update to json_response
This commit is contained in:
parent
71151758b5
commit
eda62774ec
8
mqtt.py
8
mqtt.py
@ -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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user