Adapted to legacy protocol

parent 6d442824
......@@ -3,20 +3,34 @@ import ujson
import config
import env
OPEN_VALUE = "open"
CLOSED_VALUE = "closed"
def _hq_changed_status(_, msg):
data = ujson.loads(msg)
print("The HQs status was changed to {}".format(data["status"]))
if data["status"] == True:
print("An update was come")
try:
data = ujson.loads(msg)
except:
print("Invalid JSON was provided")
return
if "status" not in data:
print("An invalid update was provided")
return
if data["status"] == OPEN_VALUE:
env.status = True
else:
elif data["status"] == CLOSED_VALUE:
env.status = False
else:
print("Invalid value of \"status\"")
def _hq_changes_status():
data = {
"id": config.BUTTON_ID,
"status": not env.status
"status": OPEN_VALUE if env.status else CLOSED_VALUE
}
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment