# Switch from python script to node red

**URL:** <https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454>\
**Category:** General\
**Created:** [9 February 2020 13:12 UTC](https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454 "2020-02-09T13:12:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joezi](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joezi](https://discourse.nodered.org/u/Joezi)\
**Post date:** [9 February 2020 13:12 UTC](https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454/1 "2020-02-09T13:12:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 February 2020 14:43 UTC](https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454/2 "2020-02-09T14:43:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 February 2020 16:54 UTC](https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454/3 "2020-02-09T16:54:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joezi](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joezi](https://discourse.nodered.org/u/Joezi)\
**Post date:** [9 February 2020 18:08 UTC](https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454/4 "2020-02-09T18:08:22Z")

</div>

![screesnhot](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/f/af34b861a0f71a4aedd0a94a8335fd12c7b45997.jpeg)

---

<div class="post-metadata">

**Author:** ![Joezi](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joezi](https://discourse.nodered.org/u/Joezi)\
**Post date:** [9 February 2020 18:09 UTC](https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454/5 "2020-02-09T18:09:00Z")

</div>

Do I have to do anything else?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 February 2020 19:00 UTC](https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454/6 "2020-02-09T19:00:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Joezi](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joezi](https://discourse.nodered.org/u/Joezi)\
**Post date:** [9 February 2020 19:03 UTC](https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454/7 "2020-02-09T19:03:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 April 2020 19:03 UTC](https://discourse.nodered.org/t/switch-from-python-script-to-node-red/21454/8 "2020-04-09T19:03:40Z")

</div>

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