Setup HomeAssistant with Z-Wave on QNAP Container using Docker

Undefined Programming

Setup HomeAssistant with Z-Wave on QNAP Container using Docker

Lets begin by making the initial Home Assistant installation, find it on QNAP Container Station. Look for homeassistant/home-assistant.

Add a new “TZ” environment to set your TimeZone, check out the List of tz database time zones

Set a static volume for the container to use, I just use QNAP “New Volume” directory. You can make your own volume using “Volume from host”, though I find permissions being a problem on some docker.

Remember to expose the container 8123 port to any host port, can set it as 8123 if you wish.

You should have the basic installation ready at [I.P Address]:[Port].

Enabling Z-Wave USB Adaptor on QNAP
Plug in your Z-Wave USB to your QNAP, I’ve got the AEON AEOEZW090-C Aeotec Z-Stick Gen5.

Telnet or SSH into your QNAP, check out what’s USB is currently available to the system

 ls /dev/tty* 

Install the cdc-acm kernel module

 insmod /usr/local/modules/cdc-acm.ko 

Check list again, you will find the “/dev/ttyACM0”

 ls /dev/tty* 

Let’s recreate the home-assistant docker using the newly found device, QNAP does not allow to connect a device to the docker with the GUI you have to do this by command line. First we need the directory of the config folder, by going into Settings > Advanced Settings > Shared Folder.

Stop the home-assistant-1 docker and remove

You can either use a docker compose or run a command to re-create the docker.


Docker Compose

Go to Create and ‘+ Create Application’, provide a name for this Application and enter this YAML:

version: '3' 
services:
    home-assistant:
        container_name: [NAME]
        volumes:
            - 'config:/config:rw'
        environment:
            - [TIMEZONE]
        devices:
            - [DEVICE LOCATION ON QNAP]:/dev/ttyACM0
        command: --privileged
        image: homeassistant/home-assistant:[VERSION]
        ports:
            - [EXTERNAL PORT]:[INTERNAL PORT: 8123]
volumes:
    config:

For this example use this:

version: '3'
services:
    home-assistant:
        container_name: homeassistant
        volumes:
            - 'config:/config:rw'
        environment:
            - TZ=Europe/London
        devices:
            - /dev/ttyACM0:/dev/ttyACM0
        command: --privileged
        image: homeassistant/home-assistant:2021.1.1
        ports:
            - 8123:8123

volumes:
    config:

Command Line

You will have to redo this every time when there is a homeassistant update.

 docker run --name [NAME] --net=bridge --privileged -itd -v [CONFIG_DIRECTORY]:/config -e TZ=[TIMEZONE] --device [USB] homeassistant/home-assistant:[VERSION] 

For this example use this command

 docker run --name home-assistant --net=bridge --privileged -itd -v /share/CE_CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/homeassistant-config/_data:/config -e TZ=Europe/London --device /dev/ttyACM0 homeassistant/home-assistant:2021.1.1 

You should have your Z-Wave USB available within your docker.

To double check if the USB is available you can access the docker

 docker exec -it [DOCKER_ID] bash 

Check the list if ‘/dev/ttyACM0’ is available

 ls /dev/tty* 

Please note that the installed module setting is lost upon restarting or shutdown on older QNAP firmware, to enable it just run this command. The docker should continue to use the same USB “/dev/ttyACM0” without making the docker again.

 insmod /usr/local/modules/cdc-acm.ko 

3 Responses

  1. peelos says:

    Thank you for this – very helpful. Wondered if you are still able to get this working

    I followed your guide to the letter (ensuring entering the correct paths / names etc) but fail to get the EON AEOEZW090-C Aeotec Z-Stick Gen5 recognized within the docker.

    I ran the command:

    docker run --name home-assistant-zwave --net=bridge --privileged -itd -v /share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/homeassistant-config/_data:/config -e TZ=Europe/Zurich --device /dev/ttyACM0 homeassistant/home-assistant                                                                  
    

    I did have to specify the port mapping in container station again to access the docker and also had to reconfigure the docker setup with integrations.. I now see that the image is set to:

    Image : homeassistant/home-assistant:undefined-data-3

    Any ideas? I will post in the qnap forum aswell if easier

    many thanks –

    • poyu says:

      Ah the command need to specify the version of homeassistant/home-assistant image, such as:

      docker run --name home-assistant-zwave --net=bridge --privileged -itd -v /share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/homeassistant-config/_data:/config -e TZ=Europe/Zurich --device /dev/ttyACM0 homeassistant/home-assistant:2021.1.1
      

      Make sure that QNAP can see ttyACM0, otherwise it won’t connect correctly

    • poyu says:

      I’ve added a Docker Compose example, which you can assign the USB device via the QNAP GUI. There is no longer a need to link the device with command line.

Leave a Reply

Your email address will not be published. Required fields are marked *