ZHA vs Zigbee2MQTT – choosing the best system?

Published by Oliver on

There are two awesome tools for local control over Zigbee devices: ZHA vs Zigbee2Mqtt. Which one should you use? I recently switched from Zigbee2MQTT to ZHA. Here I will show you how to set up ZHA with Home Assistant and compare ZHA and Zigbee2MQTT.

My setup

I recently started a new smart home setup after moving into a new apartment. I had been running Zigbee2MQTT with this setup for a couple of years now with about a dozen sensors from Aqara and IKEA Tradfri lightbulbs. It has been a really good experience: quite stable with few problems, mixing devices from multiple manufacturers and good integration into my smart home controller (OpenHab at the time).

A new Zigbee bridge

So why would I switch systems? My only real complaint about my Zigbee2MQTT system was the hardware used. I ran the network using a CC2531 USB-to-Zigbee stick. This works really great for beginners. The devices is very cheap and can be ordered with the right firmware online. Unfortunately it is also not very powerful. It can’t control too many devices directly (fortunately this is not really a problem as I have a lot of repeaters in the form of lightbulbs in my network) and it has a pretty bad range.

If you run this setup in an apartment or a small house with a lot of repeaters you might not run into any problems. I tried to also set up a similar system in my parents’ house though and quickly ran into a range problem. The server running the smart home system is stored in quite a remote place with no repeaters nearby. The walls are also built from reinforced concrete so radio-waves are blocked a lot. No luck here.

Fortunately I ran across a possible solution for this range problem: a product with a better range that is not bound directly to the control server: the Sonoff Zigbee bridge. A small Wifi connected box with a Zigbee chip. The Wifi connection makes it much more flexible in regards to the position and you can flash the open source firmware Tasmota. This gives you full (local) control over the device. Awesome! It is also still quite cheap: I paid around 20€ for mine.

The Sonoff Zigbee bridge – my wireless ZHA controller

While it has not really changed anything for me yet, I would also like to add that the bridge supports the Zigbee 3.0 standard while the CC2531 is stuck with older versions. Zigbee version 3 is supposed to make devices for unified which might be a big plus later on.

Small update here: I have since actually switched to another controller. Now I am using the Sonoff Zigbee 3.0 USB dongle plus. It also comes with support for many devices and the modern Zigbee version but it eliminates another wireless connection. While the Wifi bridge worked great this should be even more stable. I was even able to migrate all the data without the need to re-pair my devices.

Setting up ZHA with Home Assistant

To prepare the Sonoff Zigbee bridge we need to first flash Tasmota and then update the firmware on the Zigbee chip. There is a very nice full guide on how to do this here. Here is the quick rundown:

  • open the Zigbee bridge by removing the small wire feet and removing the screws
  • set your USB to serial adapter to 3.3V and connect it to the bridge:
    • ETX to RX
    • ERX to TX
    • 3V3 to 3V3
    • GND to GND
    • IO0(GPIO Zero) to GND
  • Plug in the adapter and select it in Tasmotizer. Select tasmota-zbbridge.bin and flash. Afterwards you can also use the program to burn the config for your Wifi
  • Assemble the bridge again and connect it to a USB power adapter
  • Wait until it connects to your network (or go to the AP provided by the device) and open the console. Run this:
Backlog Weblog 3; so65 1; Module 75
// wait for restart
// go to the main menu and upgrade the software. Use the stable .ota file from here https://github.com/arendst/Tasmota/tree/development/tools/fw_SonoffZigbeeBridge_ezsp
// in the console you should see some XMD: ... messages

// once done run:
backlog rule1 on system#boot do TCPStart 8888 endon ; rule1 1 ; template {"NAME":"Sonoff ZHABridge","GPIO":[56,208,0,209,59,58,0,0,0,0,0,0,17],"FLAG":0,"BASE":18} ; module 0
// there should now be a message about the server started

// you can optionally also change the OTA path for the future
otaurl http://ota.tasmota.com/tasmota/tasmota-zbbridge.bin.gz

Now we are ready to connect the bridge to Home Assistant.

Adding ZHA to Home Assistant

In your Home Assistant instance go to integrations tab and “add integration” via the button below. Select “Zigbee Home Automation” (ZHA) from the list and install it.

Installing ZHA in Home Assistant

Now the setup process begins. Select “Enter manually” when asked for a device path and choose “EZSP” as the device type. Afterwards you can use socket://<your bridge IP>:8888 as the serial path and 115200 as the port speed. This will connect to your Zigbee bridge directly via TCP.

After a few seconds the setup process should be done now. If you want to you can assign a room to your bridge, afterwards you can close the setup. You should now see a new working integration in your setup.

Zigbee integration in my Home Assistant setup

Pairing Zigbee devices from Home Assistant

Now it is time to actually connect some Zigbee devices to your setup. Fortunately this process is super easy with ZHA. Click “CONFIGURE” and then “add device” in your ZHA integration. ZHA will now start searching for new devices. Now all you need to do is put your devices in pairing mode. This is usually done by pressing a certain button for some time. A list of compatible devices and how to pair them can be found on this website.

After a couple of seconds devices will now start showing up in the ZHA integration. Each one will have a default name. Change that name and optionally assign a room here, then continue with the next device. Once you are done just close this screen. All your Zigbee devices should now show up in Home Assistant.

