Mapping z-wave dongle to Docker Homeassistant

Hi all

I have Home Assistant running in a docker container via docker-compose on my NUC 7i5. I am having some issues mapping my Aeotec z-wave dongle to be accessible by my Home assistant instance.

I have used the following docker-compose (following the guide from https://www.smarthomebeginner.com/docker-home-media-server-2018-basic/)

  homeassistant:
    container_name: homeassistant
    restart: always
    image: homeassistant/home-assistant
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
      - /dev/ttyUSB1:/dev/ttyUSB1
      - /dev/ttyACM0:/dev/ttyACM0
    volumes:
      - ${USERDIR}/docker/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - ${USERDIR}/docker/shared:/shared
    ports:
      - "8123:8123"
    privileged: true
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}

where the PUID is the user ID of my Ubuntu log in, and the PGID is the docker group
I have run

$ ls -ltr /dev/tty*|tail -n 1

and determined that my Aeotec Dongle is plugged into
/dev/ttyACM0

which is one of the devices specified in the docker compose file.

my configuration file for home assistant has the following for the z-wave component

zwave:
  usb_path: /dev/ttyACM0

When I check my configuration - it all checks out, and when I reload home assistant I get

INVALID CONFIG

The following components and platforms could not be set up:
zwave

Please check your config.

When I look at my Home assistant logs, I get the following

Error during setup of component zwave
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/openzwave/option.py", line 78, in __init__
    raise ZWaveException(u"Can't find device %s : %s" % (device, traceback.format_exception(*sys.exc_info())))
openzwave.object.ZWaveException: "Zwave Generic Exception : Can't find device /dev/ttyACM0 : ['NoneType: None\\n']"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 145, in _async_setup_component
    hass, processed_config)
  File "/usr/src/app/homeassistant/components/zwave/__init__.py", line 244, in async_setup
    config_path=config[DOMAIN].get(CONF_CONFIG_PATH))
  File "/usr/local/lib/python3.6/site-packages/openzwave/option.py", line 81, in __init__
    raise ZWaveException(u"Error when retrieving device %s : %s" % (device, traceback.format_exception(*sys.exc_info())))
openzwave.object.ZWaveException: 'Zwave Generic Exception : Error when retrieving device /dev/ttyACM0 : [\'Traceback (most recent call last):\\n\', \'  File "/usr/local/lib/python3.6/site-packages/openzwave/option.py", line 78, in __init__\\n    raise ZWaveException(u"Can\\\'t find device %s : %s" % (device, traceback.format_exception(*sys.exc_info())))\\n\', \'openzwave.object.ZWaveException: "Zwave Generic Exception : Can\\\'t find device /dev/ttyACM0 : [\\\'NoneType: None\\\\\\\\n\\\']"\\n\']'

It looks like it can’t find the device despite being pointed in the right direction

I have run
sudo usermod -a -G dialout homeassistant

My installation is on a brand new Ubuntu 18.04 LTS running on the NUC. It only has the one user, which I used in the place of “homeassistant”.

As I mentioned I followed the guide https://www.smarthomebeginner.com/docker-home-media-server-2018-basic/. I have noticed that to edit the files which is saved in the /~/Home/docker/homeassistant folder I need to log in as root - is this the problem?
I must admit I am relatively new to Linux, and the main issue I have been experience relate to user permissions.

Any suggestions on where I am going wrong?

I added

network_mode: host

to my docker-compose file, and it started detecting my z-wave dongle!!!

hopefully the address doesn’t change with restarts :slight_smile:

I am running Debian 9 on a NUC with HA running in docker.

I solved the issue with changing USB addresses by setting a udev rule.

in etc/udev/rules.d/99-com.rules add the following line to the end:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="ttyUSB-ZStick-5G"

then in your docker run command use:

--device /dev/ttyUSB-ZStick-5G:/dev/ttyUSB-ZStick-5G

or docker-compose:

devices:
  - /dev/ttyUSB-ZStick-5G:/dev/ttyUSB-ZStick-5G

Then in configuration use:

zwave:
  usb_path: /dev/ttyUSB-ZStick-5G

I’m not completely sure but I think the network mode is only used for exposing your hosts ports to the container, not USB devices so I don’t think changing that fixed your USB issue. But I may be wrong…

2 Likes