Migrate from ZHA to Z2M

Yet another migration-thread… i know. But i’ve read a lot and can’t find a good solution.

My goal:
Migrate my Zigbee-Devices/Network from ZHA (Zigbee Home Assistant) integration to Z2M (Zigbee2MQTT).

My hardware:
I’ve got a flashed Sonoff P-dongle and about 20 devices (temp-sensors, light switches, motion-sensors, some battery driven, some on the grid) and 2 Zigbee repeaters.

How i think i should do it…
After all i’ve read, the stablest way of migrating is to:

  1. Create a Zigbee backup (from the Coordinator) and a HA backup for savety
  2. Remove (delete) all Zigbee-devices from ZHA in Home Assistant
  3. Delete the ZHA integration (which will free up the dongle)
  4. Add the Z2M integration (add on) and assign the dongle
  5. Repair ALL devices, one by one
  6. Change the device-names (IDs) to what used before (lookup device by it’s IEEE ID in the Home Assistant backup JSON files to find the old names). By using the same name for the new added Zigbee devices, all automation tasks should work again.

That is a bit of a hell job, but looks like the most quirkless way.

2 Likes

Install GitHub - frenck/spook: Spook 👻 Not your homie it will notify you of missing devices (and stop notifying you when the device is back), a good way to keep track of what devices you have paired and not.

Also pair routers (bulbs, mains powered devices) first before you do the battery ones.

1 Like

Hate to spend more of your hard earned coin… however, I would purchase a 2nd coordinator dongle and bring up a parallel Zigbee2MQTT system. Then at a steady pace, move your zigbee devices over. Yes, get a router infrastructure set first before the distant end devices. I think this is a more stable and less error prone route than a ‘rip and replace’.

I run my MQTT and Zigbee2MQTT systems in docker side by side with my Home Assistant server, so that is a bit different than I think you have. However, I highly recommend it, in order to keep your HA server as simple as possible and focused on it’s core tasks. Back to your setup, though I’ve not done it, I think you can run both ZHA and Zigbee2MQTT within the same HAOS, as long as you have two zigbee coordinator dongles. Do some searching on these forums to see folks experiences with both inside HAOS.

Good hunting!

4 Likes

Correct. I run ZHA, z2m, and z2m-edge all at the same time under HAOS.

A leisurely migration is worth the few dollars for an extra coordinator.

2 Likes

I got a bit further. What i missed was to install an MQTT broker (added that).

I then made a backup of HA and ZHA (just for safety) and removed all Zigbee devices, one by one. The routers as the last, right before removing the coordinator and ZHA fully.

Then installed Zigbee2MQTT (and integration) and configure it to use the MQTT broker and to use my patched Sonoff coordinator at /dev/ttyUSB0.

After starting up i changed to “auto join mode” and the immediately the first devices came in! Great, it is such a please to work with Z2M. Just put another device (SNZB) into pairing, and it shows up right away! I could restore most of my network in minutes.

There is just one router in my cellar that refuses to pair the devices in it’s surrounding for an unknown reason.

In the map it looks like the renegate router (red marking) is connected to the coordinator, but this could not be the case as the distance is much to large. It should connect to the other router instead (…13b8)


It also show a “0” with the network strength

What i did was to move the router nearer to the other router to get it to bind initially. I guess it then binds directly to the coordinator, like the other router nearby. Then i moved it back into the cellar and now it can’t connect to something.

2 Likes

The “Permit Join” button is actually a drop down menu. Select a geographically appropriate router to pair with and try re-pairing the rogue device.

1 Like

