Remote_rpi_gpio: close->open->close, then needs reboot

In hassio / rpi4, been spending the past week troubleshooting the same problem reported here:

specifically, the exception

 AttributeError: 'NoneType' object has no attribute 'holding'

I tried tinkering with this, as I’m eager to get GPIOs migrated over to HA from the controller software I’ve been using for a long time.

I copied the remote_rpi_gpio implementation into my custom_modules, then under that dir I cloned gpiozero and renamed the package. I added a line before the one throwing the exception in mixins.py, so that it looks like:

       if self._hold_thread is not None and 'holding' in self._hold_thread: 
           self._hold_thread.holding.set()

(warning: this is something I tried, I have no idea whether it is a fix for the problem, or is just hiding another one by covering up an initialization order issue)

After trying this, no exceptions and my binary sensors are now available entities. I got excited when I saw that they worked when I triggered them. Unfortunately they only work once per reboot. In other words, for my front door the initial state is correct: closed. Opening it correctly triggers an open, then closing back to close. After that, state never changes until reboot. Same for all my other GPIOs.

I spent many hours trying to troubleshoot, but no luck so far.

Anyone else have this problem?

Got everything working. For those interested:

  • if you don’t need the ‘holding’ functionality in gpiozero

  • you only need simple open/close status for dry contacts (as is my case: doors, windows, etc.)

  • You don’t mind running your own version of remote_rpi_gpio and gpiozero (I can’t wait for the ‘proper’ fix as I’m migrating off a subscription based HA controller)

Then you can implement this workaround in 15 minutes. Mine has been functioning stably for several days now using 10 binary sensors.

  1. In config, make the custom_components directory if it doesn’t already exist, and under there, create the directory remote_rpi_gpio

  2. Copy all the files in the remote_rpi_gpio implementation from here
    , and copy them to the remote_rpi_gpio dir

  3. Edit __init__.py. Change the lines

from gpiozero import LED, Button                                           
from gpiozero.pins.pigpio import PiGPIOFactory      

to

from .mygpiozero import LED, Button                                           
from .mygpiozero.pins.pigpio import PiGPIOFactory   

You can use any name instead of mygpiozero, but I would name it something other than gpiozero

  1. Copy the gpiozero directory with its files from here
    to the current dir and rename it, so that you have:
config/custom_components/remote_rpi_gpio/mygpiozero

with all the files in it. Easiest to do by cloning the repo from github and moving that folder to the remote_rpi_gpio dir and renaming it.

  1. In mygpiozero, edit mixins.py
    Comment out the following lines (put a # at the beginning):
    a. in the HoldMixin class definiton init method, the line:
      self._hold_thread = HoldThread(self) 

b. the entire _fire_activated method
c. the entire _fire_deactivated method
d. the entire _fire_held method

Then, reboot. If you’ve done it right, you should get no errors other than a warning that you are using a customized version of remote_rpi_gpio.

1 Like