How to set up a Z-Wave network for your home automation

If you have been following along, you now have a Hass.io installation setup up and ready to begin creating automations.

As I said in my article about deciding on your home automation setup, you now need to set up the Z-Wave antenna so your various home automation equipment can talk to your Raspberry Pi and the Home Assistant software.

I recommend the Aeotec Z-Stick Gen5, Z-Wave Plus USB (affiliate link), but you theoretically can get any Z-Wave antenna and it will work.

  • Plug this USB device into your Raspberry Pi (and restart just to be safe).
  • Login to the Hass.io configuration using Putty
  • You need to figure out what the USB drive is called on your installation. Run the following command.
ls /dev/ttyACM*
/dev/ttyACM0     <-- this is the most common name, but yours may differ
  • You need to tell Home Assistant that it should expect to see Z-Wave communication on this device.
  • Open the configuration.yaml file using vim
vim configuration.yaml
  • Scroll down to the bottom of the file and enter the following command. Save and close vim (:wq)
zwave: !include zwave.yaml

This command will tell Home Assistant to look enable the Z-Wave component and to look for its configuration in a separate file in the same directory as configuration.yaml called zwave.yaml.

  • Create a new file using vim and enter the name of the Z-Wave USB stick you found before. Save and close vim.
vim zwave.yaml

usb_path: /dev/ttyACM0

Now, you will begin to “test” your configuration before actually running it. It is very easy to mess up the format of the .yaml files and cause Home Assistant to not start.

Luckily, Home Assistant has an easy way to check to see if configuration files are valid.

hass --script check_config -c /config

This tells Home Assistant to scan all of the .yaml files and see if there are any configuration issues that would cause it to not be able to restart and load. In typical Linux philosophy, if it reports no status, everything is good. This is because Linux “pipes” the output from one command to another and “chatty” output messages make it harder to pipe commands together.

You can also do this in the Home Assistant web portal.

  • Navigate to the web portal
  • Click on Configuration
  • Click on General
  • Click on Check Config
  • You will get

If everything is good, you will see a green “Configuration valid” message.

You can either reboot the Docker container or use the GUI. Note, as you add more and more automations, this will slow down (several minutes to reboot). This is why the GUI has options for just reloading pieces of the system.

exit            

whoami <-- make sure you are the "pi" user outside the Docker container
pi

sudo docker restart homeassistant
homeassistant

After Docker reports success (by printing out homeassistant), you will have to wait a few minutes for Home Assistant to finish loading.

  • You need to push you new changes to Github so they are saved. Log back into the Docker container and check the status of the files
sudo docker exec -it homeassistant /bin/bash
  • Check the status of your modified configuration files.
git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   configuration.yaml
        modified:   zwave.yaml

no changes added to commit (use "git add" and/or "git commit -a")
  • Add these files (stage them) to your git changset so you can commit them.
git add *

git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   configuration.yaml
        modified:   zwave.yaml
  • Commit the changes
git commit -m "Added zwave"
  • Push your changes to Github
git push

You are now finally ready to begin adding devices to your home automation!