Rpi_gpio failed in HA OS 12.3

For anyone still using it, there’s a known error with the rpi_gpio add-on in HA OS 12.3:

In my case it showed up as none of the GPIO pins working, and the following in the log:

2024-05-09 09:19:45.265 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up rpi_gpio platform for binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/rpi_gpio/binary_sensor.py", line 97, in setup_platform
    RPiGPIOBinarySensor(
  File "/config/custom_components/rpi_gpio/binary_sensor.py", line 132, in __init__
    edge_detect(self._port, edge_detected, self._bouncetime)
  File "/config/custom_components/rpi_gpio/__init__.py", line 59, in edge_detect
    GPIO.add_event_detect(port, GPIO.BOTH, callback=event_callback, bouncetime=bounce)
RuntimeError: Failed to add edge detection

I’m running on an RPi 3B+ but it looks like it also affects the RPi 4. I’ve also seen reports of this or a different GPIO problem the RPi 5, but I don’t know if/how that’s related.

Same for me: updating ha os from 12.2 to 12.3 breaks GPIO inputs.
Multiple reloads of gpio and reboot do nothing.
I had to downgrade to 12.2 to recover gpio :face_with_symbols_over_mouth:
Raspi 4b with GPIO hat module.
Thanks
Eddy.

A couple of people have reported good luck with a new(er) fork of the RPi GPIO custom component:

I haven’t tried it yet, but that’ll be my next step. In the end I think I’ll just use an ESP8266 and ESPHome to read my GPIO inputs. It seems silly, with the RPi sitting there with all those unused GPIO pins, but it’s pretty clear HA has abandoned them.

I reverted to a backup 12.2 but I still have the same problem. GPIO inputs are not working. GPIO outputs are working. This is frustrating as HA evolved on using PI. Not a happy bunny here!

2 Likes

How did you revert to 12.2 ?

I did it with Terminal (from ssh&web terminal) and after a full reboot, GPIO inputs are back.

HAOS Downgrade

I may be wrong but i don’t think an HA backup contains the OS… so restoring a backup won’t downgrade the os :wink:

Thanks Eddy, greatly appreciated. I assumed wrong that a backup reverted to the OS version I was on. Copied your command and success.
GPIO is back working. Phew. Thnak You

1 Like

A solution below for those wanting to upgrade os to 12.3 as reported a few posts above by CaptTom :wink:

I did try the gpio component linked above, and it worked. Unfortunately I ended up restoring all the way back to an earlier OS and Core, due to a series of problems. It started with a memory leak and crash, then severe performance issues and failures of a number of integrations. All of this happened after updating OS, Core and the GPIO component. After several days of attempts, with new things failing all the time, I was never able to identify which of those three changes (or maybe something unrelated) started everything.

Long story short: After making this change, keep an eye on your system and please report back here if you find anything odd.

1 Like

I just restore my last backup Core-2024.5.4 on a fresh new sdcard with OS 12.3
remove old rpi-gpio from HACS
Install gpiod as custom repo in HACS, 2 x full reboot (OS)
Change the syntax in config with new syntax and reboot
All seems to work fine: no message in logs, cpu usage and ram ok
Just bouncetime: setting is refused when checking config so i bypass this setting, and all works fine. i’ll spy behaviour during next few days :wink:

gpiod:
#  path: '/dev/gpiochip0' # i'm on Rpi4b

binary_sensor invert_logic:
  - platform: gpiod
    sensors:
    - name: "volet_gar_up"
      port: 04
      invert_logic: True
#    bouncetime: 1000
1 Like

Thanks for the update. I found bouncetime worked fine, but it’s indented in the list under each sensor, not under the platform like the old one.

like this(below) it doesn’t work, got error while checking config. Can you post your indentation ? Thanks !

bouncetime not working


PS: i have changed True to true (full lowercase) but no change.

All I can say is this worked, before I backed out both Core 2024.5.x and HA 12.3:

  - platform: gpio
    sensors:
      - port: 5
        name: "Heat Zone 1"
        unique_id: "gpio_heat_zone_1"
        bouncetime: 500
        invert_logic: true
      - port: 18
        name: "Heat Zone 2"
        unique_id: "gpio_heat_zone_2"
        bouncetime: 500
        invert_logic: true

Also note that I was using the “raboof” fork at raboof/ha-gpio: Custom Home Assistant component to integrate with local GPIO devices - Codeberg.org

Thanks ! I see it now you are not using the same library !

Yours is ha_gpio (gpio), mine is denef’s one gpiod !

But maybe the default value is enough for my garage door’s “red switches”…

tomorrow, i’ll give a try to raboof ha-gpio and report back :slight_smile:

For the jdeneef’s fork that i use: bouncetime is debounce !

The dev has reported very quickly :ok_hand: :ok_hand: :ok_hand:

On the right, you can see my slave raspi4 (HA2) who is hosting the GPIO hat.
CPU Load (5min) graphic. The average changed from about 0.9 to 0.1x after the change… :upside_down_face:
But as i changed: GPIO integration, OS (12.2 to 12.3), and the SDCARD : a noname brand to an sandisk EXTREME… i don’t know what makes such a big impact !