Controlling a RPI switch that is setup in the configuration.yaml file with node-red

First, I have literally spent hours researching and trying to resolve this problem with no success. I installed HA as the OS on the RPI and it is up and running with some of the most popular add-on. I have the switch set up in the configuration.yaml file:

switch:

  • platform: rpi_gpio
    switches:
    • port: 23
      name: “RPI GPIO 23 Switch”

And there is an entity that shows up on the HA Overview tab and it works to control RPI GPIO 23 that connect to an LED. Its entity id is: switch.rpi_gpio_23_switch. Now I would like to control that switch from a Node-RED flow and I can’t figure it out. The RPI palette tools in Node-RED do not work (I believe that is common knowledge.)

I would appreciate your help.

Regards,
Roger

If it is a switch inside HA, use an action node with switch.turn_on/switch.turn_off.

Thanks for the reply. I have tried that numerous times in the past without success and I just tried it again. At one time it would list the switch in the entity id but it doesn’t even do that now. And when it did I still couldn’t get it work with the command turn_on and turn_off commands. If you have time can you please provide a short step by step. I would appreciate it. I also have a discord server and I can share my screen with you.

Just need to set up a time.

Regards,

Roger

If the entity is not available in home assistant, you will not be able to use nodered to control it. I don’t use the gpio integration so I can’t help you get that working. The first step would be to get the integration working.

Thanks for the reply. The switch is available on the HA overview page and I can use it to control the GPIO connected to the LED on the RPI. I just want to try to control it from Node-RED. And that is what I can’t seem to get working.

Regards,

Roger

On the overview page click on the switch so that the more info popup comes up. Then click the gear icon on the top right. There you will see the entity id of the switch. copy it.

Go to nodered and enter the entity id in an action node and select it.

Select switch.turn_on in the action section.

Thanks. It works!
Regards,
Roger

1 Like