thecode / ha-rpi_gpio

Home Assistant Raspberry Pi GPIO Integration
Apache License 2.0
166 stars 37 forks source link

Last update gpio in raspberry pi4 not working #255

Open stamatakisa opened 1 month ago

stamatakisa commented 1 month ago

Last hassos 12.3 update gpios not working. i reboot all the systems but nothing happened

XavierTora commented 1 month ago

Correct same issue. Revert os update with terminal command: "ha os update --version 12.2"

MondoElectronics commented 1 month ago

Same problem 12.3 version...

pcmihnea commented 1 month ago

Same here, after updating Home Assistant Operating System to v12.3, none of the GPIO inputs are initialised anymore, although outputs still work.

Logger: homeassistant.components.binary_sensor
Source: helpers/entity_platform.py:356
integration: Binary sensor (documentation, issues)
First occurred: May 8, 2024 at 19:14:57 (1 occurrences)
Last logged: May 8, 2024 at 19:14:57

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 77, 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

Based on the runtime error, it seems the RPi GPIO library was changed from gpio to lgpio, so another Python library could be in need from rpi-gpio to rpi-lgpio

robertodomotico commented 1 month ago

same thing guys, if you have any news on how to fix it without downgrading it would be great. Thank you

CaptTom9 commented 1 month ago

Add me to the list. Running rpi_gpio on a RPi 3B+. Getting this in the log after updating to HA OS 12.3:

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

Reverted back to HA OS 12.2 and no errors, GPIO working again. Please let us know if there's anything we can do to help!

thecode commented 1 month ago

I am sorry but I don't have good news, the dependency used by this integration RPi.GPIO is not maintained for a long time, it is broken on new kernels (reported here: https://sourceforge.net/p/raspberry-gpio-python/tickets/210/#4ed1) and lake support for Raspberry Pi 5.

I initially took ownership of this integration trying to keep it alive after it was removed from Home Assistant, but rewriting it to use a different lib is a big task which I don't have time for right now.

Someone forked this integration and replaced the library but I am not sure what is the status of his integration, if you want to test it and report back I may check if I can backport the changes here.

https://codeberg.org/raboof/ha-gpio

anthfarr commented 1 month ago

Someone forked this integration and replaced the library but I am not sure what is the status of his integration, if you want to test it and report back I may check if I can backport the changes here.

https://codeberg.org/raboof/ha-gpio

I tried the fork you mentioned and good news!!! It works fine! I've been testing it out for a bit and found no issues with the 12.3 version.

CaptTom9 commented 1 month ago

I tried the fork you mentioned and good news!!! It works fine! I've been testing it out for a bit and found no issues with the 12.3 version.

Thanks!!

It looks like the config is a bit different. I like that I can give the entities a unique_id.

anthfarr commented 1 month ago

I like that I can give the entities a unique_id

To be fair this is not something new but it was existing also in the current one. In fact I had it in my config.

matsm85 commented 1 month ago

I have this problem in raspberry pi 3.

Otiel commented 1 month ago

Same on Raspberry Pi 2B

stamatakisa commented 1 month ago

I did my ha os back 12.2 version ( ha os upgrade --version 12.2 ) and all work again fine. Now i wait God (in Hacs)to find solusion...

djmvt commented 1 month ago

I did my ha os back 12.2 version ( ha os upgrade --version 12.2 ) and all work again fine. Now i wait God (in Hacs)to find solusion...

The solution quoted a few posts back is working. You have to change a few things in your configuration though.

Misiu commented 1 month ago

You have to change a few things in your configuration though.

Can you show an example of what needs to be changed?

djmvt commented 1 month ago

You have to change a few things in your configuration though.

Can you show an example of what needs to be changed?

First of all you have to install the fork manually as explained on the GitHub page, then you have to change the domain of the sensor/switch or whatever you are using to gpio in your configuration. The GitHub page of the fork shows how to format your configuration. It's impossible for me to explain in detail since gpio can be used for many devices. I'm a user just like you are ;)

Misiu commented 1 month ago

There is an updated version on Github: https://github.com/jdeneef/ha_gpiod I will test both, but the one I linked is recently updated and supports HA 2024.5

djmvt commented 1 month ago

There is an updated version on Github: https://github.com/jdeneef/ha_gpiod I will test both, but the one I linked is recently updated and supports HA 2024.5

Essentially the same changes as the one mentioned before. Both are working.

CaptTom9 commented 1 month ago

Has anyone else noticed a slow memory leak in HA (specifically, the homeassistant container) after installing the forked raboof version? The only other things I've changed are the update of HA Core to 2024.5.2 and then 2024.5.3, and the HA OS from 12.2 to 12.3. Obviously it's just as likely to be one of those other two changes which caused the memory leak to begin, but I can't rule out the GPIO component, either. And I haven't seen anyone else on the HA forum complaining, so I figured I'd ask here.

As an example, here are my old and new GPIO entries in configuration.yaml:

Old:

binary_sensor:
# GPIO: rpi_gpio platform
  - platform: rpi_gpio
    ports:
      5: Heat Zone 1
      18: Heat Zone 2
      22: Heat Zone 3
      23: Heat Future
      25: Boiler Burner
    invert_logic: true
    bouncetime: 500

New:

binary_sensor:
# GPIO: new (2024 05) gpio platform
  - 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
      - port: 22
        name: "Heat Zone 3"
        unique_id: "gpio_heat_zone_3"
        bouncetime: 500
        invert_logic: true
      - port: 23
        name: "Heat Future"
        unique_id: "gpio_heat_future"
        bouncetime: 500
        invert_logic: true
      - port: 25
        name: "Boiler Burner"
        unique_id: "gpio_boiler_burner"
        bouncetime: 500
        invert_logic: true
nqntRench commented 1 month ago

There is an updated version on Github: https://github.com/jdeneef/ha_gpiod I will test both, but the one I linked is recently updated and supports HA 2024.5

It works fine for me and can be added directly to HACS custom repositories.

DeCodeerHeer commented 1 month ago

Has anyone else noticed a slow memory leak in HA (specifically, the homeassistant container) after installing the forked raboof version? The only other things I've changed are the update of HA Core to 2024.5.2 and then 2024.5.3, and the HA OS from 12.2 to 12.3. Obviously it's just as likely to be one of those other two changes which caused the memory leak to begin, but I can't rule out the GPIO component, either. And I haven't seen anyone else on the HA forum complaining, so I figured I'd ask here.

As an example, here are my old and new GPIO entries in configuration.yaml:

Old:

binary_sensor:
# GPIO: rpi_gpio platform
  - platform: rpi_gpio
    ports:
      5: Heat Zone 1
      18: Heat Zone 2
      22: Heat Zone 3
      23: Heat Future
      25: Boiler Burner
    invert_logic: true
    bouncetime: 500

New:

binary_sensor:
# GPIO: new (2024 05) gpio platform
  - 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
      - port: 22
        name: "Heat Zone 3"
        unique_id: "gpio_heat_zone_3"
        bouncetime: 500
        invert_logic: true
      - port: 23
        name: "Heat Future"
        unique_id: "gpio_heat_future"
        bouncetime: 500
        invert_logic: true
      - port: 25
        name: "Boiler Burner"
        unique_id: "gpio_boiler_burner"
        bouncetime: 500
        invert_logic: true

I noticed my binary sensors are slower to report. I have a door sensor wired into GPIO. Previously when I opened my door the automation ran directly and the lights turned on. Now it takes a second or three to actually notice the change.

This is ever since I updated to the new OS update and the fork mentioned above. The signals being outputted do not have this delay.

stamatakisa commented 1 month ago

This github version " https://github.com/jdeneef/ha_gpiod " i test it but it has problems. I install "https://codeberg.org/raboof/ha-gpio" after first mesh all my gpios working properly.

Sunratte commented 1 month ago

This github version " https://github.com/jdeneef/ha_gpiod " i test it but it has problems. I install "https://codeberg.org/raboof/ha-gpio" after first mesh all my gpios working properly.

have you installed with HACS?

sndrod commented 1 month ago

I have an Rpi5 and this does not work, or at least work consistently. Sometimes some of the switches and sensors appear, but mostly do not, and it appears random. This is all very depressing, given how much work I have put into HA.

matsm85 commented 1 month ago

My entire wired home automation system has been rendered useless. I hope someone has the time to fix this.

Misiu commented 1 month ago

@matsm85 did you try two linked alternatives? https://codeberg.org/raboof/ha-gpio https://github.com/jdeneef/ha_gpiod

Misiu commented 1 month ago

This github version " https://github.com/jdeneef/ha_gpiod " i test it but it has problems.

please consider creating issues in the addon repo. It is actively developed, so if there are issues the author might fix them.

sndrod commented 1 month ago

@matsm85 did you try two linked alternatives? https://codeberg.org/raboof/ha-gpio https://github.com/jdeneef/ha_gpiod

I tried both of these

sndrod commented 1 month ago

Moving to Wemos

comet424 commented 1 month ago

anyone know when this will be fixed. as its important for me to get these back up and running.. is the addon issue.. or is it the HA OS or Core or Supervisor issue that caused this problem? and is there a fix being worked on?

Misiu commented 1 month ago

@comet424 try those two alternatives I've linked just 3 comments earlier. I'm not sure the author has the hardware and the time to fix the issue. It is related to the 12.3 OS update. Try downgrading to 12.2

Misiu commented 1 month ago

@matsm85 did you try two linked alternatives? https://codeberg.org/raboof/ha-gpio https://github.com/jdeneef/ha_gpiod

I tried both of these

I assume none of them worked or you have some issues. Did you create issues in the repositories if you had issues? Without an issue, the author doesn't know there is a problem and can't help.

comet424 commented 1 month ago

@Misiu are the GPIOD and the other one are they supposed to to be alternative to this plugin? i dunno why HA ever removed gpio...
ill give them a try... i use a RPi4 running HA with the gpio to be a crticial pump to pump water out of my basement.. i lucky the relay switch works but the binary sensors dont work... so it cant sensors switchs i press... but ill give those a test shortly... but it is frustrating its been solid working fine since the last updates or so

Misiu commented 1 month ago

I had the same issue. I remember when the HA team removed GPIO support, it was frustrating, but to this repo author, we still had the option to use GPIO and 1wire devices. The latest version of the Linux kernel isn't compatible with RPI.GPIO so that's the problem, not the Home Assistant developers, they had nothing to do with the issue in OS 12.3

You can always SSH to your PI and call ha os upgrade --version 12.2. This should temporarily fix the issue so that the critical devices will work again.

comet424 commented 1 month ago

@Misiu i wonder why linux changed how gpios worked? shouldnt it not be changed as you use linux on raspberry pis??

so i having troubles for the first on... i downloaded the zip got ha_gpio folder i copyed it to my custom folders. and changed platform to - platform : gpio
and reboot.. not found i have tried platform : ha_gpio i tried renaming ha_gpio folder to gpio etc still not found in the logs... what does it take to fix that?

wonder why linux changed things that it cant handle gpios and i thought home assistant developers made the OS?

CaptTom9 commented 1 month ago

For anyone else frustrated by this, I have had good results switching over to an ESP8266 running ESPHome to monitor the relays which had been connected to the GPIO pins on my RPi. In fact I already had it monitoring temperatures so it was just a matter of moving the wires and adding some lines to the YAML.

It's a shame the HA team decided to abandon the RPi GPIO support. It's such a fundamental part of the RPi hardware that it seems it would be important to support. Reading between the lines, I think the HA devs are drifting away from the RPi platform, probably for good reason. But I think it will seriously limit the number of people who are drawn to HA in the long run.

comet424 commented 1 month ago

@Misiu i got it to work with the first one.. i had to figure it out... so... you dont use the ha_gpio folder.. you need to look inside it and copy the gpio folder from there... and i had to rename rpi_gpio to oldrpi_gpio and reboot.. to get it to work what a pain though

comet424 commented 1 month ago

@CaptTom9 i run a few HAs and one of them is a standalone just to run a pump in my basement with timers and press a button to turn it on and off so more powerful then esphome device and then i use it to link it to the main HA with the remote home assistant which also has its own issues now on depreciation... but ya its a shame they went away.. but i made it as i wasnt good enough with arduinio coding and cron tabing setup was getting to be a pain so i loved how i made HA a stand alone for a pump but a pain when the gpio fail on update... but i seem to got it running again but i dunno how long it last with that one version

robertodomotico commented 1 month ago

Hi everyone, between the two alternatives I tried this: https://github.com/jdeneef/ha_gpiod and it works perfectly on my RPI4. It is very simple to adopt it, let's not despair, there is always a solution! infinite thanks to the author who saved our lives ;) A small note: I first removed the old integration and also the old entities, otherwise the new integration, finding the same entity names in configuration, renames them and it seemed they were not read correctly in the lovelace and instead they were there.

comet424 commented 1 month ago

i will have to try the gpiod next... i finding the ha_gpio one the first option it works but its slow.. so to register a button press you actually have to hold the button 2 seconds instead of a mili second press... so for whatever reason that one is super slow... ill give that other one a try

MondoElectronics commented 1 month ago

Hi All, i switched to GPIOD after GPIO failed (RPI 4 + HA) and so far so good, I am using it around 1 month and it is stable and fast enough to register PIR sensor activity, I use it for ALARMO. So I am satisfied with GPIOD functionality

sndrod commented 1 month ago

What Raspberry Pi are you using - I use 5 and could not get it to work

sndrod commented 1 month ago

Anyway, I am now trying Wemos instead

mburget commented 3 weeks ago

Hi All, i switched to GPIOD after GPIO failed (RPI 4 + HA) and so far so good, I am using it around 1 month and it is stable and fast enough to register PIR sensor activity, I use it for ALARMO. So I am satisfied with GPIOD functionality

same here, gpiod (https://github.com/jdeneef/ha_gpiod) works fine for me on a rpi4. I had performance issues with the other one (https://codeberg.org/raboof/ha-gpio)

thecode commented 3 weeks ago

I will look about migrating the changes from ha_gpiod here

github-actions[bot] commented 1 week ago

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

Sunratte commented 1 week ago

I use an RPi4 with gipiod. It works perfectly for me too. It still works rpi_gpio for outputs and gpiod for inputs.