ConBee II USB Gateway on Ubuntu with Home Assistant (Docker)

Over the last few weeks, I have been researching what I can achieve with home automation. After browsing countless web articles and watching hours of various YouTube videos the first decision I made was what wireless protocol I would use for connectivity, I decided on Zigbee. For those who don't know much about IoT and smart devices, most sensors and devices connect wirelessly using either WiFi, Zigbee, or Z-Wave. Each of these protocols has its pros and cons which I won't cover here, but there were a few reasons I choose ZigBee.

1) New Cisco access points are starting to support ZigBee, I don't currently know what this means for me specifically, but I thought it may something to play around with in the future if I hit any range issues.

2) I didn't want to utilise WiFi, I tinker a lot with my network and didn't want any smart home devices relying on WiFi.

3) ZigBee is an open standard, Z-Wave isn't.

To prevent having to own a separate "smart hub" for each smart device I purchased, I opted to centralise everything into an open-source piece of software called Home Assistant (https://www.home-assistant.io/) - it also has a Docker container! There are other benefits of using something like this as opposed to each manufactures own smart hubs. Firstly all your data is stored locally on your own server within your control and secondly with everything is processed locally and not in the cloud. Cloud-based solutions can add a fair amount of latency from what I have seen. A good example of this would be if you wanted to automatically turn on a light when motion is detected. There could be several seconds delay in motion being detected and the light turning on, especially if the smart bulb and motion detectors are by different manufactures using their own independent hubs or cloud solutions

In order to connect my smart devices to Home Assistant, I needed something that could communicate using the ZigBee protocol. After some research, there was one clear winner that everyone recommended which was the ConBee II USB gateway by Dresden Elektronik. The only issue I had with this device was the price, at close to £40 quid it took me a while to bite the bullet. I could have got something for cheaper, but I wanted something reliable, it may well be controlling key parts of my home in the future!

The device can be purchased on Amazon and this is what arrived in the post:

Now I just needed to get this connected to my Docker host and pass it through to the Home Assistant Docker container. I haven't ever tried passing through USB devices in Docker before, but how hard can it be?

First, you have to change your USB access rights by using the below command, I also rebooted my server at this point.

 sudo gpasswd -a $USER dialout

I then connected the USB gateway to my server and I could see the device recognised in Ubuntu, a good start...

[email protected]:/home/jack# lsusb | grep Dresden
Bus 005 Device 002: ID 1cf1:0030 Dresden Elektronik

To interface with the USB gateway, I spun up a Docker container running deCONZ using the below Docker-Compose snippet. You can think of this as the middle man between the USB gateway and Home Assistant.

  deconz:
    container_name: deconz
    image: marthoc/deconz
    restart: always
    devices:
      - /dev/ttyACM0
    environment:
      - DECONZ_DEVICE=/dev/ttyACM0
      - DECONZ_VNC_MODE=1
    network_mode: host
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /mnt/NAS/Docker/deconz_config:/root/.local/share/dresden-elektronik/deCONZ

Once the container was running, I navigated to 'Configuration' -> 'Integrations'vwithin Home Assistant where I could see the ZigBee gateway automatically discovered.

Upon clicking 'CONFIGURE' I was shown the following and had to scratch my head for a few minutes and do some Googling before figuring out what I had to do next.

It turns out the Deconz container runs 'Phoscon App' on port 80 by default. I navigated to this, where it showed my gateway as seen in the below screenshot. If you already have a container using port 80, you can change the Phoscon port by using the environmental variable 'DECONZ_WEB_PORT=8080' within docker-compose.

Once selecting your Gateway you will be prompted to set a new name and password. Once set you will be asked to connect some lights, I don't have any lights so chose the 'Proceed without lights' option on the top right of the page.

Once on the below page, choose the menu button on the top left, 'Settings', 'Gateway', 'Advanced', and 'Authenticate App'.

Once you have clicked 'Authenticate App' you will see a 60-second countdown, now it's time to go back to Home Assistant and click 'Submit' to see a message like below.

The Zigbee gateway is now integrated into Home Assistant! The next step is to try and pair the Zigbee door/window sensors I purchased but I will cover that in another post.