added new device types

This commit is contained in:
Nico Melone
2024-10-04 18:56:11 -05:00
parent 79b2f149df
commit 7c3f3519a4
24 changed files with 80728 additions and 1424 deletions

Binary file not shown.

View File

@@ -1,4 +1,4 @@
import json, time
import json, time, os
from datetime import datetime as dt
from quickfaas.measure import recall, write
from quickfaas.remotebus import publish
@@ -48,7 +48,13 @@ def writeplctag(value):
except Exception as e:
logger.debug(e)
return False
def reboot():
#basic = Basic()
logger.info("!" * 10 + "REBOOTING DEVICE FROM CLOUD" + "!"*10)
r = os.popen("kill -s SIGHUP `cat /var/run/python/supervisord.pid`").read()
logger.info(f"REBOOT : {r}")
def receiveCommand(topic, payload):
try:
logger.debug(topic)
@@ -58,6 +64,7 @@ def receiveCommand(topic, payload):
commands = {
"sync": sync,
"writeplctag": writeplctag,
"reboot": reboot
}
if command == "setPLCTag":
try:
@@ -65,6 +72,12 @@ def receiveCommand(topic, payload):
logger.debug(result)
except Exception as e:
logger.error(e)
elif command == "reboot":
try:
ack(topic.split("/")[-1])
commands["reboot"]()
except Exception as e:
logger.error(e)
#logger.debug(command)
ack(topic.split("/")[-1])
time.sleep(2)