diff --git a/main.py b/main.py index 687ea67..34ce2e7 100644 --- a/main.py +++ b/main.py @@ -24,13 +24,13 @@ def error_print(message: str): print('[ERROR]['+current_time+'] '+message) #relay -def relay_controller(pin: int, state): +def relay_controller(pin: int, state: str): print(state) - if state == True: + if state == "True": relay = gpiozero.OutputDevice(pin, active_high=True, initial_value=False) relay.on() debug_print("Set relay-pin "+str(pin)+" to state True") - elif state == False: + elif state == "False": relay = gpiozero.OutputDevice(pin, active_high=True, initial_value=False) relay.off() debug_print("Set relay-pin "+str(pin)+" to state False") @@ -92,24 +92,24 @@ def mqtt_on_message(client, userdata, msg): if topic == "strawberry-pi-greenhouse/relay/channel/1": if payload == "on": - relay_controller(channel_1, True) + relay_controller(channel_1, "True") elif payload == "off": - relay_controller(channel_1, False) + relay_controller(channel_1, "False") elif topic == "strawberry-pi-greenhouse/relay/channel/2": if payload == "on": - relay_controller(channel_2, True) + relay_controller(channel_2, "True") elif payload == "off": - relay_controller(channel_2, False) + relay_controller(channel_2, "False") elif topic == "strawberry-pi-greenhouse/relay/channel/3": if payload == "on": - relay_controller(channel_3, True) + relay_controller(channel_3, "True") elif payload == "off": - relay_controller(channel_3, False) + relay_controller(channel_3, "False") elif topic == "strawberry-pi-greenhouse/relay/channel/4": if payload == "on": - relay_controller(channel_4, True) + relay_controller(channel_4, "True") elif payload == "off": - relay_controller(channel_4, False) + relay_controller(channel_4, "False") if __name__ == "__main__":