home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.42k stars 30.66k forks source link

Error while setting up platform remote_rpi_gpio #27724

Closed ashtonsmith closed 3 years ago

ashtonsmith commented 5 years ago

Home Assistant V 0.100.2 hass.io installation

Description of problem: After updating (didn't think to take a snapshot) remote_rpi_gpio can not set up

Problem-relevant configuration.yaml:

binary_sensor:
  - platform: remote_rpi_gpio
    host: 192.168.1.84
    ports:
      27: Single Garage
      13: Double Garage
      04: Media Room
      21: Entranceway
      22: Kitchen
      23: Loungeroom
      12: Laundry
      20: Sensor 20
      19: Sensor 19
    invert_logic: true

Logfile output:

Error while setting up platform remote_rpi_gpio
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/binary_sensor.py", line 52, in setup_platform
    address, port_num, pull_mode, bouncetime
  File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/__init__.py", line 48, in setup_input
    pin_factory=PiGPIOFactory(address),
  File "/usr/local/lib/python3.7/site-packages/gpiozero/devices.py", line 124, in __call__
    self = super(GPIOMeta, cls).__call__(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/input_devices.py", line 432, in __init__
    bounce_time=bounce_time, pin_factory=pin_factory)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/mixins.py", line 383, in __init__
    super(HoldMixin, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/input_devices.py", line 188, in __init__
    self._fire_events(self.pin_factory.ticks(), self.is_active)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/mixins.py", line 368, in _fire_events
    self._fire_activated()
  File "/usr/local/lib/python3.7/site-packages/gpiozero/mixins.py", line 398, in _fire_activated
    self._hold_thread.holding.set()
AttributeError: 'NoneType' object has no attribute 'holding'

I have tried setting environment variables, however this is not helping, and the error does not specifically state that it could not set the pinfactory (like it used to)

Thanks

pergolafabio commented 5 years ago

i have the same error

restarting hassio helps, then error is gone, restarting again, error is back, so its random ...

2019-10-16 20:02:45 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up platform remote_rpi_gpio
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/binary_sensor.py", line 52, in setup_platform
    address, port_num, pull_mode, bouncetime
  File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/__init__.py", line 48, in setup_input
    pin_factory=PiGPIOFactory(address),
  File "/usr/local/lib/python3.7/site-packages/gpiozero/devices.py", line 124, in __call__
    self = super(GPIOMeta, cls).__call__(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/input_devices.py", line 432, in __init__
    bounce_time=bounce_time, pin_factory=pin_factory)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/mixins.py", line 383, in __init__
    super(HoldMixin, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/input_devices.py", line 188, in __init__
    self._fire_events(self.pin_factory.ticks(), self.is_active)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/mixins.py", line 368, in _fire_events
    self._fire_activated()
  File "/usr/local/lib/python3.7/site-packages/gpiozero/mixins.py", line 398, in _fire_activated
    self._hold_thread.holding.set()
AttributeError: 'NoneType' object has no attribute 'holding'
pergolafabio commented 5 years ago

i reverted to 1.5.0 dependency , loaded it as a custom, but its the same running the old 1.4.1 dependency gives back to badpinfactory error offcourse

pergolafabio commented 5 years ago

hi @jgriff2 , are you codeowner? can you have a look at this issue? its very annoying, i have to restart hassio untill it works

thnx a lot!

ashtonsmith commented 5 years ago

@pergolafabio in the meantime, if you load as custom, set the dependency to 1.4.1 , then log into your homeassistant container and add the below lines to /bin/entry.sh:

export GPIOZERO_PIN_FACTORY=pigpio export PIGPIO_ADDR=YOUR_RPi_IP_ADDRESS

then restart home assistant twice, you should be good

pergolafabio commented 5 years ago

Is it failing because of the depency? Is there no easier fix then this for the badpinfactory? Because for that workaround , you need to do it on each hassio update?

pergolafabio commented 5 years ago

hi @ashtonsmith

i see several temp solutions, whats the difference with yours? in total there are 3 temp solutions, not sure whats the best :) in first one below, they add a port also, like 8888 , you do not?

from github issue : https://github.com/home-assistant/home-assistant/issues/25944

I was able to fix the problem temporarily using Kdemontf's fix on HassOS by installing the community's SSH & Web Terminal addon. I then turned off the terminal add-on's Protected Mode in order to gain Docker access, and went to the terminal to find/edit my Home Assistant Docker container:

docker container ls showed my list of Docker containers. I then found the container ID for Home Assistant, by looking for the container using the image qemux86-64-homeassistant.
I entered the container using docker exec -it <container id> bash.
I edited the /bin/entry.sh script, adding the line export GPIOZERO_PIN_FACTORY="mock" PIGPIO_ADDR="<rpi-ip-addr>:8888" after the set -e line.
I saved the file, and used CTRL-D to get back to the HassOS Supervisor container.
I committed my Docker container changes using docker commit <container id> homeassistant/qemux86-64-homeassistant.
I restarted Home Assistant.
This will of course break anytime Home Assistant gets updated. Hopefully the fix can be applied soon!

from community forums : https://community.home-assistant.io/t/remote-raspberry-pi-gpio/120306/45

#!/bin/bash
set -e

# add the line below
export GPIOZERO_PIN_FACTORY=mock

udevd --daemon
udevadm trigger

if CMD="$(command -v "$1")"; then
  shift
  exec "$CMD" "$@"
else
  echo "Command not found: $1"
  exit 1
fi
damocles-git commented 4 years ago

It seems a problem related with HA, I have a raspberry pi zero w with the pigpiod daemon running and enabled for remote access, HA is running in an intel nuc.

Testing remote gpio access from the command line with the pinout tool, first it try to connecto to localhost:8888 and fails because environment variables are not configured:

(homeassistant) hass@nuc ~ $ hass --version
0.101.3
(homeassistant) hass@nuc ~ $ pip3 show  gpiozero | grep -i version
Version: 1.5.1
(homeassistant) hass@nuc ~ $ pip3 show -f gpiozero | grep pinout
  ../../../bin/pinout
  gpiozerocli/__pycache__/pinout.cpython-36.pyc
  gpiozerocli/pinout.py
(homeassistant) hass@nuc ~ $ 
(homeassistant) hass@nuc ~ $ pinout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at localhost(8888)

Did you start the pigpio daemon? E.g. sudo pigpiod

Did you specify the correct Pi host/port in the environment
variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888

Did you specify the correct Pi host/port in the
pigpio.pi() function? E.g. pigpio.pi('soft', 8888)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Unable to initialize GPIO Zero. This usually means that you are not running
pinout on a Raspberry Pi. If you still wish to run pinout, set the
GPIOZERO_PIN_FACTORY environment variable to 'mock' and retry, or refer to the
Remote GPIO section of the manual* to configure your environment to remotely
access your Pi.

* https://gpiozero.readthedocs.io/en/stable/remote_gpio.html

For further information, please refer to https://pinout.xyz/
(homeassistant) hass@nuc ~ $ 

now I set the environment variables:

(homeassistant) hass@nuc ~ $ export PIGPIO_ADDR=10.20.30.13 GPIOZERO_PIN_FACTORY=pigpio
(homeassistant) hass@nuc ~ $ pinout
.-------------------------.
| oooooooooooooooooooo J8 |
| 1ooooooooooooooooooo   |c
---+       +---+ PiZero W|s
 sd|       |SoC|   V1.1  |i
---+|hdmi| +---+  usb pwr |
`---|    |--------| |-| |-'

Revision           : 9000c1
SoC                : BCM2835
RAM                : 512Mb
Storage            : MicroSD
USB ports          : 1 (excluding power)
Ethernet ports     : 0
Wi-fi              : True
Bluetooth          : True
Camera ports (CSI) : 1
Display ports (DSI): 0

J8:
   3V3  (1) (2)  5V    
 GPIO2  (3) (4)  5V    
 GPIO3  (5) (6)  GND   
 GPIO4  (7) (8)  GPIO14
   GND  (9) (10) GPIO15
GPIO17 (11) (12) GPIO18
GPIO27 (13) (14) GND   
GPIO22 (15) (16) GPIO23
   3V3 (17) (18) GPIO24
GPIO10 (19) (20) GND   
 GPIO9 (21) (22) GPIO25
GPIO11 (23) (24) GPIO8 
   GND (25) (26) GPIO7 
 GPIO0 (27) (28) GPIO1 
 GPIO5 (29) (30) GND   
 GPIO6 (31) (32) GPIO12
GPIO13 (33) (34) GND   
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
   GND (39) (40) GPIO21

For further information, please refer to https://pinout.xyz/

even reading my remote i2c TSL2561 sensor works:

(homeassistant) hass@nuc ~ $ pigs i2co 1 0x39 0   i2cwd 0 0x80 0x03   i2cwd 0 0x81 0x02   mils 500   i2crd 0 0x8C   i2cc 0
0
140 2 0 0 0 0 0 0 128 1 80 4 9 0 5 0 51 2 0 0 0 0 0 0 128 1 80 4 9 0 5 0 51 2 0 0 0 0 0 0 128 1 80 4 9 0 5 0 51 2 0 0 0 0 0 0 128 1 80 4 9 0 5 0 51 2 0 0 0 0 0 0 128 1 80 4 9 0 5 0 51 2 0 0 0 0 0 0 128 1 80 4 9 0 5 0 51 2 0 0 0 0 0 0 128 1 80 4 9 0 5 0 51 2 0 0 0 0 0 0 128 1 80 4 9 0 5 0 51 2 0 0 0 0 0 0 128 1 80 4 9

now I start HA in the current shell with the same environment variables:

(homeassistant) hass@nuc ~ $ echo $PIGPIO_ADDR $GPIOZERO_PIN_FACTORY
10.20.30.13 pigpio
(homeassistant) hass@nuc ~ $ hass -v
Config directory: /home/users/hass/.homeassistant
2019-11-14 15:38:51 INFO (SyncWorker_1) [homeassistant.loader] Loaded script from homeassistant.components.script
2019-11-14 15:38:51 INFO (SyncWorker_4) [homeassistant.loader] Loaded light from homeassistant.components.light
2019-11-14 15:38:51 INFO (SyncWorker_3) [homeassistant.loader] Loaded influxdb from homeassistant.components.influxdb
[...]
2019-11-14 15:39:07 INFO (MainThread) [homeassistant.setup] Setting up remote_rpi_gpio
2019-11-14 15:39:07 INFO (MainThread) [homeassistant.setup] Setup of domain media_player took 3.6 seconds.
2019-11-14 15:39:07 INFO (MainThread) [homeassistant.setup] Setup of domain remote_rpi_gpio took 0.1 seconds.
2019-11-14 15:39:07 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.remote_rpi_gpio
2019-11-14 15:39:07 INFO (MainThread) [homeassistant.setup] Setup of domain group took 11.9 seconds.
2019-11-14 15:39:07 INFO (SyncWorker_4) [homeassistant.loader] Loaded nmap_tracker from homeassistant.components.nmap_tracker
2019-11-14 15:39:07 INFO (MainThread) [homeassistant.setup] Setting up script
2019-11-14 15:39:09 INFO (MainThread) [homeassistant.setup] Setting up automation
2019-11-14 15:39:09 INFO (MainThread) [homeassistant.setup] Setup of domain script took 1.7 seconds.
2019-11-14 15:39:10 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up platform remote_rpi_gpio
Traceback (most recent call last):
  File "/home/users/hass/homeassistant/lib64/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/lib64/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/users/hass/homeassistant/lib64/python3.6/site-packages/homeassistant/components/remote_rpi_gpio/binary_sensor.py", line 52, in setup_platform
    address, port_num, pull_mode, bouncetime
  File "/home/users/hass/homeassistant/lib64/python3.6/site-packages/homeassistant/components/remote_rpi_gpio/__init__.py", line 48, in setup_input
    pin_factory=PiGPIOFactory(address),
  File "/home/users/hass/homeassistant/lib64/python3.6/site-packages/gpiozero/devices.py", line 124, in __call__
    self = super(GPIOMeta, cls).__call__(*args, **kwargs)
  File "/home/users/hass/homeassistant/lib64/python3.6/site-packages/gpiozero/input_devices.py", line 432, in __init__
    bounce_time=bounce_time, pin_factory=pin_factory)
  File "/home/users/hass/homeassistant/lib64/python3.6/site-packages/gpiozero/mixins.py", line 383, in __init__
    super(HoldMixin, self).__init__(*args, **kwargs)
  File "/home/users/hass/homeassistant/lib64/python3.6/site-packages/gpiozero/input_devices.py", line 188, in __init__
    self._fire_events(self.pin_factory.ticks(), self.is_active)
  File "/home/users/hass/homeassistant/lib64/python3.6/site-packages/gpiozero/mixins.py", line 368, in _fire_events
    self._fire_activated()
  File "/home/users/hass/homeassistant/lib64/python3.6/site-packages/gpiozero/mixins.py", line 398, in _fire_activated
    self._hold_thread.holding.set()
AttributeError: 'NoneType' object has no attribute 'holding'
2019-11-14 15:39:10 INFO (MainThread) [homeassistant.setup] Setting up device_tracker

so it seems that HA is having a problem with the remote gpio component.

GigiGat commented 4 years ago

I have the same error! hassio version: 0.102.3

dupondje commented 4 years ago

Had this here also. Guess the plugin needs some love :)

scsi050 commented 4 years ago

I get this error too, running hassio 0.103.5. No permenant fix at this point?

Sun Jan 26 2020 14:07:44 GMT-0600 (Central Standard Time)
Error while setting up platform remote_rpi_gpio
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/binary_sensor.py", line 50, in setup_platform
    address, port_num, pull_mode, bouncetime
  File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/__init__.py", line 47, in setup_input
    pin_factory=PiGPIOFactory(address),
  File "/usr/local/lib/python3.7/site-packages/gpiozero/devices.py", line 124, in __call__
    self = super(GPIOMeta, cls).__call__(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/input_devices.py", line 432, in __init__
    bounce_time=bounce_time, pin_factory=pin_factory)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/mixins.py", line 383, in __init__
    super(HoldMixin, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/input_devices.py", line 188, in __init__
    self._fire_events(self.pin_factory.ticks(), self.is_active)
  File "/usr/local/lib/python3.7/site-packages/gpiozero/mixins.py", line 368, in _fire_events
    self._fire_activated()
  File "/usr/local/lib/python3.7/site-packages/gpiozero/mixins.py", line 398, in _fire_activated
    self._hold_thread.holding.set()
AttributeError: 'NoneType' object has no attribute 'holding'
andystewart999 commented 4 years ago

Yep - I'm getting this as well. It seems to be totally random... :-(

andystewart999 commented 4 years ago

@balloob and @frenck - still an issue on 0.105.2, although not surprising as I didn't see anything relating to GPIO (remote or otherwise) in the change logs.

For my specific use case I'm trying to get a garage door relay to change and for the door to report its status - both super easy with GPIO as in fact you mention here. I was hoping that the addin being developed by @sp1k3ster that was ultimately rejected would solve my issues (as the remote part is easy to set up) but no joy.

I'm happy to try a master/slave HA scenario, also as referenced as being super easy by you @balloob but that seems like overkill to just integrate with GPIO... but I'll give it a whirl. I've done some Googling but apart from the MQTT EventStream stating it's to connect two HA instances together I haven't been able to find anything concrete re seeing pin changes and sending relay commands... is there any documentation?

Optimally remote_rpi_gpio will be fixed as that's by far the cleanest way of managing this specific garage door use case.

Thanks for your continued dev work on Home Assistant - I'm looking forward to working with it a lot over the upcoming months.

ChrisB85 commented 4 years ago

Same problem here. I'm trying to integrate PIR sensor from my RPI-based smart mirror.

andystewart999 commented 4 years ago

@pergolafabio in the meantime, if you load as custom, set the dependency to 1.4.1 , then log into your homeassistant container and add the below lines to /bin/entry.sh:

export GPIOZERO_PIN_FACTORY=pigpio export PIGPIO_ADDR=YOUR_RPi_IP_ADDRESS

then restart home assistant twice, you should be good

Revisiting this fix, which I've been using for a while, when upgrading to 0.107.x it looks like /bin/entry.sh has moved and I can't find it. Looking at the container data (I'm no expert) it looks like Init is just being called without any parameters.

I foolishly modified init directly and it bricked my installation, I had to revert to a snapshot.

For 0.107.x, which file should be modified to add those export lines?

andystewart999 commented 4 years ago

So we're now on 0.110.3, and I've been using the same custom integration of RemoteGPIO since February. Now I'm starting to get deprecation issues regarding SwitchDevice and BinarySensorDevice so I'm getting worried about the older custom integration dying on me.

So I went totally native, ie no I removed the old remote GPIO integration and the 'None' error described above has come back. Also the current version of the RemoteGPIO addin is still using SwitchDevice, I expect that will get fixed up soon enough.

So I'm going to use the current version of RemoteGPIO, extract it back as a custom integration, change the manifest back to 1.4.1 and hope for the best - both now and in the long term as I'm really relying on RemoteGPIO for a few activities (garage door and aircon)

Cheers, Andy

frankiej911 commented 4 years ago

I have the same issue since the beginning of this year. I use my remote gpio to read the watermeter with a proximity sensor.

In the past some reboots of Hass fixes the problem and it was stable all the time (if I didn't restart Hass again). But since the last update and after many restarts the component won't start anymore...

andystewart999 commented 4 years ago

Hi all, I've taken some steps to get this working for me and I've had good success so far.

I've created a brand new gpiozero package on PyPi, with only two differences to the original:

I've renamed it of course so it can be referenced in the manifest. So what I periodically do is grab the four files related to the remote_gpio integration from the home assistant core folder, save them in custom_components and then adjust the manifest to suit. That's far easier than my old fix of going into the container, making adjustments to gpiozero and then committing those changes.

Here's the manifest that works for me, note the new package:

{
  "domain": "remote_rpi_gpio",
  "name": "remote_rpi_gpio",
  "documentation": "https://www.home-assistant.io/integrations/remote_rpi_gpio",
  "requirements": ["gpiozero-ha==1.5.3"],
  "codeowners": []
}

Regarding the IP hardcoding, I've noticed that, intermittently, for some reason the binding didn't work (although that was with an older version of the integration). Check out these two lines, extracts from init.py:

    try:
        return Button(
            port,
            pull_up=pull_gpio_up,
            bounce_time=bouncetime,
            pin_factory=PiGPIOFactory(address),
        )

and

    try:
        return LED(
            port, active_high=not invert_logic, pin_factory=PiGPIOFactory(address)
        )
    except (ValueError, IndexError, KeyError):
        return None

Historically I changed the PiGPIOFactory instantiation by forcing the 'host' parameter rather than it being fed in as the first optional parameter. Looking at the current source code there's no reason why just inferring the first parameter shouldn't always work, but this fix works for me so I'm leaving it alone:

pin_factory=PiGPIOFactory(host=address)

So that's it - it works 100% of the time with the custom package versus less than 10% of the time with the built-in. Not ideal but neither is life so feel free to make use of this hack if you want.

All I need now is a way of restarting the remote_gpio integration without restarting the whole of HA, if I have to reboot one of my misbehaving Raspberry Pis. Any thoughts on that?

Cheers, Andy

svh1985 commented 4 years ago

Same issue, Error while setting up remote_rpi_gpio platform for binary_sensor.

2wenty2wo commented 4 years ago

I had it working last night but I restarted today and been getting the same error since. Running Home Assistant 0.115.3 / HassOS 4.13.

Edit: This is a weird one. Randomly it started working again without me changing anything. I think it's because I restarted? Edit 2: Just updated to Home Assistant 0.115.6 and because of the restart I'm getting the remote_rpi_gpio error again.

scsi050 commented 4 years ago

Still broken in 0.115.6 / HassOS 4.13 / Supervisor v245

Logger: homeassistant.components.binary_sensor Source: components/remote_rpi_gpio/init.py:45 Integration: Binary sensor (documentation, issues) First occurred: September 30, 2020, 4:45:34 PM (1 occurrences) Last logged: September 30, 2020, 4:45:34 PM

Error while setting up remote_rpi_gpio platform for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 193, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, self.kwargs) File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/binary_sensor.py", line 49, in setup_platform button = remote_rpi_gpio.setup_input( File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/init.py", line 45, in setup_input return Button( File "/usr/local/lib/python3.8/site-packages/gpiozero/devices.py", line 124, in call self = super(GPIOMeta, cls).call(*args, *kwargs) File "/usr/local/lib/python3.8/site-packages/gpiozero/input_devices.py", line 430, in init super(Button, self).init( File "/usr/local/lib/python3.8/site-packages/gpiozero/mixins.py", line 383, in init super(HoldMixin, self).init(args, kwargs) File "/usr/local/lib/python3.8/site-packages/gpiozero/input_devices.py", line 188, in init self._fire_events(self.pin_factory.ticks(), self.is_active) File "/usr/local/lib/python3.8/site-packages/gpiozero/mixins.py", line 368, in _fire_events self._fire_activated() File "/usr/local/lib/python3.8/site-packages/gpiozero/mixins.py", line 398, in _fire_activated self._hold_thread.holding.set() AttributeError: 'NoneType' object has no attribute 'holding'

ficklma1 commented 3 years ago

Still broken!

scsi050 commented 3 years ago

HassOS 4.17 / 0.118.4 rpi_gpio started working for me out of the blue on Dec2 2020. Hadn't worked for nearly 12-months since now and I didn't change anything.

slarti42 commented 3 years ago

I tried setting this up on 2020.12.7 and seems to not work. Here's the log entry:

Logger: homeassistant.components.binary_sensor Source: components/remote_rpi_gpio/init.py:41 Integration: Binary sensor (documentation, issues) First occurred: 5:33:35 PM (1 occurrences) Last logged: 5:33:35 PM Error while setting up remote_rpi_gpio platform for binary_sensor

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, self.kwargs) File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/binary_sensor.py", line 45, in setup_platform button = remote_rpi_gpio.setup_input( File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/init.py", line 41, in setup_input return Button( File "/usr/local/lib/python3.8/site-packages/gpiozero/devices.py", line 124, in call self = super(GPIOMeta, cls).call(*args, *kwargs) File "/usr/local/lib/python3.8/site-packages/gpiozero/input_devices.py", line 430, in init super(Button, self).init( File "/usr/local/lib/python3.8/site-packages/gpiozero/mixins.py", line 383, in init super(HoldMixin, self).init(args, kwargs) File "/usr/local/lib/python3.8/site-packages/gpiozero/input_devices.py", line 188, in init self._fire_events(self.pin_factory.ticks(), self.is_active) File "/usr/local/lib/python3.8/site-packages/gpiozero/mixins.py", line 368, in _fire_events self._fire_activated() File "/usr/local/lib/python3.8/site-packages/gpiozero/mixins.py", line 398, in _fire_activated self._hold_thread.holding.set() AttributeError: 'NoneType' object has no attribute 'holding'

slarti42 commented 3 years ago

Ok, this is weird. I had GPIO 16 pulled to ground when I started doing this. I opened the door where this reed switch is and everything started working perfectly after a restart with the door open. It even survives a restart even when the door is closed. Maybe this will give a hint to a dev who understands the code.

EDIT: spoke too soon. It survived one HASS restart. After that, the door has to be open to be able to restart without losing the remote_rpi_gpio.

parautenbach commented 3 years ago

Same issue for me running HA core 2021.1.1.

WMP commented 3 years ago

Bug exists in 2021.1.0 docker

WMP commented 3 years ago

I fix it by using @andystewart999 package, in docker container i do: pip install gpiozero-ha Its important to remember about this command always after upgrade ha.

sampod commented 3 years ago

pip install gpiozero-ha Its important to remember about this command always after upgrade ha.

Thanks. Seems to be working well. Could this be included in official docker image?

comet424 commented 3 years ago

how do you run pip install gpiozero-ha hassio terminal window has no pip option no sudo either how do you fix it with the offical image version as i dont use raspbian.. but need to fix the gpio issues

andystewart999 commented 3 years ago

You just have to amend the manifest file to use gpiozero-ha, then HA will download and install it automatically.

comet424 commented 3 years ago

ok ill google that .. as i dont know how to do any of that .. i just knew burn HA iso using the raspberry pi sd card burner and then your done i still new to HA only a few months so i get confused easily so ill have to google this manifest file

comet424 commented 3 years ago

could you send a link or something.. google didnt have much.. i searched for manifest found manifest file in hacs folrder and a intergration-manifiest file.. but inside hte file didnt help me add gpiozero-ha

can you make it simple to understand for a noobie.. explain it it you were like 5... like a dummies book

andystewart999 commented 3 years ago

Sorry, travelling a lot right now...hope these pics help. Create a new custom component using HA's default Remote GPIO files (copy from Github) and then amend the manifest file.
3D2D98AE-669A-4945-AC8B-A7B11574194A

292B18EA-FB65-4A3C-9C8E-59F78CB5DCF4

comet424 commented 3 years ago

@andystewart999 i do not know how to amend or what not but it didnt work .. what i did was searched the remote_rpi_gpio on github i created a folder in custom components remote_rpi_gpio

i then created the files and copy and pasted the code into each one.. i restarted HA several times but get an error and doesnt work

` You are using a custom integration remote_rpi_gpio which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 12:11:07 AM – loader.py (WARNING) - message first occurred at 12:10:59 AM and shows up 2 times remote_rpi_gpio: Error on device update! 12:11:04 AM – Binary sensor (ERROR) - message first occurred at 12:11:03 AM and shows up 2 times No 'version' key in the manifest file for custom integration 'remote_rpi_gpio'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'remote_rpi_gpio' 12:10:59 AM – loader.py (WARNING)

so i must be doing something wrong? files are located \192.168.0.12\config\custom_components\remote_rpi_gpio

comet424 commented 3 years ago

oh if i click that full load i get these errors didnt include it all if you need it i get it to you 021-03-16 00:10:53 WARNING (MainThread) [homeassistant.loader] You are using a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-03-16 00:10:59 WARNING (MainThread) [homeassistant.loader] You are using a custom integration remote_rpi_gpio which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-03-16 00:10:59 WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'remote_rpi_gpio'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'remote_rpi_gpio' 2021-03-16 00:11:03 ERROR (MainThread) [homeassistant.components.binary_sensor] remote_rpi_gpio: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 465, in async_device_update await task File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/remote_rpi_gpio/binary_sensor.py", line 100, in update self._state = remote_rpi_gpio.read_input(self._button) File "/config/custom_components/remote_rpi_gpio/__init__.py", line 61, in read_input return button.is_pressed AttributeError: 'NoneType' object has no attribute 'is_pressed' 2021-03-16 00:11:04 ERROR (MainThread) [homeassistant.components.binary_sensor] remote_rpi_gpio: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 465, in async_device_update await task File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/remote_rpi_gpio/binary_sensor.py", line 100, in update self._state = remote_rpi_gpio.read_input(self._button) File "/config/custom_components/remote_rpi_gpio/__init__.py", line 61, in read_input return button.is_pressed AttributeError: 'NoneType' object has no attribute 'is_pressed' 2021-03-16 00:11:07 WARNING (MainThread) [homeassistant.loader] You are using a custom integration scheduler which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-03-16 00:11:10 WARNING (MainThread) [homeassistant.components.weather] Setup of weather platform environment_canada is taking over 10 seconds. 2021-03-16 00:11:11 WARNING (MainThread) [homeassistant.setup] Setup of hacs is taking over 10 seconds. 2021-03-16 00:11:11 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/hassio/ingress.py", line 245, in _websocket_forward await ws_to.send_str(msg.data) File "/usr/local/lib/python3.8/site-packages/aiohttp/client_ws.py", line 150, in send_str await self._writer.send(data, binary=False, compress=compress) File "/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 687, in send await self._send_frame(message, WSMsgType.TEXT, compress) File "/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 598, in _send_frame raise ConnectionResetError("Cannot write to closing transport") ConnectionResetError: Cannot write to closing transport

comet424 commented 3 years ago

2021-03-16 08:03:04 ERROR (SyncWorker_2) [homeassistant.loader] Error parsing manifest.json file at /config/custom_components/remote_rpi_gpio/manifest.json: Expecting value: line 7 column 1 (char 6) 2021-03-16 08:03:04 WARNING (MainThread) [homeassistant.loader] You are using a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-03-16 08:03:15 ERROR (MainThread) [homeassistant.components.binary_sensor] remote_rpi_gpio: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 465, in async_device_update await task File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, *self.kwargs) File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/binary_sensor.py", line 100, in update self._state = remote_rpi_gpio.read_input(self._button) File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/init.py", line 61, in read_input return button.is_pressed AttributeError: 'NoneType' object has no attribute 'is_pressed' 2021-03-16 08:03:16 ERROR (MainThread) [homeassistant.components.binary_sensor] remote_rpi_gpio: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 465, in async_device_update await task File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/binary_sensor.py", line 100, in update self._state = remote_rpi_gpio.read_input(self._button) File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/init.py", line 61, in read_input return button.is_pressed AttributeError: 'NoneType' object has no attribute 'is_pressed'

comet424 commented 3 years ago

how come in your 2 photos one points to custom_components/remote_rpi_gpio other points to custom_components/remote_rpi

do i need both?

comet424 commented 3 years ago

@andystewart999 so far 0 luck getting it to work gave up for now and HA community had not answers either as no one replied about it

sampod commented 3 years ago

I just updated to Home Assistant 2021.3.4 and i did not have to manually install pip install gpiozero-ha.

I'm running home assistant in docker. Seems that RPi.GPIO library has been bumped in PR#48106 and this might have solved this issue. Can anyone confirm this?

scsi050 commented 3 years ago

I've been on 2021.3.4 for 6 days and still have the same issue. I have not yet manually installed gpiozero-ha.

sampod commented 3 years ago

Yeah. Sorry. I don't really understand why it works now in my installation. And that pr is not event in current release. So the dev branch still might be worth testing.

comet424 commented 3 years ago

i dont know how to install gpiozero-ha as when i use the Terminal in HA it tells me there is no such command pip
and the like 100 add on icons are gone under supervisor add ons store.. used to have a massive list to choose from not anymore dunno why.. and i use the HACS i forget how i found that..

but i thought maybe trying installing Supervised HA on Raspian OS because the gpio stuff is already installed so HA just used it.. but it didnt work.. i get error.. my current work around as i need HA to access other raspberry Pi GPIO pin to operate a sump pump on a timer .. but so far i working on you run 2nd HA on the remote Pi and then you link the 2 HA so i can control Relay on Remote HA to by pass this broken issue...

but this is the error i get for remote rpi gpio running On Raspibian Supervised.

`Logger: homeassistant.components.binary_sensor Source: components/remote_rpi_gpio/init.py:61 Integration: Binary sensor (documentation, issues) First occurred: 2:11:16 PM (1 occurrences) Last logged: 2:11:16 PM

remote_rpi_gpio: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 465, in async_device_update await task File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/binary_sensor.py", line 100, in update self._state = remote_rpi_gpio.read_input(self._button) File "/usr/src/homeassistant/homeassistant/components/remote_rpi_gpio/init.py", line 61, in read_input return button.is_pressed AttributeError: 'NoneType' object has no attribute 'is_pressed'`

jonathanrobichaud4 commented 3 years ago

I have the same problem as well. Seems to be a problem with the code and there isn't an attribute for the binary sensor? I'm not sure but I will experiment.

philiprusinov commented 3 years ago

I can confirm that with docker 2021.3.4 cover is working without installing custom components. Previously I get the same issues, but found a duplicate state/relay pin ID.

andystewart999 commented 3 years ago

Hi all - so sorry about my late reply, I've been flat out at work.

gpiozero-ha was always supposed to be a short-term workaround until the core HA component was fixed. Sounds like 2021.3.4 sorts out connectivity at last (the issue I always had was related to a missing pin factory, gpiozero-ha just hardcoded the right one for a Pi).

I'll give it a try on my install and let you know what happens. I will say that the problem was intermittent for me, although it was more likely to fail than not - note that according to Github, the remote_rpi_gpio component hasn't been touched for 5 months and the manifest is still referring to gpiozero 1.5.1, which it has for years. Hmm.

Talk soon, Andy

EDIT Well, I've removed the custom component, rebooted and I can still see the remote GPIO-based switch I had set up. And it still works! I'll reboot a few more times to be certain.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Ghannes commented 3 years ago

hi guys any permenant fix planned for this issue?

ficklma1 commented 3 years ago

I’m using remote gpio for my garage controller and when the garage is closed and I reboot home assistant it will always fail to initialize. So I have to remember to have the garage opened if I plan to reboot home assistant. Hopefully this additional information will help the developer(s) to troubleshoot and finally correct this issue.

On Jul 4, 2021, at 8:00 AM, Ghannes @.***> wrote:

 hi guys any permenant fix planned for this issue?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

comet424 commented 3 years ago

@ficklma1 @Ghannes seems no one can fix this sissue... the only work around i did cuz i was frustrated with no support i found Remote Home assistant which has worked great for me

so you install Home Assistant on your remote Pi ... and you link the 2 Home assistants together and you have a Main Home assistant.. that controls the actions on the Remote Home Assistant.. for my use it was a Caller ID Display and Running a water Pump from either a timer. or pressing a physical button..
and doing it this way.. if i have to reboot the Main Home Asssitant as i run it in a VM under Unraid.. it doesnt affect the remote Pi.. i abbonded this remote GPIO i gave up.. so my pump pi with caller ID (caller ID not from the home assistant never got it to work) but i use a RPI 4 2GB version and works great as an alternative...

you can find the remote home assistant thing on there website... hope that helps.. least it was 1 way to get around things other then bashing your head off the wall waiting for a fix

andystewart999 commented 3 years ago

Hi @comet424 - just to be clear, you're referring to Home Assistant's REST API and the ability to call services with that?

I've got a similar scenario re your garage, I'm controlling my aircon that way. The only issue I have is that it's a Gen1 Pi B+, installing HA on it makes it sooooo sloooooow, 20 minute boot times! I could use something like MQTT to send actions that an MQTT server on the remote PI would process and action, but remote_gpio is a perfect solution with the exception that the connection isn't resilient...