added relay with global channels

Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>
master
Ebbe Baß 2022-07-13 09:51:58 +02:00
parent 376f2582da
commit ee1a5ac09d
1 changed files with 32 additions and 4 deletions

28
main.py
View File

@ -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,12 +100,24 @@ def mqtt_on_message(client, userdata, msg):
payload = str(msg.payload.decode("utf-8"))
if topic == "strawberry-pi-greenhouse/relay/channel/1":
if payload == "on":
pass
elif payload == "off":
pass
elif topic == "strawberry-pi-greenhouse/relay/channel/2":
if payload == "on":
pass
elif payload == "off":
pass
elif topic == "strawberry-pi-greenhouse/relay/channel/3":
if payload == "on":
pass
elif payload == "off":
pass
elif topic == "strawberry-pi-greenhouse/relay/channel/4":
if payload == "on":
pass
elif payload == "off":
pass