Yeah prior to this, if you wanted to make a backup on HA, the ZHA integration needed to be disabled and you needed to ssl into HA to access the coordinator (he other option is using another environment altogether). For ZHA_CUSTOM, ZHA needs to be enabled otherwise the commands do not work.
I just did a nvram reset and here are the logs (everything looks okay, nvram backup was created successfully as well)
2022-01-08 09:09:45 INFO (MainThread) [custom_components.zha_custom] Running custom service: <ServiceCall zha_custom.execute (c:d0c61e312e531a68ba6ddcde5e90dec6): command=znp_nvram_reset>
2022-01-08 09:09:45 DEBUG (MainThread) [custom_components.zha_custom] module is <module âcustom_components.zha_customâ from â/config/custom_components/zha_custom/init.pyâ>
2022-01-08 09:09:45 INFO (MainThread) [custom_components.zha_custom.znp] Reading NVRAM from device
2022-01-08 09:09:59 INFO (MainThread) [custom_components.zha_custom.znp] Saving NVRAM to â/config/custom_components/zha_custom/local/nvram_backup_20220108_090945.jsonâ
2022-01-08 09:09:59 INFO (MainThread) [custom_components.zha_custom.znp] NVRAM backup saved to â/config/custom_components/zha_custom/local/nvram_backup_20220108_090945.jsonâ
2022-01-08 09:09:59 INFO (MainThread) [custom_components.zha_custom.znp] Reset NVRAM
Rebooted and did an NVRAM Restore (devices did not come back online after a restart)
2022-01-08 09:19:12 INFO (MainThread) [custom_components.zha_custom] Running custom service: <ServiceCall zha_custom.execute (c:9aba205011eaf778e1f71555824cc4d0): command=znp_nvram_restore>
2022-01-08 09:19:12 DEBUG (MainThread) [custom_components.zha_custom] module is <module âcustom_components.zha_customâ from â/config/custom_components/zha_custom/init.pyâ>
2022-01-08 09:19:12 INFO (MainThread) [custom_components.zha_custom.znp] Reading NVRAM from device
2022-01-08 09:19:27 INFO (MainThread) [custom_components.zha_custom.znp] Saving NVRAM to â/config/custom_components/zha_custom/local/nvram_backup_20220108_091912.jsonâ
2022-01-08 09:19:27 INFO (MainThread) [custom_components.zha_custom.znp] NVRAM backup saved to â/config/custom_components/zha_custom/local/nvram_backup_20220108_091912.jsonâ
2022-01-08 09:19:27 INFO (MainThread) [custom_components.zha_custom.znp] Restoring NVRAM from â/config/custom_components/zha_custom/local/nvram_backup.jsonâ
2022-01-08 09:19:27 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall zha_custom.execute (c:9aba205011eaf778e1f71555824cc4d0): command=znp_nvram_restore>
Traceback (most recent call last):
File â/usr/src/homeassistant/homeassistant/core.pyâ, line 1511, in catch_exceptions
await coro_or_task
File â/usr/src/homeassistant/homeassistant/core.pyâ, line 1530, in _execute_service
await handler.job.target(service_call)
File â/config/custom_components/zha_custom/init.pyâ, line 73, in custom_service
await handler(
File â/config/custom_components/zha_custom/znp.pyâ, line 180, in znp_nvram_restore
nvram_obj = json.load(f)
File â/usr/local/lib/python3.9/json/init.pyâ, line 293, in load
return loads(fp.read(),
io.UnsupportedOperation: not readable
Reboot and did a network restore
2022-01-08 09:26:45 INFO (MainThread) [custom_components.zha_custom] Running custom service: <ServiceCall zha_custom.execute (c:6d70b0fa91d29d99c0be404ce7905b91): command=znp_restore>
2022-01-08 09:26:45 DEBUG (MainThread) [custom_components.zha_custom] module is <module âcustom_components.zha_customâ from â/config/custom_components/zha_custom/init.pyâ>
2022-01-08 09:26:55 INFO (MainThread) [custom_components.zha_custom.znp] Restore from â/config/custom_components/zha_custom/local/nwk_backup.jsonâ
2022-01-08 09:26:55 INFO (MainThread) [custom_components.zha_custom.znp] Validating backup contents
2022-01-08 09:26:55 INFO (MainThread) [custom_components.zha_custom.znp] Backup contents validated
2022-01-08 09:26:55 INFO (MainThread) [custom_components.zha_custom.znp] Writing to device
2022-01-08 09:27:34 DEBUG (MainThread) [custom_components.zha_custom.znp] List of attributes/methods in znp [âclassâ, âdelattrâ, âdictâ, âdirâ, âdocâ, âeqâ, âformatâ, âgeâ, âgetattributeâ, âgtâ, âhashâ, âinitâ, âinit_subclassâ, âleâ, âltâ, âmoduleâ, âneâ, ânewâ, âreduceâ, âreduce_exâ, âreprâ, âsetattrâ, âsizeofâ, âstrâ, âsubclasshookâ, âweakrefâ, â_appâ, â_configâ, â_listenersâ, â_port_pathâ, â_skip_bootloaderâ, â_sync_request_lockâ, â_uartâ, â_unhandled_commandâ, â_znp_configâ, âcallback_for_responseâ, âcallback_for_responsesâ, âcapabilitiesâ, âcapture_responsesâ, âcloseâ, âconnectâ, âconnection_lostâ, âconnection_madeâ, âdetect_zstack_versionâ, âframe_receivedâ, âload_network_infoâ, ânetwork_infoâ, ânode_infoâ, ânvramâ, âremove_listenerâ, ârequestâ, ârequest_callback_rspâ, âresetâ, âset_applicationâ, âversionâ, âwait_for_responseâ, âwait_for_responsesâ, âwrite_network_infoâ]
2022-01-08 09:27:34 INFO (MainThread) [custom_components.zha_custom.znp] Write done, call pre_shutdown(). Restart the device/HA after this.
2022-01-08 09:27:34 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall zha_custom.execute (c:6d70b0fa91d29d99c0be404ce7905b91): command=znp_restore>
Traceback (most recent call last):
File â/usr/src/homeassistant/homeassistant/core.pyâ, line 1511, in catch_exceptions
await coro_or_task
File â/usr/src/homeassistant/homeassistant/core.pyâ, line 1530, in _execute_service
await handler.job.target(service_call)
File â/config/custom_components/zha_custom/init.pyâ, line 73, in custom_service
await handler(
File â/config/custom_components/zha_custom/znp.pyâ, line 109, in znp_restore
await app._znp.pre_shutdown()
AttributeError: âZNPâ object has no attribute âpre_shutdownâ
After the network restore, the following devices came back online immediately
1/4 sengled A19 RGB bulbs
1/1 Ikea Signal Repeater
1/1 Smart Outlet
After waiting about 5 minutes, the rest of the sengled bulbs came back online!
Conclusion: Deletion of the ZHA integration and Zigbee.db is not needed AND a power cycle of mains powered devices is not necessary (I dont have any battery powered devices to test with but I assume those would rejoin if you wake them manually). See procedure below:
The procedure should be the following (follow âaâ steps if migrating to a new coordinator):
- Backup using the
znp_backup
command in the zha_custom
service. Verify that the nwk_backup.json
file is generated in the local
directory
- Remove the original coordinator from your system. Insert the new Coordinator.
2a) Remove the ZHA Integration from Home Assistant (only needed for migrating to a new coordinator with a different serial path; the alternative is to modify HAâs config file directly to update the current integrationâs serial path and baudrate)
2b) Rename/Move the zigbee.db file (should not be needed. If this is done then the restore will not remember entity names)
- Restart Home Assistant
3a) Add the ZHA Integration to Home Assistant (needed if you removed it)
- Restore using the
znp_restore
command (If you used a custom file name for the backup then make sure you name it back to nwk_backup.json
)
- Check the logs (currently the
pre_shutdown
call failed for the first successful test, but that is not critical)
- Restart HA
- Check that everything is ok
NOTES:
- Devices may take a while to rejoin the network as the Zigbee specification requires them to âback-offâ in case of communication problems
- You may speed up the process by power cycling devices
- Devices may not be instantly responsive due to the zigbee mesh needing to be recreated