diff --git a/main.py b/main.py index ed50bc6..9311190 100644 --- a/main.py +++ b/main.py @@ -82,26 +82,31 @@ def mqtt_on_message(client, userdata, msg): topic = str(msg.topic) 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 payload == "on": - relay_ch_1.on() + relay_controller(channel_1, True) elif payload == "off": - relay_ch_1.off() + relay_controller(channel_1, False) elif topic == "strawberry-pi-greenhouse/relay/channel/2": if payload == "on": - relay_ch_2.on() + relay_controller(channel_2, True) elif payload == "off": - relay_ch_2.off() + relay_controller(channel_2, False) elif topic == "strawberry-pi-greenhouse/relay/channel/3": if payload == "on": - relay_ch_3.on() + relay_controller(channel_3, True) elif payload == "off": - relay_ch_3.off() + relay_controller(channel_3, False) elif topic == "strawberry-pi-greenhouse/relay/channel/4": if payload == "on": - relay_ch_4.on() + relay_controller(channel_4, True) elif payload == "off": - relay_ch_4.off() + relay_controller(channel_4, False) if __name__ == "__main__":