NodeRed in HASS trying to move servo

Hi everyone,
I’m kinda new to HASS as I came over from OpenHAB. My old instance of OH1 broke down and moving over to OH3 was just a pain in the a** so I decided to give HASS a chance. Never regretted it!

There is just one thing which I simply cannot get to run and therefore asking for help. I’ve got a servo motor which needs to be triggered by my HASS instance. This servo uses a remote control for me to activate and deactivate my house alarm.

I was hoping to be able to use my old python script, which I scrambled together by using goolge. This exact script did the job back in my openHAB-days:

import RPi.GPIO as gpio
import time

servopin = 18

gpio.setup(servopin, gpio.OUT)
servo = gpio.PWM(servopin, 50)


I had to learn that import is no option when running py-scripts in HASS :frowning: so I had to find a new solution. I learned that node-red and it’s gpio integrations might be worth a look at - and thats where I’m stuck at.

I created a sequence which triggers correctly - I simply attached the output to my lights and they toggle according to my newly created helper input_boolean.wachhund

Now there seem to be two ways. One would be the -already integrated - rpi-gpio out node or the node-red-node-pi-gpiod which I just added. I’m trying to trigger the regular rpi-gpio by the following, but when triggered it simply says “N/A on”. I set the pin to “12 - GPIO 18”, Type: “PWM output” with a frequency of 50 Hz.

When I try to trigger the installed node node-red-node-pi-gpiod the following way it says “econnrefused localhost:8888”. I configured it to pin “12 - GPIO 18”, Type “PWM output”, with a frequency of 50 Hz and the localhost with port 8888.

Can you give any advice of how to proceed or how to debug?
Here’s some more general info:

  • back then I was running the above mentioned import-py script on a RPi2 , now I’m using a RPi3
  • 15 W Power Supply for the RPi (I think even 18 W)
  • brown servo cable attached to Pin 6 (ground)
  • red servo cable attached to Pin 2 (5V Power Supply)
  • orange servo cable attached to Pin 12 (GPIO 18)
  • cables had to be extended thus there is a color-change (servo-brown : jumper-cable-yellow ; servo-red : jumper-cable-red ; servo-orange : jumper-cable-orange)

Thanks in advance!

Although there is no answer to my request by now maybe some topics I’d like to drop to see if anybody can advise any direction:

As of now I suggest that GPIO is deactivated thus I get the ECONNREFUSED error. I read “I had to enable the remote GPIOD access in the Raspberry Pi configuration at interfaces.” here:

Do you guys think this might be a way? It seems to me that changing this options is quite a hassle in HASS-os as I cannot simply connect via ssh, right? It seems to me that I need to follow that howto to be able to connect via ssh:
Do you think its worth the effort (which seems quite high to me)?

Or am I completely wrong?

I’m thankful for any kind of assistance here!

I’m just testing this stuff, to make my pupils complete some tasks in their domotic project this year.
A lightweight door is actioned by a servo, the sg90 model. We have succeeded with Arduino (uno, mini or ES8622), using a current sketch directly attached to buttons, or a mqtt client. We have used Tinkercad to learn about graphical programming, and now we are moving to Node Red. This scenario can be wide:
1- local pc with node red ----> direct connected arduino ----> servo
2- local pc with node red ----> mqtt server ----> raspberry ----> servo
3- local pc ----> raspberry with node red ----> servo
4- any device —> local node red ui -----> mqtt server ----> raspberry with node red ----> servo

Along with 3 and 4, we have the possibility of accesing Node Red (in pc or Raspberry) using any wifi connected device. The point in using local pc with node red is to avoid merging different students flows in the same node red server. In this case, mqtt server is a way to solve final access to raspberry. But we could use several raspberries and dilute the merging.

Servo is configured both in a gpio, and gpiod. The first is marked as a PWM type, while the second is marked as servo.
Both nodes can’t be active at the same time: gpio node sends signal every 4 seconds aprox. and this is annoying: the servo goes and return every time from one position to other.
Gpio moves the servo all wide range, but it is continuously sending signals, and the device is randomly unstable. With some injected numbers, like 1 or 2, it makes noise.
Gpiod servo mode can’t move the servo more than 80 or 100 degrees. I haven’t found any limits configuration that extends the movement range.
Today I’ll try to use gpiod pwm mode, but I suspect it will do the same as gpio node.

In other sort of scenary, I’m guessing where to use mosquitto in same raspberry or use mqtt node-red server. I don’t know which one will perform best.

You would probably do better asking this question in the nodered forum. HA has it’s own gpio integration as well as esphome. I’d venture to say the majority of users here utilize those options rather than nodered.