Problem: The Pi GPIO pin state is sometimes detected correctly but sometimes not. It’s random, but seems to get worse the longer HA has been running.
Objective: Physical shutdown button on the Pi. Press the button to start a safe shut-down process automated in Node-Red.
Setup: tactile switch normally open wired between GPIO22 and ground. When pressed it shorts GPIO22 to ground. (I also set up another on GPIO17 to compare)
Home Assistant Core 0.106.5, Operating System 3.12
The set-up is practically bare, I haven’t got going with any devices or automation yet.
I enabled i2c following this guide: https://www.home-assistant.io/hassio/enable_i2c/
I created two binary-sensors in configuration.yaml
binary_sensor:
- platform: rpi_gpio
ports:
17: gpio17
26: gpio26
I also installed the Node-Red palette node-red—node-pi-gpio
Both these binary_sensors show up in Lovelace. When I press the physical buttons you see the state change sometimes, sometimes not. It’s totally unreliable.
I have confirmed the Pi is functioning correctly by running a stock Raspbian installation and using gpiotest https://elinux.org/R-Pi_Troubleshooting#Testing
In the stock Raspbian Node-Red detects the button presses/state changes with no problems.
I’ve checked the voltages on the pins are correct and that the momentary buttons are physically good.
In Node-Red using rpi_gpio_in node it does not detect the pin state correctly, nor does it react to state change.
I am a noob so I can’t tell if I’m doing something totally dumb!
Can anyone help?