Reading GPIO binary sensor does not work

Hi,
I’ve tested the used sensor hw with a simple Python RPi script, on a Raspberry Pi Model 2 B, and it reads the state changes fine, when I change the input to the sensors.

When I connect the sensor hw to the HA raspberry (Model 4), HA does not read at all the sensor state changes. They are always seen as ‘Off’ in the GUI.

I have used a GPIO cable connector to make sure I don’t mess up with GPIO pins when switching the hw from one Pi to the other.

I’ve also used a voltage meter, and I see that the voltage is correctly raised to 3.3V from 0V in the input pin, but GUI does not follow. I tried setting small and large bounce_time but it didn’t help.

# Sensors
binary_sensor:
  - platform: rpi_gpio
    invert_logic: false
    pull_mode: 'DOWN'
    ports:
      6: Garage Door
      17: Front Gate
      27: Corridor Lights
      22: Garage Lights
      5: Front Door Light

Pins 6 and 17 are used also as state_pins of two covers, further below in the configuration and they work fine (the input is coming from the same sensor HW as the non-working 27,22 and 5 pins).

Any ideas how to solve or troubleshoot further?

Not sure if applies to the Pi 2 B, but there’s a bunch of information about GPIO on a Pi 3 and 4 here:

and here:

and here:

Summary: HA doesn’t do GPIO pins well.

Thanks @CaptTom,
Not sure if I’m sad reading your reply because of HA not supporting the rpio_platform binary sensor, or glad that reading your command line based workaround here it finally worked for me.

I confirm have 5 binary sensors defined now with scan_interval set to 1s and work fine so far on RPi 4 model B.

1 Like

Glad it worked, thanks for letting us know!

Just to clarity, there has been some progress on updates for GPIO handling in HA. I haven’t really had the time or inclination to help test the updates, since the command-line workaround is stable and there are enough changes going on in HA lately that I just don’t want to add to them. It could be that, someday soon, we can go back to using the native GPIO processing.

I also want to point out that the workaround isn’t ideal for everyone. A scan_interval of 15 seconds is fine for my needs (monitoring my heating system) because things happen on much longer time scales than that. You’re having good luck with a one-second interval, great! But for some use cases (like a doorbell) that wouldn’t work.