In theory and hopefully in practice (based on the specific devices you have), that router should ‘adapt’ and connect back to the coordinator via another ‘stronger’ route via another router. That said, you are kind of hurting yourself by physically putting a device next to the coordinator and binding it to the coordinator and then moving the devices to a place that it does not have a strong connection to the coordinator. As @jerrm indicated, completely remove the device that added to Zigbee2MQTT this way, you may have to do a ‘force’ option on the remove in Zigbee2MQTT. Then physically move the device to the location you want it to be in. And then ‘add via’ a closer router. This process is not really clear in any of the Zigbee implementations, frustrating for most users. As I said, even if you did what you did, the device should ‘get a clue’ and start to route via a closer router rather than directly to the coordinator, however if you search this forum and the zigbee2mqtt forum, you will find folks with a mixed bag of success with some of the newer ‘low cost’ devices. Below is a screen shot of the ‘dropdown’ that @jerrm is referring to, not very user friendly IMHO. I’m not referring to the fact, I use MAC address for my device names, another whole opinion item, just the fact this menu does not clearly stand out and describe its function. Good hunting!

I understand, thank you very much. I could remove the router, put it to it’s originate place and tried to re-add it again, the way you described:
Selected the other router (it’s the nearbiest ZB module) from the dropdown, choosed “Permit join” for that device. A 4 minute countdown starts (never noticed that in the first…) and it restartet the rouge router, but nothing, it won’t show up.

Not sure I understand what you mean here.

I think from your posts, the problem device has a last six digits of it’s mac address as DD:3B:66, is this a kind of ‘custom’ CC2530 based device? What firmware is on it? What is it?
Are you sure you did a ‘force remove’ when you removed it prior to readding and did you make sure it no longer appears in your list of zigbee devices?

When you do the ‘add via’ steps, you should see several ‘bubble’ pop up along the right side of the zigbee2mqtt HTML page. If you are not seeing those, or they have errors (red not green bubbles), then the device is not being found. Perhaps, if you have another zigbee device from different vender that you can do an ‘add via’ and see what happens. Goog hunting!

I replaced the DiY router by a Sonoff ZB 3-P dongle, flashed as router. Now it’s working (again). Maybe the old one get’s broke.

Now my network setup is complete and i am very happy with Z2M, it is really so much better than ZHA.

2 Likes

Trying not to create a new thread :slight_smile:
Trying to migrate some devices to ZHA and - this is the problem - to keep their friendly names. Say, there is “garage_desk_light_1” bulb. HA knows it as “light.garage_desk_light_1”. Now I am adding it to ZHA. The entity becomes “light.garage_desk_light_1_light” even though I manually change the name of the device to “garage_desk_light_1”.
Is there a way to teach ZHA not to add “_light” in the end (as it already has “light.” in the front and “light” in the name)?
I have a few things like this and really hate changing all automations and dashboards
Thanks,.

So in the end, there is no solution to seamlessly restore ZHA devices into Z2M.
This solution is Z2M and ZHA later…
https://smarthomescene.com/guides/how-to-use-zigbee2mqtt-and-zha-with-a-single-coordinator/
I was hoping the other way round without unpairing devices from ZHA

2 Likes

same here. as some devices have issues with joining through the ZHA (SkyConnect), I flashed a SonOff ZBridgePro to Tasmota and now want to migrate from ZHA to Zigbee2MQTT. is there a way to import the Zigbee database somehow into Z2M?

No. Re-pairing is the way to go.

I was also interested in trying out Z2M, but I decided to keep with ZHA instead.

I have a pretty extensive Zigbee network now of 90 devices, and it’s not worth the hassle since they’re already working in ZHA.

I dunno what devices wouldn’t be compatible, but Philips Hue, IKEA, Inovelli, and Sengled work fine in ZHA.

I can confirm that adding an extra Zigbee dongle for the Z2M network is the best way to migrate.
There were the odd device that just wouldn’t play well with Z2M, so I ended up keeping a small ZHA network as well.

I have two Skyconnects. How would I go about migrating devices over? Do I have to physically mess with them or can I do it all in Home Assistant?

You will need to re-pair all devices.

I’m fine repairing them. Can I keep the same entity names so my automations don’t suddenly break? Is there a good process for doing this transition?

You can keep the names, sure. Just delete the device from ZHA first, then pair it in Z2M.