Skip to main content

Setting up a Zigbee Network with Home Assistant

··1093 words·6 mins·
Wireless Home Assistant
Table of Contents

Intro
#

Zigbee is a wireless mesh connectivity standard for smart home devices. It’s great for small, low-power devices, like sensors and buttons. Compared to Wi-Fi, Zigbee devices are much easier to set up and typically offer longer battery life.

Choosing a Zigbee Coordinator
#

Zigbee devices all connect back to one central hub, a Zigbee coordinator. While there’s many options for coordinators, deciding on one was actually a pretty easy choice for me.

Almost all Zigbee coordinators use USB to connect directly to your smart home control platform. Since I use Home Assistant running on a server in my basement, this would put my coordinator in a pretty bad location for a wireless hub.

Fortunately, TubesZB Zigbee Coordinators connect to your network via ethernet. This allows me to place my coordinator in a central location rather than being tethered to another computer. These coordinators also come highly recommended on the Home Assistant Forums.

The specific device I ended up choosing was the EFR32 MGM21 PoE Coordinator. At the time of purchase, it had the most recent hardware of the TubesZB coordinators. Power over Ethernet is also a plus since my switch can power the device over its already required network connection.

TubesZB brand Zigbee coordinator
My TubesZB Coordinator

Setting up the coordinator
#

I’m going to be putting this zigbee coordinator on my IoT VLAN, which is accessible locally only and has NAT disabled to prevent access to the internet. Upon plugging the coordinator into a PoE port on the correct VLAN, it got a DHCP lease on the IoT subnet, which I then changed to a static mapping in my router. This ensures the coordinator will get the same IP every time, allowing me to connect it to home assistant via its IP.

Speaking of which, there are two options for connecting zigbee coordinators to Home Assistant: The Zigbee Home Automation (ZHA) Home Assistant integration, or using Zigbee2MQTT (which can be run as a docker container) and controlling zigbee devices through home assistant’s connection to your MQTT broker. Since the TubesZB github page lists EFR32 coordinators’ Zigbee2MQTT support as “experimental” I’ve just gone with ZHA for now, which seems to be the simpler option to implement anyways.

On the TubesZB github page the coordinator’s creator has a few lines he suggests adding to your Home Assistant configuration.yaml when using an EFR32 device (which I am). Using this configuration as a base I edited a few things to my liking, using the ZHA integration documentation as a reference. Here’s the config I ended up with:

zha:
  custom_quirks_path: /config/zha_custom_quirks
  zigpy_config:
    network:
      channel: 25
    ota:
      otau_directory: /config/zigpy_ota
    source_routing: true
    handle_unknown_devices: true
    ezsp_config:
      CONFIG_APS_UNICAST_MESSAGE_COUNT: 30
      CONFIG_TX_POWER_MODE: 3
      CONFIG_MAX_END_DEVICE_CHILDREN: 32
      CONFIG_BROADCAST_TABLE_SIZE: 60
      CONFIG_SOURCE_ROUTE_TABLE_SIZE: 200
      CONFIG_ROUTE_TABLE_SIZE: 32
      CONFIG_ADDRESS_TABLE_SIZE: 32
      CONFIG_PACKET_BUFFER_COUNT: 255
      CONFIG_BINDING_TABLE_SIZE: 32
      CONFIG_NEIGHBOR_TABLE_SIZE: 16
      CONFIG_MTORR_FLOW_CONTROL: 1
      CONFIG_MAX_HOPS: 5

The things I changed from the TubesZB suggested config were the OTA & custom quirks folder paths (which I set to be subdirectories in /config), as well as the Zigbee channel for my network to use. I set the channel to 25, which according to a diagram in this article won’t interfere with 2.4GHz Wi-Fi channels 1 and 6, which I use on my UniFi APs. Since Zigbee uses lower power signals than Wi-Fi it is important to ensure they aren’t operating on the same frequencies, as that could disrupt the Zigbee network’s operation.

After restarting home assistant to apply my configuration changes, I set up my coordinator with the ZHA integration by following the TubesZB github page’s instructions.

Migrating Philips Hue devices
#

With my coordinator set up, I was now ready to move over my Philips Hue zigbee devices, which include 3 color bulbs and a dimmer switch. These were previously paired to a “Hue Hub” (Philips Hue’s proprietary zigbee coordinator), so I’d have to remove them via the hue app before pairing them to my new coordinator. Before un-pairing them I clicked “Add device” under the ZHA integration, which makes it search for new zigbee devices to adopt. After removing the devices from the hub app, I expected them to enter pairing mode and get picked up by ZHA.

As soon as I clicked “Remove Device” in the hue app, bulb 1 and 2 entered pairing mode and were picked up by ZHA. Unfortunately, bulb 3 and my dimmer switch did not get picked up. The dimmer switch has a reset button, so I wasn’t as worried about it as the light. I tried flicking the light switch off then on again a couple times, but the first bulb still wasn’t getting picked up.

Searching online, I found that hue bulbs can be reset using a hue dimmer switch by pressing and holding the off and on switch for 10 seconds in close proximity to a bulb. When I tried this, however, it only caused bulb 2 to blink and reset; I guess I should have unscrewed the other 2 bulbs first… After this reset of bulb 2 it was now in the same state as bulb 3, with neither of them wanting to pair to my coordinator.

Turning to the infinite wisdom of reddit, I found a comment claiming that hue bulbs could be reset (thereby entering pairing mode) by following this procedure:

  1. Start with bulb off for at least 5 seconds
  2. Turn lights on for 8 seconds
  3. Turn lights off for 2 seconds
  4. Repeat steps 2 and 3 three more times
  5. Turn on lights, they should blink for 5 seconds if the reset was successful

Since my bulbs were all in a Bond Light fixture which is also connected to Home Assistant, I used the controls in HA to follow this on/off procedure, again making sure ZHA was searching for new devices first. Fortunately, following this procedure did end up with my lights all flashing for 5 seconds, then being picked up by ZHA. Thanks reddit!

For the dimmer switch I used a paperclip to press the “reset” button on the back for ~15 seconds, after which the front LED flashed orange and green a few times, then the device was picked up by ZHA.

Adding other devices
#

Update from 2023-11-05:

After using my Zigbee network for a couple months, I’ve been very happy with it. After several power outages, devices have reconnected automatically, and controlling Zigbee devices continues to be reliable and snappy.

Unlike my initial experience migrating old devices, pairing new devices has been extremely painless. I’ve added several sensors and smart plugs now, and connecting each one has been as simple as pressing their pairing button while ZHA is searching for new devices.