I’m using a Rapsberry Pi 3b+ with a 32-bit kernel, and trying to use GPIO pins as input. Unfortunately, it isn’t working. I’ve seen several threads on here but they were old, unresolved, and/or weren’t caused by the same thing as my problem. Here’s what my configuration looks like (or at least one version, I’ve tried a lot of things to make this work, since some people reported switching pins fixed the problem):
switch:
- platform: rpi_gpio
ports:
5: Relay1
6: Relay2
13: Relay3
16: Relay4
19: Relay5
20: Relay6
21: Relay7
26: Relay8
invert_logic: true
binary_sensor:
- platform: rpi_gpio
ports:
11: Input1
12: Input2
Note that the outputs work fine. Moreover, I’ve tried a bunch of different GPIO numbers, and none of them work for inputs, while all of the ones I’ve tried work as outputs.
What also works is the command gpio readall
from the wiringpi package, run as the same user as hass. This strongly suggests it is not a permission issue. I can also see that the pins I’m trying are configured for input.
Here’s where things seem to go wrong in the log:
2019-08-25 17:14:20 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up platform rpi_gpio
Traceback (most recent call last):
File "/home/hass/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 149, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/hass/local/lib/python3.7/site-packages/homeassistant/components/rpi_gpio/binary_sensor.py", line 45, in setup_platform
port_name, port_num, pull_mode, bouncetime, invert_logic
File "/home/hass/local/lib/python3.7/site-packages/homeassistant/components/rpi_gpio/binary_sensor.py", line 70, in __init__
rpi_gpio.edge_detect(self._port, read_gpio, self._bouncetime)
File "/home/hass/local/lib/python3.7/site-packages/homeassistant/components/rpi_gpio/__init__.py", line 60, in edge_detect
GPIO.add_event_detect(port, GPIO.BOTH, callback=event_callback, bouncetime=bounce)
RuntimeError: Failed to add edge detection
I’m unfortunately stuck here, so would really appreciate suggestions on how to fix this or what other experiments might shed light on the problem. Thanks.