Using a RPI for Z Wave - tprelog/iocage-homeassistant GitHub Wiki

Minimal setup for RPI running ozwdaemon

ozwdaemon is used by the OpenZWave (beta) integration for Home Assistant.

Unfortunately, there is currently no easy solution for running ozwdaemon on FreeNAS, but do not despair, there is a relatively simple solution. As I mentioned before, I have moved my Z-Stick, from my FreeNAS, to a RPI 3B+ running Raspbian Buster Lite with Docker to provide. There are already, many guides and videos around the internet to provide details about installing and using both Raspbian and Docker. Based on such guides, I have put together this outline of the minimal steps I used to setup my RPI for running ozwdaemon.

RPI Prepare SDCARD

I used Raspberry Pi Imager to flash raspbian-lite on the sdcard

Enable ssh

# cd /mnt/sdcard/boot
touch ssh

Configure WiFi - optional method 1

# cd /mnt/sdcard/boot
nano wpa_supplicant.conf
  • In this file, add something like the following
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev 
update_config=1
network={
    ssid="YourNetworkSSID"
    psk="Your Network's Passphrase"
    key_mgmt=WPA-PSK
}

RPI First Boot

Connect to the RPI using ssh

  • default password is raspberry
ssh [email protected]

Configure the RPI

sudo raspi-config

8 - Update - optional, this only updates raspi-config

1 - Change password for user pi

2 - Network options

  • N1 - change the hostname
  • N2 - setup wifi - optional method 2

4 - Localisation options

  • I1 - Set Locale
  • I2 - Set Time Zone
  • I4 - WiFi Country - optional, if not using wifi

Install system updates and reboot

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove
sudo reboot

RPI Second Boot

Connect to the RPI using ssh - Did you change the hostname?

ssh [email protected]

Install Docker

wget -O get-docker.sh https://get.docker.com
sh ./get-docker.sh

Add user to the docker group

sudo usermod -aG docker pi

You need to log out, then log back in to apply these user permissions


Run a Docker Command

  • Simple test to be sure your user can run docker
  • You'll see an error if docker needs to be run as root
docker version

That's it! Your RPI should now be ready to starting running docker containers

docker run -it --security-opt seccomp=unconfined --device=/dev/ttyACM0 -v /tmp/ozw/config:/opt/ozw -e MQTT_SERVER="192.168.10.100" -e USB_PATH=/dev/ttyACM0 openzwave/ozwdaemon:latest

Using Docker Compose

If you're comfortable using the command line, it may be preferred to manage your docker containers using Docker Compose.

Install Docker Compose

sudo apt install docker-compose

Create a compose file

See also: Compose File Structure and Examples

nano docker-compose.yml
  • This is an example for ozwdaemon
  • In this file, add something like the following
version: '3'
services:

  ## qt-openzwave (ozwdaemon)
  ozwd:
    container_name: "ozwdaemon"
    image: openzwave/ozwdaemon:latest
    ports:
      - 1983:1983
    restart: unless-stopped
    security_opt:
      - seccomp:unconfined
    volumes:
      - ozwd:/opt/ozw/config
    devices:
      - "/dev/ttyACM0:/dev/ttyACM0"
    environment:
      MQTT_SERVER: "192.168.10.100"
      MQTT_USERNAME: "ozw"
      MQTT_PASSWORD: "SuPeR!sEcret"
      USB_PATH: "/dev/ttyACM0"
      OZW_NETWORK_KEY: "0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,0x11,0x12,0x13,0x14,0x15,0x16"
      #QT_LOGGING_RULES: "*.debug=false;ozw.library.debug=true"

volumes:
  ozwd:

Starting the ozwdaemon service

See also: Docker Compose Getting Started - Step 8

docker-compose up -d

If you started Compose with docker-compose up -d, you can stop your services with:

docker-compose stop

Uninstall Docker Compose

sudo apt purge docker-compose && sudo apt autoremove

Using Portainer

For now, I've decided I'm going to use Portainer to manage my container(s) on the RPI. If nothing else, I like having the convenience of a web-ui, that can be added to Home Assistant Core, by using an iframe panel.

See also: Portainer Deployment Quick Start

Create a volume for Portainer data

docker volume create portainer

Run Portainer

docker run -d -p 9000:9000 -p 8000:8000 --name portainer --restart unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v portainer:/data portainer/portainer

Now from a web browser, you should be able to reach portainer at http://docker_host_address:9000

Create a stack file

Portainer stacks are deployed using the equivalent of docker-compose. Only Compose file version 2 is supported at the moment.

  • This is an example for ozwdaemon
  • In this file, add something like the following
version: '2'
services:

  ## qt-openzwave (ozwdaemon)
  ozwd:
    container_name: "ozwdaemon"
    image: openzwave/ozwdaemon:latest
    ports:
      - 1983:1983
    restart: unless-stopped
    security_opt:
      - seccomp:unconfined
    volumes:
      - ozwd:/opt/ozw/config
    devices:
      - "/dev/ttyACM0:/dev/ttyACM0"
    environment:
      MQTT_SERVER: "192.168.10.100"
      MQTT_USERNAME: "ozw"
      MQTT_PASSWORD: "SuPeR!sEcret"
      USB_PATH: "/dev/ttyACM0"
      OZW_NETWORK_KEY: "0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,0x11,0x12,0x13,0x14,0x15,0x16"
      #QT_LOGGING_RULES: "*.debug=false;ozw.library.debug=true"

volumes:
  ozwd:

Update Portainer

docker pull portainer/portainer:latest
docker stop portainer
docker rm portainer 

# Run Portainer as before
docker run -d -p 9000:9000 -p 8000:8000 --name portainer --restart unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v portainer:/data portainer/portainer