jpcornil-git / HA-mcp23017

MCP23017 implementation for Home Assistant (threadsafe, lower latency and config flow support)
18 stars 6 forks source link

Enable to use MCP23017 #30

Open Charlo26 opened 2 months ago

Charlo26 commented 2 months ago

Hello, i got an waveshare MCP2307 with 0x27 address.

I try to find it on my RPi 4, with Raspbian OS, when I use i2cdetect -y 1, I found it with 0x27 adress.

But, on my HomeAssistant Supervised installation, i'm unable to communicate with it.

i2c is correctly enabled.

when I restart HA i got :

2024-09-04 06:20:45.882 ERROR (SyncWorker_3) [custom_components.mcp23017] Unable to access mcp23017-0x27 ([Errno 110] Operation timed out)

2024-09-04 06:21:39.199 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('mcp23017', '01J6XM6W5MMBZ9YXKGCRQE27PX'): 29834.171859957}

2024-09-04 06:21:44.854 ERROR (MainThread) [homeassistant.components.switch] Setup of platform mcp23017 is taking longer than 60 seconds. Startup will proceed without waiting any longer.

2024-09-04 06:21:44.857 WARNING (MainThread) [custom_components.mcp23017] mcp23017@0x27@0x27 component not found, unable to unload entity (pin 0).

Thank you

jpcornil-git commented 2 months ago

Hi, Could you start a terminal within the homeassistant container and list all i2c devices from there (you may have to run "apk add i2c-tools" first) ?

> i2cdetect -l

I guess that either the container has no access to the host i2C devices or that the device may not be the expected /dev/i2c-1. Cheers, jpc

jpcornil-git commented 2 months ago

Where you able to fix the issue ?

vandijkict commented 2 weeks ago

I have the same problem and get the messsage: Error: Unable to access mcp23017-0x32 ([Errno 2] No such file or directory: '/dev/i2c-1')

pkondela commented 2 weeks ago

hello, try running the container with the i2c parameter ( " --device=/dev/i2c-1 \"). I have it like this without any problems

docker run -d \ --name homeassistant \ --privileged \ --restart unless-stopped \ -e TZ=Europe/Bratislava \ -v /home/pi/docker/home-assistant/config:/config \ -v /run/dbus:/run/dbus:ro \ --device=/dev/ttyUSB0 \ --device=/dev/i2c-1 \ --network host \ homeassistant-extended

jpcornil-git commented 2 weeks ago

Thanks for your comment; in order to expose i2c within a docker container, you should indeed either add it explicitly using a "--device" argument as suggested above or run in "--priviledged" mode (both are not required afaik).

If you are running on a raspberry, make sure to enable the i2c interface first (raspi-config -> Interfacing Options > I2C or by editing the /boot/config.txt directly).

Then check that /dev/i2c-1 is effectively available: