added relay_controller to mqtt_on_message if
Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>master
parent
264b35ed0b
commit
a162bbf897
21
main.py
21
main.py
|
@ -82,26 +82,31 @@ def mqtt_on_message(client, userdata, msg):
|
||||||
topic = str(msg.topic)
|
topic = str(msg.topic)
|
||||||
payload = str(msg.payload.decode("utf-8"))
|
payload = str(msg.payload.decode("utf-8"))
|
||||||
|
|
||||||
|
channel_1 = 4
|
||||||
|
channel_2 = 17
|
||||||
|
channel_3 = 27
|
||||||
|
channel_4 = 11
|
||||||
|
|
||||||
if topic == "strawberry-pi-greenhouse/relay/channel/1":
|
if topic == "strawberry-pi-greenhouse/relay/channel/1":
|
||||||
if payload == "on":
|
if payload == "on":
|
||||||
relay_ch_1.on()
|
relay_controller(channel_1, True)
|
||||||
elif payload == "off":
|
elif payload == "off":
|
||||||
relay_ch_1.off()
|
relay_controller(channel_1, False)
|
||||||
elif topic == "strawberry-pi-greenhouse/relay/channel/2":
|
elif topic == "strawberry-pi-greenhouse/relay/channel/2":
|
||||||
if payload == "on":
|
if payload == "on":
|
||||||
relay_ch_2.on()
|
relay_controller(channel_2, True)
|
||||||
elif payload == "off":
|
elif payload == "off":
|
||||||
relay_ch_2.off()
|
relay_controller(channel_2, False)
|
||||||
elif topic == "strawberry-pi-greenhouse/relay/channel/3":
|
elif topic == "strawberry-pi-greenhouse/relay/channel/3":
|
||||||
if payload == "on":
|
if payload == "on":
|
||||||
relay_ch_3.on()
|
relay_controller(channel_3, True)
|
||||||
elif payload == "off":
|
elif payload == "off":
|
||||||
relay_ch_3.off()
|
relay_controller(channel_3, False)
|
||||||
elif topic == "strawberry-pi-greenhouse/relay/channel/4":
|
elif topic == "strawberry-pi-greenhouse/relay/channel/4":
|
||||||
if payload == "on":
|
if payload == "on":
|
||||||
relay_ch_4.on()
|
relay_controller(channel_4, True)
|
||||||
elif payload == "off":
|
elif payload == "off":
|
||||||
relay_ch_4.off()
|
relay_controller(channel_4, False)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue