In a prior post, we set up Home Assistant on Synology. This time, we will learn how to set up and configure a Zigbee home network for your smart home.

( Photo by Robin Glauser )

In my last article, we discussed what Home Assistant is and how to set it up on a Synology DSM with Docker support. I also explained a sample configuration which automates the motion detection capabilities of a surveillance camera based on detecting the presence/absence of the homeowners. After all, who wants to be recorded by their security camera while running around naked and singing embarrassing songs? Asking for a friend 😎

This is very useful of course, but what I want is to implement advantageous automation that either increase house safety, make things more convenient, help reducing electricity/gas costs and finally, make it easy to see what's going on at home when everyone is away. None of this can happen until the house itself is instrumented with appropriate sensors that can reflect the "state" of the house in digital terms.

Let's see first what are the various options available for achieving that.

Choosing a protocol

Smart Home devices can run and communicate between themselves in a variety of ways - as long as they are configured in a network, and that network is made accessible to our Home Assistant installation. After some research, I figured out that there are a few options available for setting up such network in terms of protocols:

  • Zigbee
  • Z-Wave
  • Standard wi-fi
  • Other (IR/RF)

There are already plenty of other articles describing the differences in details. In the end, I decided to set up a Zigbee network for the following reasons:

  • Zigbee is an open standard, already used by plenty of manufacturers in the smart home sector. Very recently Apple, Amazon, Google and the Zigbee Alliance announced a working group (Connected Home over IP) to ensure comprehensive interoperability of the smart devices they put on the market.
  • Zigbee devices and sensors seem to be cheaper than comparable Z-Wave devices.
  • Zigbee 's mesh network allows for more hops than a Z-Wave network, meaning more flexibility in the layout and positioning of the devices. Generally speaking, unless you are working with a very large home / building, this is somewhat of a minor aspect for consideration.
  • Both Zigbee and Z-Wave are dedicated low-power, mesh network protocols that have been designed for this specific use case. This means that the sensors/devices can be battery operated (meaning no wires) and in a normal scenario the battery (in most cases a small button cell) will usually last one to two years. A standard wi-fi device is not optimised for this scenario and will either require wiring (PoE or just a good old plug/cable) or very frequent battery changes.

One potential disadvantage is that a Zigbee network operates on 2.4GHz which is the same frequency used by standard Wi-Fi solutions. This means that careful planning must be made around the specific channels configured both for your Wi-Fi network, your Zigbee network and even any neighbour's network. See here for some further tips.

Z-Wave operates instead in a frequency between 800 and 900 MHz (depending on your country of residence), therefore such interference aspects are less of an issue.

Lightbulbs
(Photo by Kari Shea )

Choosing Zigbee devices

(Disclosure: as an Amazon Associate I earn from qualifying purchases)

Once settled on the protocol, the next step is to choose the right devices for building your Zigbee sensor network. For starters, you need a gateway: this is the hub that acts as an interface between your sensors / smart devices and your home automation system (in our case Home Assistant).

For my scenario, I had three main requirements:

  1. I wanted to avoid a branded gateway (such as Samsung Smartthings, Xiaomi Aqara Hub, IKEA TRΓ…DFRI etc...). I needed a hub that works with standard Zigbee devices from different vendors. In other words, I don't want to be at the mercy of these vendors who may discontinue these devices at any time. A recent example comes from the US where BestBuy has canned the Insignia smart home devices line, or Google ditching its Work With Nest program. Less recent examples involve expensive Silicon Valley based juicers.
  2. Similarly to above - I wanted all the data collected by the Zigbee network to stay local in my network. What happens in my home must stay in my home 😁
  3. I needed a hub which is well supported by Home Assistant and that can be set up easily on my Synology DS 218+ Disk Station. I also didn't want to go with a home built, DIY solution.

With these requirements in mind, after some research and digging, I settled on the dresden elektronik Conbee II USB stick, which is a universal Zigbee gateway. It runs locally in your network and does not rely on external services or require any subscription. Getting it recognized on the Synology DSM is also fairly easy.

Once the USB device is recognized, you can get the Docker image for deCONZ on your Disk Station (See also on Github for more detailed documentation). deCONZ is dresden elektronik's gateway software and it has a pretty solid integration with Home Assistant, meaning once a device is paired to the Zigbee gateway it will be available very much seamlessly in Home Assistant. I will show later in more detail how to whip up all of these things together.

In terms of sensors and devices, I wanted to try a few to get some experience in setting it all up, as well as verifying each device's capabilities before committing to a more significant installation. These are the ones I tried so far:

I picked the Xiaomi devices as they are relatively inexpensive and are listed as supported on the deCONZ wiki page. The Innr bulb was not explicitly listed but I figured out to try and see, and it was recognized and paired immediately.

Installing Conbee II on Synology

Assuming you have a Conbee II, here is how I set it up with deCONZ.

1) Load the appropriate kernel modules in Synology (you will need to SSH in your Disk Station for this). These will allow you Conbee II stick to be recognized as a USB Serial Device.

sudo insmod /lib/modules/usbserial.ko
sudo insmod /lib/modules/ftdi_sio.ko

2) Plug in the Conbee II stick. It is recommended that you use a USB extension to avoid interference which may reduce the performance of the antenna in the stick. In my case, the stick was bound to /dev/ttyACM0 Β (a fact which I found out by looking in the dmesg command output) - note it down, as you'll need it later to set up the deCONZ image.

3) Add a startup script

πŸ‘©πŸ»β€πŸ’» Update 12 February 2020 πŸ‘¨πŸ»β€πŸ’»

Step (3) is no longer required. The Conbee II stick gets recognised just fine after a reboot and without the startup script.

I will leave the instructions here anyway just in case

to ensure that the modules load after a reboot for the Conbee II to be recognized in the future. Thanks to this forum user for the below suggestions:

touch /usr/local/etc/rc.d/startup.sh
chmod 700 /usr/local/etc/rc.d/startup.sh
sudo vi /usr/local/etc/rc.d/startup.sh

Then include the following content in the startup script:

sudo insmod /lib/modules/usbserial.ko
sudo insmod /lib/modules/ftdi_sio.ko
sudo chmod 777 /lib/modules/usbserial.ko
sudo chmod 777 /lib/modules/ftdi_sio.ko
/usr/local/etc/rc.d/startup.sh

4) Open the Disk Station Docker software (refer to my previous article if you haven't installed it yet) and pull the marthoc/deconz image. It will need to be run with high privileges for it to access the USB serial device (as it is not possible to pass a --device parameter to map it directly). Ensure to set the environemnt variables:

  • DECONZ_DEVICE=/dev/ttyACM0 or other device if appropriate depending on your installation. This is the value you noted above in point (2) when you plugged the stick.
  • DECONZ_WEB_PORT=<your_port> change <your_port> with the HTTP port to be used for Phoscon, the web configuration interface for your gatway.
  • DECONZ_VNC_MODE=1 to enable VNC mode which allows you to inspect the Zigbee nework topology in more detail.
  • DECONZ_VNC_PASSWORD to set a VNC password that is different than the default one (highly recommended)

Finally, bind a folder on your Disk Station to the container's /root/.local/share/dresden-elektronik/deCONZ. Then either configure the container to use the host network settings, or map appropriate host ports to the container ports.

5) Run the container and navigate to your Disk Station's IP and above-configured port. You will be directed to the Phoscon app which is used to manage the gateway and prompted to create login credentials. Once set, you will find appropriate controls to start searching for devices to pair. In my case, for pairing the lights it was sufficient to put them in the appropriate sockets and switch on the light, then trigger the light search function in Phoscon until they are found. For the other Xiaomi sensors, pressing the reset button and then running the Phoscon search for sensors.

Girl in front of neon insigna
( Photo by Spencer Imbrock )

Conclusions

To summarise, we learnt how to set up a Zigbee network at home using a vendor-agnostic hub and subsequently pairing a few lights and sensors. These should appear seamlessly in Home Assistant once the Home Assistant deCONZ integration is enabled. This basic set up already allows for a few useful automation rules, for example:

  • Using the motion sensor to switch on the lights automatically when movement is detected in the hallway, but only after sunset or when the ambient light sensor detects a dark condition (such as an overcast winter day).
  • Receiving an alert on Telegram when motion is detected while everyone is out of the home.
  • Receiving an alert on Telegram when the door has been left open and everyone is out of the home.
  • Setting up random light patterns during vacation, to deter thieves or intruders

Thanks for reading! If you enjoyed the article and you haven't already, have a look at the other parts of this series: