Switch from python script to node red

Hello, I would like to use node red instead of a python script which is started at system start. Unfortunately, I am not getting the functionality to run. Here is my python script:


#Einstellungen
klingel_gpio = 4 #GPIO, der mit der Schaltung verbunden ist

gpio.setmode(gpio.BCM)
gpio.setup(klingel_gpio, gpio.IN, pull_up_down=gpio.PUD_UP)
gpio.add_event_detect(klingel_gpio, gpio.FALLING)
gpio.event_detected(klingel_gpio)

while True:
time.sleep(1)
if gpio.event_detected(klingel_gpio):
actions.handleAction("Someone is in front of the door")
time.sleep(5)
gpio.event_detected(klingel_gpio)


I tested the node node gpio_in (set it to gpio 4 and Pull up) but it does not work. Does anyone has an idea what I am doing wrong.

If you are running node-red, what does your node-red flow look like?
Do you have node-red running at startup?
What platform are you using? Pi, Windows?

1 Like

Also check that gpio 4 in the node-red node is the same pin as is meant by 4 in the python script. There is often confusion over pin number vs gpio number.

Do I have to do anything else?

You shouldn't have to. When the pin state chages you should get a message.

1 Like

Ok. Thank you. I will retry next weekend and give you feedback.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.