Zigbee2Mqtt Change network key without loosing zigbee groups and scenes

Hi guys.

My smarthome heavily uses z2m groups and scenes for every room, because they are more performant than ha scenes (which sends unicast zigbee packages).

I am now in the situation to have to change the network key on my rather large network (121 devices with 42 routers, mostly hue bulbs).

Tried this: Change zigbee secure network key, Zigbee2MQTT - #4 by khvej8 and changed my network key and started repairing 6x bulbs with the dimmer switch factory reset. Which worked and Z2M showed them online.

I started with a room and realized groups and scenes will be displayed in Z2M (they are saved in database.db) but does not work. The groups and scenes are obviously stored on the bulbs itself and cleared with the factory reset.

So because I had not much time for also migrate my 100+ scenes, I reverted the key change with an backup restore, repaired the bulbs again and redone my scenes/groups manually for this room. Yes, z2m shows the scene info but you have to change a value, delete the scene and redo it. It was a pain and waste of time.

Yeah, that's the reason I am here to ask: is there any mechanism to preserve z2m/zigbee groups/scenes while changing the network key?

I had an idea:

  • Recall every z2m scene
  • Save them temporary in HA
  • Store the group members (screenshots, just to safe)
  • Do the migration again
  • Redo the groups (so the devices get the group IDs)
  • Recall the temp HA group one for one…
  • And save it with the old/same id/Name in Z2M (store the “same” scenes back on the devices)

Any help is appreciated

Hi, have to admit I do not remember if I recreate the Zigbee groups. Possibly, as I only have a few, the work would not take any time. So, do not remember.

I have never used Zigbee scenes.

Unfortunately, I do not any good ideas. Hope you find a easy solution.

1 Like

Thanks for coming back to me.
Yeah, these things usally we do that not very often :sweat_smile:

Currently i am trying my idea from above … and backup all to HA scenes.

Just wrap it up here if anyone needs this.
The way of storing the scenes for each room temporarily in HA (z2m_backup___) worked like a charme.
Also i have manually stored all Groups, the member count and memebs and scene names.

After changing network key, on first start, all device was gone in Z2M because Z2M backuped the database. I stopped it, restored the database.db and started it again. Sure before changing the key i deleted the coordinator_backup.yaml. After another restart all devices, groups was there, but not functioning.

Yeah, time to repairing all devices, which was a pain on ~120 devices (it took ~6 hours).

Restoring of groups and scenes was a breeze.
FIrst i added back all members to the groups again, than calling each group from HA, deleting it in Z2M and saving it again. In between you have to switch off the group, otherwise some wierd things happens, if some members are on/off between different scenes.

All in all, zigbee network is up again.