update to json_response

This commit is contained in:
karl.hudgell 2021-10-28 10:17:11 +01:00
parent 71151758b5
commit eda62774ec

View File

@ -51,12 +51,12 @@ def publish(client):
def subscribe(client: mqtt_client):
def on_message(client, userdata, msg):
print(f"Received `{msg.payload.decode()}` from `{msg.topic}` topic")
a = json.loads(msg.payload.decode())
if "color" in a:
hex = convert_to_bulb_format(a)
json_response = json.loads(msg.payload.decode())
if "color" in json_response:
hex = convert_to_bulb_format(json_response)
run_bulb_action(hex)
else:
if a["state"] == "OFF":
if json_response["state"] == "OFF":
run_bulb_action("cc2433")
else:
run_bulb_action("cc2333")