Z2m to zha compatibility

Hi everybody,

I have been using zigbee2mqtt for (at least) four years now, and it always worked fine; well, some times it didn’t, but I eventually realized it was my fault, so those don’t count…

But for quite some time now, zigbee2mqtt doesn’t have a webUI any longer. I use the official HA addon. At first, there was a webUI, but all my devices were gone. They were still working fine in Home Assistant, but I could not see or edit them in the zigbee2mqtt tab. Automations etc. all still worked.

Then, more recently, the webUI was gone!! All my existing devices are still there, but when I click the z2m tab now, I get informed that zigbee2mqtt is not running and asked whether I want to start it. However, as you can see from the logs, it was indeed running. I can toggle zigbee devices as well. But the webUI is completely gone.


So today I uninstalled, then re-installed zigbee2mqtt. The webUI was back. Yay! Now, a few hours later, I have the same issue as before: webUI gone, popup saying it’s not running, but it actually is.

If I switch to zha, how likely is it that all my devices that worked with zigbee2mqtt will still work? I am using vanilla z2m, no custom devices… everything I have is officially supported by z2m without modifications. Will all these devices work with zha?

I am quite sure it will be hell re-pairing all these devices, but I cannot work with z2m like this, either. I ordered the new Sonoff / iTead SVW-BSPs; apparently, they have paired with z2m, because when I inspect the mqtt traffic, those new devices are there. But they are not shown in Home Assistant (even though the mqtt messages are going through Home Assistants mosquitto); since there is no z2m webUI, I cannot look into this further the way I would have in the past.

If people on here tell me zha is good to replace z2m without any issues, I’ll give it a try. I remember trying this before and some things being annoying, for example, button presses that used to be binary_sensor entities via z2m were “reduced” to events by zha, so I didn’t even look any further into it. I didn’t want to re-write countless automations. But now that this z2m issue has been going on for so long, I’d gladly give it another shot as long as all my devices would still work. I’ll rewrite those automations, it’s better than not having a UI to configure things properly.

Thanks in advance for your ideas :slight_smile:

What sort of zigbee devices do you have?

Z2M tends to be faster at adding new devices but if all you have is well known brands and devices (excepting Tuya) you should be ok.

That’s a really weird failure. Do the logs from the add-on show anything odd?

What web browser are you using?

1 Like

If I switch to zha , how likely is it that all my devices that worked with zigbee2mqtt will still work?

Both ZHA and Zigbee2MQTT have a great, but slightly different supported devises list. You can check the list out here:

I am quite sure it will be hell re-pairing all these devices

I’m not shure, but the following instruction is given on the FAQ of zigbee2mqtt:

Requires repairing

You need to re-pair all you devices when:

  • Changing the network key (network_key), Zigbee channel (channel) or panID (pan_id) in configuration.yaml.
  • Switching between adapters requires repairing, except when:
    • When adapters are the same repairing is not required (e.g. CC2531 → CC2531)
    • Switching from a CC2530 or CC2531 based adapter to a CC2538/CC2652/CC1352 based adapter does not require repairing (e.g. CC2531 → CC2652)
    • Switching between CC2538, CC2652 and CC1352 based adapters does not require repairing (e.g. CC2538 → CC2652)

Doesn’t require repairing

You don’t need to re-pair your devices when:

  • Updating or downgrading Zigbee2MQTT to a different version.
  • Updating the coordinator firmware.
    • If after flashing you fail to control your devices it helps to:
      • Wait a few minutes so that the Zigbee network can settle.
      • Send Zigbee commands (e.g. turn on/off) to the device.
      • Reboot the device (unplug and plug power).
  • Switching the system running Zigbee2MQTT.
    • When doing this, make sure to copy over the contents of the data directory.

I didn’t want to re-write countless automations

if your entity ID’s do not change I dont think you need to rewrite a lot of automations :slight_smile:

I meant that I’ll have to re-pair all those devices if I were to switch from z2m to zha. Unless there is a way to use the same network_key, channel, and pan_id…? I’ll look into that.

if your entity ID’s do not change I dont think you need to rewrite a lot of automations :slight_smile:

It was like this when I last tried to switch from z2m to zha; I have multiple aqara opple buttons. With z2m, they have a binary_sensor or sensor entity that reports something like button_1_single or button_3_double, depending on the presses.

With zha, these sensors were gone; the button presses were reported as events instead, so I couldn’t just keep the entity_id (or change it in the automation), but I’d have to change the automation to work with events instead of statuses.

I meant that I’ll have to re-pair all those devices if I were to switch from z2m to zha. Unless there is a way to use the same network_key, channel, and pan_id…? I’ll look into that.

Maybe this is something to look into:

It was like this when I last tried to switch from z2m to zha; I have multiple aqara opple buttons. With z2m, they have a binary_sensor or sensor entity that reports something like button_1_single or button_3_double , depending on the presses.

I didn’t think of that, but your right. If the way to events are being given to HA is different you will be looking into changing all of your automations :frowning:

You will have to re-pair. How many devices?

I did all my 74 devices last month when I changed zigbee channel. Didn’t take too long. Starting with the routing capable devices closest to the coordinator and moving away. Then all the non routing end devices. Helps to have a tablet or laptop you can carry around with you to rename the devices as they are added and to keep the pairing process open (for z2m, not sure how zha handles that).

There was an issue that should be fixed in the dev branch:

I personally had an issue with 1.38, that may or not be related:

I would suggest trying the dev branch first, if that doesn’t work remove any icon: entries from devices.yaml (if present).

As for moving to ZHA, there is more involved than just getting the devices joined, you would also need to touch most, if not all, automations. Great pain with no gain IMO.

1 Like

Not if they:

Oh unless they are using the dreaded device automations. Then yeah that would be a real pain.

1 Like

Matching device names are often not enough. Entity names change as well. A motion sensor entitiy in z2m may be exposed as “_occupancy” where ZHA will call it “_motion”. Automations may be OK if you rename all the way down to the entity level, but that’s still a lot of work and potential maintenance headache.

Anything based on z2m “action” state triggers would have to be reworked, probably into ZHA event triggers.

1 Like

This (@jerm 's recommendation) is where I’d start. Load the dev branch and see if youre fixed before starting anything else.

As mentioned above but not clearifiednthere, you can actually partially migrate so that you do not need to manually, but as @jerrm wrote you need to update all your automation to point to the new entities created. You also need to recreate any Zigbee groups and bindnings too if you have those. See here:

Note that is not a full migration as it does not copy any application settings/configurations from Zigbee2MQTT and you get new entity names:

Note: this procedure only helps migrate basic network settings to your Home Assistant Connect ZBT-1, customizations like device names will be lost and automations will need to be updated. Most powered devices like lightbulbs will be re-discovered over time (you can speed this up by rebooting the device) but your battery-powered devices may need to be re-joined to the network for the migration to complete. There is currently no migration path to migrate all settings and devices. If you no longer have the old stick, you can migrate via z2m backup.

Thanks, everybody :slight_smile:

While I have been putting it off, I meant to freshly install HA and clean things up (either everything yaml or everything GUI, not some here some there, as I have now), and if I eventually get around to doing that, I’ll see whether I’ll use z2m or switch to zha.

I’ll wait until I really need the webUI and then switch to the developer branch, until then, it’s basic z2m. Not ideal, but I don’t feel comfortable using the dev version because it might fix this issue, but create others.