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 subscribe(client: mqtt_client):
def on_message(client, userdata, msg): def on_message(client, userdata, msg):
print(f"Received `{msg.payload.decode()}` from `{msg.topic}` topic") print(f"Received `{msg.payload.decode()}` from `{msg.topic}` topic")
a = json.loads(msg.payload.decode()) json_response = json.loads(msg.payload.decode())
if "color" in a: if "color" in json_response:
hex = convert_to_bulb_format(a) hex = convert_to_bulb_format(json_response)
run_bulb_action(hex) run_bulb_action(hex)
else: else:
if a["state"] == "OFF": if json_response["state"] == "OFF":
run_bulb_action("cc2433") run_bulb_action("cc2433")
else: else:
run_bulb_action("cc2333") run_bulb_action("cc2333")