Home assistant not working with IO PI Plus (mcp23017 expander) - Remote I/O error

Hi all

I have troubles getting GPIO extender to work over I2C in Home Assistant. I’m using IO PI Plus that is based on mcp23017, therefore I’m using the configuration below.

switch:
- platform: mcp23017
i2c_address: 0x20
pins:
1: Light1
3: Light3
5: Light5
7: Light7
9: Light9
11: Light11
13: Light13
15: Light15

Environment used:

  • RPI 3 B+
  • IO PI Plus expander
  • HomeAssitant 0.110.70 - installed into venv
  • I2C configured

Scenario:

  • After a fresh start i can found I2C addresses (displayed instantly <1s)

(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: 20 21 – – – – – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – – -

  • I can also successfully run my test python script controlling IO PI Plus with a relay board.

  • after starting ./hass from env it starts. Regular gpios works fine, however I2c pins are not detected and I get an error in the log.

Log Details (ERROR)

> Logger: homeassistant.components.switch
> Source: components/mcp23017/switch.py:42
> Integration: Switch ([documentation](https://www.home-assistant.io/integrations/switch), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+switch%22))
> First occurred: 10:32:47 AM (1 occurrences)
> Last logged: 10:32:47 AM
> 
> Error while setting up mcp23017 platform for switch
> 
> Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 184, in __probe_for_device self.i2c.writeto(self.device_address, b"") File "/usr/local/lib/python3.7/site-packages/busio.py", line 86, in writeto return self._i2c.writeto(address, buffer, stop=stop) File "/usr/local/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 38, in writeto self._i2c_bus.write_bytes(address, buffer[start:end]) File "/usr/local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 308, in write_bytes self._device.write(buf) TimeoutError: [Errno 110] Operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 190, in __probe_for_device self.i2c.readfrom_into(self.device_address, result) File "/usr/local/lib/python3.7/site-packages/busio.py", line 76, in readfrom_into return self._i2c.readfrom_into(address, buffer, stop=stop) File "/usr/local/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 44, in readfrom_into readin = self._i2c_bus.read_bytes(address, end-start) File "/usr/local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 179, in read_bytes return self._device.read(number) TimeoutError: [Errno 110] Operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, 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/mcp23017/switch.py", line 42, in setup_platform mcp = MCP23017(i2c, address=i2c_address) File "/usr/local/lib/python3.7/site-packages/adafruit_mcp230xx/mcp23017.py", line 64, in __init__ super().__init__(i2c, address) File "/usr/local/lib/python3.7/site-packages/adafruit_mcp230xx/mcp230xx.py", line 48, in __init__ self._device = i2c_device.I2CDevice(i2c, address) File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 69, in __init__ self.__probe_for_device() File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 192, in __probe_for_device raise ValueError("No I2C device at address: %x" % self.device_address) ValueError: No I2C device at address: 20

- After that momentI2C interface also gets stuck even when when homeassistant is shutdown (now discovery takes >10s)

homeassistant@raspberrypi:/srv/homeassistant $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: – – – – – – – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – – – – – – – – –
70: – – – – – – – –

  • Also a tutorial that worked before, stops working…
(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ python3 /home/pi/src/tutorial/tutorial2.py

Traceback (most recent call last):
File "/home/pi/src/tutorial/tutorial2.py", line 4, in <module> bus = IOPi(0x20)
File "/srv/homeassistant/lib/python3.7/site-packages/IOPi/IOPi.py", line 110, in __init__ self.__bus.write_byte_data(self.__ioaddress, self.IOCON, self.__conf)
File "/srv/homeassistant/lib/python3.7/site-packages/smbus2/smbus2.py", line 434, in write_byte_data ioctl(self.fd, I2C_SMBUS, msg) OSError: [Errno 121] Remote I/O error
  • Interface recover’s only after reboot.

Help very appreciated on getting hass working with the expander.