Proper control panels should show up automatically – here for white adjustable Hue lightbulb

I was able to join a couple of Tradfri lightbulbs, different Philips Hue lightbulbs as well as different Aqara sensors and buttons without any problem. Adding a IKEA Fyrtur blind was a little bit more complicated but also worked.

ZHA vs Zigbee2MQTT

So after using both systems, which ones is better? Which should you be using? It depends. Both systems are great, both are working very well. It depends on your use-case which system will work better for you. Here are a couple of (dis)advantages of the different systems though.

zha vs zigbee2mqtt advantages & disadvantages for both systems
ZHA vs Zigbee2MQTT – there are advantage for both systems

What is great about Zigbee2MQTT

Zigbee2MQTT is the more independent of the two systems. You are not tied to any specific smart home system as pretty much all of them can interface with MQTT. This means you can also run it on a machine separate from your smart home server. It will also stay online while you restart your actual smart home controller, which can be a big plus with Home Assistant that needs to be restarted every time something changes in the configuration files.

It is pretty easy to set up, at least if you have a certain knowledge about technology. Check out my GitHub repository if you are looking for a ready-to-go setup. It supports a very wide range of devices and I never had any major problems with my setup.

It does not come with a graphical user interface but the Zigbee2MQTT assistant will fix that problem. Since I wrote this a graphical interface was actually added and is available by default on port 8080 of your server.

Zigbee2MQTT will also allow you to upgrade the firmware of devices from some companies like IKEA (Tradfri) and Philips (Hue) – OTA updates. Additionally you can change some of the device settings (like report frequency, etc…).

Finally it seems to be relatively easy to add support for new devices, although I never had to do that.

What is not so great about Zigbee2MQTT

Zigbee2MQTT has been working very well for me. Of the two systems it is the slightly more complex one though. While the setup was not very hard it requires additional software (a MQTT broker) and some technical skills.

Although the configuration via the text file is pretty simple, and makes it easy to back up your settings, some changes like renaming a device require editing of said file and a restart. That can be quite annoying. A fully integrated GUI like ZHA included in Home Assistant makes all of this much easier.

Pairing of devices also sometimes took quite a while for me but did always end up working. Most likely this is a fault of the network though, not the software.

For me the biggest drawback of Zigbee2MQTT is something that is not actually part of the software: the hardware. The CC2531 stick is used in most cases and while it is cheap and works, its range and capacity are very limited. While the project does support a wider range of adapters now, as far as I can see they are all supposed to be directly connected to your server. Some of them, while being very powerful, are also more expensive.

Actually Zigbee2MQTT does support the Wifi bridge now. It is still recommended to use a directly connected controller though to avoid another error source. It also seems like new hardware gets added to ZHA quicker but that might change from case to case.

What is great about ZHA

ZHA is a newer alternative to Zigbee2MQTT and does a couple of things differently. The great integration into Home Assistant makes installation and device discovery really really simple. No text configuration needed in most cases, just the GUI.

While the list of supported devices is a little bit smaller than Zigbee2MQTT’s it is still very likely to support everything you want to use. I certainly had no problems in that regard. Ikea Tradfri, Philips Hue and all the Aqara devices just worked.

Adding new devices and groups as well as seeing a map of your network right there in Home Assistant is just great and an awesome user experience.

Maybe my biggest reason for using ZHA was the support for the Sonoff Zigbee bridge. A cheap device, with custom locally controlled firmware that can be placed anywhere (has since been added to Z2MQTT too). Being able to switch controllers without repairing was great too and might be properly integrated into Home Assistant soon.

What is not so great about ZHA

The tight integration into Home Assistant, while being a great user experience, is also the biggest drawback of ZHA. As far as I know you simply can not use it with another system. It also means restarting Home Assistant, which unfortunately you still need to do to update certain things, will also make your Zigbee devices unavailable for some time.

While ZHA offer support for OTA firmware updates (something Z2MQTT does well) it is a bit more complicated to use.

It does include a network map and Home Assistant as a general interface but just for managing your Zigbee devices I actually prefer the UI of Zigbee2MQTT assistant. The assistant does feature a better network map than ZHA im my opinion, has nice labels and supports more firmware upgrades.

Which system should you use?

So – ZHA vs Zigbee2MQTT – which system should you use? As I said it depends.

If you are not using Home Assistant or if you need to run the smart home controller and the Zigbee control software separately, the choice is simple: use Zigbee2MQTT.

If you are using some more rare device it might also be a good idea to check the list of supported devices and go with the system that supports yours.

If, on the other hand, you are using Home Assistant and are looking for a system that is easy to set up without additional software then go with ZHA! The UI integration is well done and the support for a Wifi – Zigbee bridge like the Sonoff bridge can be really really helpful. The rest of the controls are nearly as powerful as Zigbee2MQTT. In my opinion this is the best choice for beginners.

Overall I have to say both systems are great. Both have not been hard to set up and have worked very reliable for me (although I have seen people claim otherwise for both systems). In any case I really recommend going with this open source approach instead of buying and operating a bunch of different gateways. At least if you are enthusiastic about tech and have some time at hand. Integration of most devices is really smooth, you can combine the best & cheapest devices from many companies and YOU take full control over all of it.