chemadh / zigbee2mqtt_ha

Zigbee2mqtt High-availability controller prototype
19 stars 0 forks source link

Use Coordinator Backups Instead Of RAM Dumps? #2

Open danieledwardgeorgehitchcock opened 3 months ago

danieledwardgeorgehitchcock commented 3 months ago

I have been investigating and thinking about your project for a while now since you posted it in the Zigbee2MQTT Git Repo.

I am wondering what your driver was for using RAM dumps over the traditional coordinator_backup.json files that are already baked into Zigbee2MQTT..?

In all honesty, I haven't checked what a RAM dump offers which the coordinator_backup.json doesn't but, I am wondering if the latter could be used instead? If so, this would not require any offlining of an active coordinator and, backup / restore methods are already baked into the coordinator firmwares..

danieledwardgeorgehitchcock commented 3 months ago

Further to the above, if a coordinator backup could be used, a simple extension for Zigbee2MQTT could be created that broadcasts the file contents over MQTT itself (if it doesn't already).

With a topic retention set in MQTT, the extension could pull back the latest backup directly from the retained message and do a restore on initial start of Zigbee2MQTT therefore avoiding the need for file synchronisation and better fitting with the technologies that Z2M already has available to it.

chemadh commented 3 months ago

Thanks a lot for your feedback,

In my experience, it was not possible to get a stable behaviour (with no need of re-joining devices) between coordinator switch-overs if NVRAM is not re-flashed in the process. In the other hand, my understanding was that NVRAM contents include internal coordinator functioning variables, not fully available at Zigbee2mqtt level.

However, Zigbee2mqtt documentation points in the direction that you commented. If coordinator_backup.json file is kept up to date automatically by Zigbee2mqtt process, synchronizing and flashing that file directly during switch-over, without a previous extraction of NVRAM content from the coordinator, would be a smarter approach. I definitely will check it and share the results.

If it results in a valid approach, it could also make sense to suggest a Zigbee2mqtt functionality to backup, store, and recover the last known active config for the coordinator IEEE address, using MQTT topic retention functionality (allowing multiple Zigbee networks connected to the same MQTT Broker too).