changed msg.topic/msg.payload into var's
Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>master
parent
4fd8d0b037
commit
225f80587b
27
main.py
27
main.py
|
@ -68,23 +68,26 @@ def mqtt_on_connect(client, userdata, flags, rc):
|
|||
client.subscribe("server-rack-led-1/b")
|
||||
|
||||
def mqtt_on_message(client, userdata, msg):
|
||||
print(f"Message received [{msg.topic}]: {msg.payload}")
|
||||
if str(msg.topic) == "server-rack-led-1/power":
|
||||
power = str(msg.payload)
|
||||
print("topic: " ,str(msg.topic.decode("utf-8")))
|
||||
print("payload: " ,str(msg.payload.decode("utf-8")))
|
||||
topic = str(msg.topic.decode("utf-8"))
|
||||
payload = str(msg.payload.decode("utf-8"))
|
||||
if topic == "server-rack-led-1/power":
|
||||
power = payload
|
||||
|
||||
elif str(msg.topic) == "server-rack-led-1/r":
|
||||
r = str(msg.payload)
|
||||
elif topic == "server-rack-led-1/r":
|
||||
r = payload
|
||||
|
||||
elif str(msg.topic) == "server-rack-led-1/g":
|
||||
g = str(msg.payload)
|
||||
elif topic == "server-rack-led-1/g":
|
||||
g = payload
|
||||
|
||||
elif str(msg.topic) == "server-rack-led-1/b":
|
||||
b = str(msg.payload)
|
||||
elif topic == "server-rack-led-1/b":
|
||||
b = payload
|
||||
|
||||
elif str(msg.topic) == "server-rack-led-1/mode":
|
||||
if str(msg.payload) == "0":
|
||||
elif topic == "server-rack-led-1/mode":
|
||||
if payload == "0":
|
||||
mode = 0
|
||||
elif str(msg.payload) == "1":
|
||||
elif payload == "1":
|
||||
mode = 1
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue