-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheol_plugin.py
More file actions
40 lines (34 loc) · 1018 Bytes
/
Copy patheol_plugin.py
File metadata and controls
40 lines (34 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
#mqtta version 1
#end-of-life plugin
#get eol from file and retrieve it and display it
from io import StringIO
import utility as utility
from datetime import datetime
import time
from core import MyApp
import os
import paho.mqtt.client as mqtt
class Plugin:
def process(self):
f = utility.Utility()
ip = f.ip()
eol = f.eol()
hostname = f.host()
#variable extracted from topic name
subT = f.subtopic()
#broker ip set in setup.config file
BROKER = f.broker()
DV = f.DynamicVariable()
while True:
broker = BROKER
client = mqtt.Client(ip)
client.connect(broker)
client.loop_start()
if(subT == ""):
client.publish(f"workstation/{hostname}/n/eol", str(eol), 2, False)
setattr(f, "logText", str(eol))
f.log()
time.sleep(0.5)
client.disconnect()
exit()