ZHA or Zigbee2MQTT: Which One Should You Choose?
To connect my first Zigbee switches to Home Assistant, I first needed... Zigbee.
So I ordered a SONOFF Zigbee 3.0 USB Dongle Plus (ZBDongle-E), based on an EFR32MG21 chip.
Why that one?
Nothing particularly scientific about it.
The price seemed reasonable for an experiment, the reviews were very good, and it appeared to be widely used with Home Assistant.
Should I have researched it more thoroughly?
Maybe.
But three months later, I still have absolutely no reason to regret that choice.
The only thing I probably would have liked to know at the time was that there were also solutions designed to cover both Zigbee and Thread.
Would that have changed my choice?
I'm not even sure.
Today, this dongle does exactly what I ask of it, and I don't feel limited in any way by having a dedicated Zigbee interface.
Right. I Have a Dongle. Now What?
Once the dongle was installed — and after a little bit of fun getting USB passthrough working all the way through to my Home Assistant VM — another question appeared:
ZHA or Zigbee2MQTT?
ZHA is directly integrated into Home Assistant.
Connect a compatible coordinator, Home Assistant can detect it, and you can configure your Zigbee network directly from the interface.
Simple.
Zigbee2MQTT, on the other hand, requires a few additional pieces.
You need to install Zigbee2MQTT, have an MQTT broker — Mosquitto in my case — and then connect all those little pieces to Home Assistant.
Seen like that, the choice seems fairly obvious.
Why make life more complicated?
Except...
After doing a little research, I quickly realised that a significant part of the community was using Zigbee2MQTT.
And generally, when a lot of people deliberately choose the path that requires a little more tinkering, I tend to wonder why.
There is probably some historical legacy behind that.
Zigbee2MQTT has long had a reputation for supporting a very wide range of devices and offering a huge amount of configuration flexibility.
But you have to be careful with comparisons found on the Internet.
ZHA has evolved considerably.
Today, it can handle things such as Zigbee groups, device bindings, OTA updates and network backups. It can also migrate a network to another compatible coordinator.
In other words, some of the historical arguments in favour of Zigbee2MQTT are no longer necessarily enough to separate the two.
And to this day, I still haven't found a definitive answer to the question:
“Which one is better?”
I'm increasingly convinced that it simply isn't the right question.
A Question of Architecture
There was, however, something about Zigbee2MQTT that appealed to me more.
With ZHA, the whole thing appeared to me as a relatively monolithic solution integrated into Home Assistant.
With Zigbee2MQTT, I saw something more like this:
More pieces.
So, objectively, more things to install, configure, monitor... and potentially break.
Curiously, that was also part of what I liked about it.
Each component had a role I could identify.
Zigbee2MQTT handled the Zigbee network.
Mosquitto carried the MQTT messages.
Home Assistant made use of them.
Probably my slightly twisted side showing.
Or simply a preference for architectures where I can see fairly clearly who is talking to whom.
And What About MQTT?
There was another idea behind the choice as well.
MQTT obviously isn't limited to Zigbee2MQTT.
Once you have a Mosquitto broker running, there is nothing stopping you from connecting other applications, sensors or services to it.
At the time, I didn't necessarily need any of that.
But I liked the idea of adding a generic building block rather than a component that would only ever serve one specific purpose.
And since then, other things have indeed started using Mosquitto.
That absolutely does not prove that Zigbee2MQTT was the better choice.
It simply means that, in my case, the architecture that appealed to me eventually found other uses.
So, ZHA or Zigbee2MQTT?
If someone asked me that question today without giving me any other context, my answer would probably be:
start with ZHA.
It's directly integrated into Home Assistant, there are fewer components to install and maintain, and if your goal is simply to add Zigbee devices to your setup, it's probably the most straightforward route.
I would take a more serious look at Zigbee2MQTT in a few situations.
If you feel like going a little further under the hood, for example.
Or if MQTT is already part of your infrastructure.
If you already have an active Mosquitto broker — perhaps because several services running in Docker containers are already publishing data to it — adding Zigbee2MQTT to that environment can feel quite natural.
The broker already exists.
It's configured.
You know why it's there.
Zigbee2MQTT simply becomes another component using that infrastructure.
On the other hand, installing Zigbee2MQTT and an MQTT broker solely to connect a handful of Zigbee switches to Home Assistant adds complexity that you may have absolutely no need for.
And I think that's ultimately where a large part of the answer lies.
The choice doesn't just depend on what Zigbee2MQTT can offer. It also depends on what you already have and what you intend to do with it.
And Me?
I was starting almost from scratch with Zigbee.
I didn't already have an ecosystem full of MQTT components that would have made Zigbee2MQTT the obvious choice.
And yet...
I chose Zigbee2MQTT.
Three months later, can I say it was the best choice?
No.
Have I found any reason to switch to ZHA?
No either.
I still like the architecture, Mosquitto has since found other things to do, and my Zigbee devices work.
For now, that's more than enough for me.
And if I had to recommend something to someone starting today?
ZHA by default.
Then Zigbee2MQTT once you start having a reason to choose it.
Even if, apparently, some of us prefer to start with the solution that has more pieces.
Probably because it gives us more things to understand.

Comments
No comments yet.
Add a comment