Ok, so I made a start on this, but actually can’t get it fully working. Feeling a bit stupid to be honest.
Assuming the best bet is to move to docker, my hope was to create some instructions for how someone could migrate from venv to docker. I wanted to copy my old HA config from the venv method into new docker, so I did the following:
$ sudo systemctl stop [email protected]
$ sudo systemctl disable [email protected]
$ sudo apt-get install docker.io docker-compose
$ cp -r .homeassistant .homeassistant_docker
$ mkdir dockercfg
$ cd dockercfg
$ nano docker-compose.yml
Type in this:
$ docker-compose up -d
HA runs and I can connect to the web url from another machine on port 8123 but my ZHA and some other devices aren’t working. My old method of viewing HA output doesn’t work any more but I found I can do
docker logs -f --tail 20 home-assistant
to see what HA is doing. When I do I get:
2020-12-16 23:08:44 ERROR (MainThread) [zigpy.application] Couldn't start application
2020-12-16 23:08:44 ERROR (MainThread) [homeassistant.components.zha.core.gateway] Couldn't start ZNP = Texas Instruments Z-Stack ZNP protocol: CC253x, CC26x2, CC13x2 coordinator
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/serial/serialposix.py", line 265, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
PermissionError: [Errno 1] Operation not permitted: '/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0'
I see that the serial device exists within the docker container:
$ docker exec -it home-assistant /bin/bash
bash-5.0# ls -la /dev/tty*
crw-rw-rw- 1 root root 5, 0 Dec 16 23:30 /dev/tty
crw-rw---- 1 root dialout 188, 0 Dec 16 22:36 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Dec 16 22:36 /dev/ttyUSB1
bash-5.0# ls -la /dev/serial/by-id/*
crw-rw---- 1 root dialout 188, 1 Dec 16 22:36 /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
But it’s readwrite by ‘dialout’ and ‘root’.
What user is HA running as within my docker container? It seems to be root. So maybe the permissions issue is with the user running docker. But that’s also root. So why can’t they access the USB port?
So yeah, I’m stuck now because that’s a bit beyond my docker knowledge so far.
For the record, I think this is already well beyond what non-technical users would have patience for.
What’s kind of good is that I can do
$ docker-compose stop
$ systemctl start [email protected]
To go back to my old method of running HA. So at least I’ve not burned any bridges/WAF points.
But can anyone help me?