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.
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.
In config, make the custom_components directory if it doesn’t already exist, and under there, create the directory remote_rpi_gpio
Copy all the files in the remote_rpi_gpio implementation from here
, and copy them to the remote_rpi_gpio dir
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
Copy the gpiozero directory with its files from here
to the current dir and rename it, so that you have: