Closed DanielBaulig closed 1 year ago
Hey there @dmulcahey, @adminiuga, @puddly, mind taking a look at this issue as it has been labeled with an integration (zha
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
zha documentation zha source (message by IssueLinks)
ZHA can't open the port. There were no changes related to the serial module in zha.
What is the host? Check permission on the serial port and make sure docker instance has access to it. Run a shell inside the container to confirm UID of the ha core can read/write serial port.
Thank you for helping out.
Host is raspbian on a Raspberry Pi 4 Model B.
On host
# ls -lisa /dev/ttyACM0
442 0 crw-rw---- 1 root dialout 166, 0 Dec 4 15:43 /dev/ttyACM0
# docker exec -it home-assistant /bin/bash
bash-5.1# ls -lisa /dev/ttyACM0
442 0 crw-rw---- 1 root dialout 166, 0 Dec 4 15:43 /dev/ttyACM0
bash-5.1# id -u $(whoami)
0
bash-5.1# ls -lisan /dev/ttyACM0
442 0 crw-rw---- 1 0 20 166, 0 Dec 4 15:43 /dev/ttyACM0
HA runs as root in the container:
bash-5.1# ps -a
PID USER TIME COMMAND
1 root 0:00 /package/admin/s6/command/s6-svscan -d4 -- /run/service
12 root 0:00 /bin/bash
33 root 0:00 s6-supervise s6-linux-init-shutdownd
35 root 0:00 /package/admin/s6-linux-init/command/s6-linux-init-shutdownd -c /run/s6/basedir -g 3000 -C -B
42 root 0:00 s6-supervise s6rc-oneshot-runner
43 root 0:00 s6-supervise s6rc-fdholder
51 root 0:00 /package/admin/s6/command/s6-ipcserverd -1 -- /package/admin/s6/command/s6-ipcserver-access -v0 -E -l0 -i data/rules -- /package/admin/s6/command/s6-sudod -t 30000 -- /package/admin/s6-rc/command/s6-rc-oneshot-run -l ../..
79 root 0:00 s6-supervise home-assistant
81 root 3:26 python3 -m homeassistant --config /config
325 root 0:00 ps -a
However, when I try the following I also get a Operation not permitted
error.
bash-5.1# cat /dev/ttyACM0
cat: can't open '/dev/ttyACM0': Operation not permitted
Running the same on the host seems to work though:
# cat /dev/ttyACM0
e^C
Note that I tried chmoddingo+rw
to /dev/ttyACM0
just in case and that didn't change anything either.
Adding
privileged: True
to the home-assistant service in my docker-compose.yaml file seems to resolve the issue. It's not entirely clear to me how this differs from how I invoked it before or why this suddenly became necessary though.
Does downgrading to 2022.11.4 fixes it?
- "/dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2197609-if00:/dev/ttyAMA0
Did this work before? I'm not positive it is going to work, mounted as a volume. This should be a device mapping. Or map devices ttyAMA0 to ttyAMA0 and mount dev serial as a volume.
Does downgrading to 2022.11.4 fixes it?
Haven't tried yet. I'll give it a shot.
- "/dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2197609-if00:/dev/ttyAMA0
Did this work before? I'm not positive it is going to work, mounted as a volume. This should be a device mapping. Or map devices ttyAMA0 to ttyAMA0 and mount dev serial as a volume.
Yes it did. I've been using this compose file for years. But now that you mention it, I'm realizing that I recently changed some lines above that particular line and added some more volume mappings. I remember vaguely that I fumbled in vim and did some accidental edits that I undid. Maybe I didn't cleanly undo them and removed the device:
line that may have separated that particular line from the volumes:
block.
To my own disgrace I do not have the yaml file in source control, so I can no longer reconstruct if that may have been the case or not. But it seems to be making sense.
The above line is a valid device mapping line for a container, but would not work as a volume mapping, because you are trying to open a device file. It would not work unless it is a fully privileged container as you found out.
I'm closing this as this is not a zha issue.
@Adminiuga I (re-?) added the devices:
block and moved the serial device mapping into it and it is working again as expected.
Appreciate you taking the time help me debug this even though it wasn't a ZHA issue. Is there a way for me to buy you a coffee or beer?
I appreciate the offer, but I'm fine. Thank you though 🤝
The problem
I just upgraded to 2022.11.5 and since then ZHA fails to setup correctly. Note, I'm not 100% convinced that this was actually related to the upgrade, but there was a ZHA dependency update in 11.5, so maybe it is.
Logs:
What version of Home Assistant Core has the issue?
2022.11.5
What was the last working version of Home Assistant Core?
2022.11.4
What type of installation are you running?
Home Assistant Container
Integration causing the issue
ZHA
Link to integration documentation on our website
https://www.home-assistant.io/integrations/zha
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
GCFFlasher
binary (not aGCFFlasher_internal
binary) and that binary didn't show any devices when listing withGCFFlasher -l
.