Comparing Zigbee2MQTT with ZHA

A screenshot of the Zigbee2MQTT home page

If you’re a Home Assistant user who is getting started with Zigbee devices, then you may be tempted to just use Zigbee Home Automation (ZHA), Home Assistant’s built-in Zigbee implementation. But you may also want to consider Zigbee2MQTT as an alternative, and this blog post will explain the differences.

I’ve recently started looking into Zigbee devices. Back in July, I wrote about the different smart home protocols, and Zigbee offers some useful features:

  • Low power, so battery-powered Zigbee devices shouldn’t need their batteries replacing too often.
  • It’s a mesh protocol, so every mains-powered Zigbee device forms a mesh with each other, allowing a network to span a house without necessarily needing multiple access points like Wi-Fi.
  • It works locally, so it’s more secure and private than Wi-Fi.

If you have Philips Hue bulbs, Ikea Tradfri devices or any Hive products from British Gas, then you’re probably already using Zigbee devices. You also have a private Zigbee network if you have a smart meter, although you won’t be able to use this with your own devices. I’m using a Sonoff USB Zigbee dongle (sponsored link), which is plugged into the Raspberry Pi which runs Home Assistant. Previously, I had flashed it with custom firmware to enable support for Thread and Zigbee, but I’ve reverted that now as multiprotocol support is experimental, and I have Google Wi-Fi devices which support Thread if needed.

Zigbee Home Automation (ZHA)

If you’re new to Zigbee and/or Home Assistant, my recommendation is to use ZHA, which is Home Assistant’s built-in implementation. If you plug your Zigbee dongle in, Home Assistant should detect it, and offer to configure the ZHA integration for you. Then, you just add devices using the ‘Add Integrations’ button on the Integrations Settings page, where a new ‘Add Zigbee device’ option will appear at the top.

Home Assistant should be able to recognise and offer to add any Zigbee device, but what you may find is that some devices won’t have any entities. This means that it’s not supported by ZHA. There’s a database of Zigbee devices which you can use to check whether they’re supported by ZHA or Zigbee2MQTT, and what you may notice is that there are quite a few which ZHA doesn’t support.

Zigbee2MQTT

One of the devices that I’ve recently bought seemingly fell into this latter category. To be fair, I never checked it with ZHA, but reading reviews online suggested that it would only work with Zigbee2MQTT and not ZHA. Zigbee2MQTT also maintains its own list of supported devices, which currently number nearly 4000.

Getting Zigbee2MQTT set up with Home Assistant is a much more involved process, however. You’ll need to install two addons and an integration:

  1. Firstly, you’ll need to install the Mosquitto addon, which is an MQTT broker – essentially a server which handles the MQTT messages. This is available from the standard Home Assistant add-on store. There are other brokers available, but this one is most recommended for use with Home Assistant.
  2. Next, you’ll need to install the MQTT integration. Once Mosquitto is running, Home Assistant may automatically detect it, and offer to install this for you, but if not you’ll need to install it manually.
  3. Finally, there’s the Zigbee2MQTT addon to install. This isn’t available from the standard Home Assistant add-on store until you add a custom repository.

Once all of these are installed, you’ll need to disable the ZHA integration if it’s enabled, and then open the Zigbee2MQTT web interface. Go into the settings, and ensure that it’s pointing at the Mosquitto MQTT server that you set up in step one above – you may need to enter its IP address.

You’ll then need to add devices using the Zigbee2MQTT web interface – there’s a button at the top right where you can enable pairing. Any devices you add will then show up automatically under the MQTT integration in Home Assistant.

Once set up, Zigbee2MQTT seems to work well, and I’ve seen others state that they’ve found it more stable than ZHA. But it’s a lot more difficult to set up, and ZHA will probably work for most users. If you’re new to all this, my advice would be to try ZHA first, and then re-pair your devices with Zigbee2MQTT if it doesn’t work out.