diff --git a/main.py b/main.py index b845500..ccce1b7 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,22 @@ except ImportError: print(ImportError) exit() +RELAY_PIN_CH_1 = 4 +RELAY_PIN_CH_2 = 17 +RELAY_PIN_CH_3 = 27 +RELAY_PIN_CH_4 = 11 + +global relay_ch_1 +relay_ch_1 = gpiozero.OutputDevice(RELAY_PIN_CH_1, active_high=True, initial_value=False) + +global relay_ch_2 +relay_ch_2 = gpiozero.OutputDevice(RELAY_PIN_CH_2, active_high=True, initial_value=False) + +global relay_ch_3 +relay_ch_3 = gpiozero.OutputDevice(RELAY_PIN_CH_3, active_high=True, initial_value=False) + +global relay_ch_4 +relay_ch_4 = gpiozero.OutputDevice(RELAY_PIN_CH_4, active_high=True, initial_value=False) def debug_print(message: str): now = datetime.now() @@ -84,13 +100,25 @@ def mqtt_on_message(client, userdata, msg): payload = str(msg.payload.decode("utf-8")) if topic == "strawberry-pi-greenhouse/relay/channel/1": - pass + if payload == "on": + pass + elif payload == "off": + pass elif topic == "strawberry-pi-greenhouse/relay/channel/2": - pass + if payload == "on": + pass + elif payload == "off": + pass elif topic == "strawberry-pi-greenhouse/relay/channel/3": - pass + if payload == "on": + pass + elif payload == "off": + pass elif topic == "strawberry-pi-greenhouse/relay/channel/4": - pass + if payload == "on": + pass + elif payload == "off": + pass if __name__ == "__main__":