How do I start docker container after zwave USB is loaded?

I’ve got a USB ZWave stick and openhab running in docker container. On system restart, the container is launched before the USB stick is recognized/mounted/etc. Thus, openhab can’t talk to any of my zwave devices. I have to simply restart the container and all is good. How can I tell the docker container to wait until the USB device is ready before starting the container?

The only thing I can think of is to modify the docker daemon system file so it depends on something that starts late enough that the hardware will be available. Maybe networking.

I found out that you can have USB devices create systemd .device files. You just need to TAG it like so:

# cat /etc/udev/rules.d/aeotech.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="zwave", OWNER="openhab", TAG+="systemd"

# udevadm trigger && udevadm control --reload-rules

# systemctl list-units --all --full | grep -i zwave
  dev-zwave.device                      loaded    active   plugged   Aeotec Z-Stick Gen5 (ZW090) - UZB

From here, you can use this reference in Requires= or After= in other unit files

1 Like

@utdrmac, quick question: I’ve invested hours and hours in the past few days into finding a solution for why my Aeotec Z-Wave Gen5+ Stick only working after “immediate re-deploy of the openHAB container”, but not anymore after “container or Raspi restart” (see here).

Was the problem you had similar? If yes I’d try to understand your solution and try it out myself.

Hello @Cplant,
I’m not sure if the issues were similar. The power went out here one day and when my server rebooted, I noticed none of the zwave stuff worked. Checking the OH UI, it said stick was offline. I simply restarted the docker container and it all worked again. This lead me to the suspicion that the OH container was launching before the USB stick was detected/loaded/mounted. After adding the above udev rules, a test reboot shows that the container now loads after the stick and everything worked right away.