Koenkk / zigbee-herdsman

A Node.js Zigbee library
MIT License
456 stars 277 forks source link

Z-Stack 1.2 Backup & Restore #395

Closed castorw closed 2 years ago

castorw commented 2 years ago

Tis PR adds ability to backup Z-Stack 1.2 adapters and restore them on newer Z-Stack versions:

Addressing https://github.com/Koenkk/zigbee2mqtt/issues/6714.

friebi commented 2 years ago

Awesome work! Is there somewhere a howto convert from an existing CC2531 coordinator to e.g. slea.sh's CC2652RB?

friebi commented 2 years ago

Found it myself thanks to the Discord channel and it worked!! :1st_place_medal: :partying_face: :sunglasses: :trophy: You need a Python installation with this: zigpy-znp and then check here for steps: backup-and-restore (don't get confused by the NVM backup & restore in the next section - this only works for adapters which are physically the same!)

castorw commented 2 years ago

@friebi You basically don't need to do anything. Properly shutdown z2m, remove the stick, put in the new stick (freshly erased and flashed) and start z2m. The backup should be restored onto new stick.

friebi commented 2 years ago

@castorw Thanks for the answer! So that means the above process is already part of z2m startup if it detects a new coordinator (change the serial port in configuration.yaml of course)? Awesome!

castorw commented 2 years ago

@Koenkk Is this PR already in latest z2m? Could you please instruct @friebi ? Thanks.

friebi commented 2 years ago

@castorw sorry if I was confusing. Yes, it is part of the latest z2m releases and that's why it got my attention. Everything is fine and I got it working as described here. Now I'm just amazed that you seem to have it integrated into the startup process of z2m without any manual steps necessary. Nvm it works perfect and I'm very happy! Thank you so much

Koenkk commented 2 years ago

I can confirm this is in 1.21.0 indeed (see changelog: https://github.com/Koenkk/zigbee2mqtt/releases/tag/1.21.0)

ykcheow commented 2 years ago

Hi, I'm upgrading the my cc2531 to cc2652p stick. My zigbee2mqtt is the latest version. I follow the instructions from @castorw, but my zigbee devices doesn't seem to join back. The zigbee2mqtt is able to start and I did change the USB path in the configuration but I didn't change the pan_id. The pan_id was 6754. So, do I have to change the pan_id actually when upgrading the stick?

friebi commented 2 years ago

@ykcheow I did not change the pan_id and as far as I understood you'll definitely have to repair all your devices if you do. Maybe try backing up your network from the old stick and restore it to the new one manually as described above?

ykcheow commented 2 years ago

@friebi As I understand from the latest zigbee2mqtt release of v1.21.0, we don't have to re-pair all the devices if we are changing the cc2531(firmware not the latest) to cc2652p (with latest firmware).

I'm confused with pan_id changes.

friebi commented 2 years ago

I didn't have to repair all devices and I didn't change the pan_id. All I did was a manual backup and restore of the network, changing the serial port in the configuration and it worked.

ykcheow commented 2 years ago

I have tested the new CC2652p stick at another HA which is dev. environment and it appears the stick is working good. I can pair motion sensor and the sensor is reporting the state correctly. So the new hardware is not a problem. @castorw May I know how long do we need to wait for the devices to rejoin back to the new stick after swapping? Also, can you confirm we don't need to change pan_id when changing CC2531 to CC2652p? When I putting back the old stick, all the devices joined instantly. @Koenkk Can you please shred some light also?

Here are some additional info,

Thanks in advance.

Koenkk commented 2 years ago

What do you see in the log when controlling devices after migrating to the CC2652p ? If you see errors like No network route (205) when try removing some routers from power and controlling them aftewards.

ykcheow commented 2 years ago

I can confirm the zigbee2mqtt v1.21.0 can migrate from cc2531 to cc2652p with the need of re-pairing all the devices.

My problem is on the my HA RPi that's running with SSD. I suspect the USB does not have enough power for the cc2652p stick and causing the issue. And I still have no solution yet.

I've verified the stick is actually working at another dev HA RPi which is running with SD card.

Koenkk commented 2 years ago

My problem is on the my HA RPi that's running with SSD. I suspect the USB does not have enough power for the cc2652p stick and causing the issue. And I still have no solution yet.

Common problem, try connecting the SSD or stick through a powered usb hub

marcgarciamarti commented 2 years ago

Hi there @castorw Could you or anybody confirm whether zigbee 3.0 will be supported when running 1.21 on a CC2531 without the need of repairing thanks to this PR? Does one need to do any manual step? Any place I can read up what the instructions are? Thanks!

maiflaii commented 2 years ago

Hi,I only change the port and all devices are working but when try parking news devices,the log dont show nothing and no paring

maxime1992 commented 1 year ago

Hey guys, I just tried to flash my sonoff coordinator to latest version as I was one behind. I had understood that everything was supposed to be automatic now so I just flashed the new version. Except that when I start z2m I don't have any device now :sweat_smile: ... I'm sweating a bit with 80 devices I've got, including some in my walls (for controlling the lights). It'd be massively painful to repair everything...

I guess I should've gone with the safe way of doing a backup first, rookie mistake :man_facepalming: Any hope I can get it to work fine as before knowing that I do have my file configuration.yaml, coordinator_backup.json, database.db and state.json or should I just start repairing all of them :confused: ?

reneklootwijk commented 1 year ago

I experienced multiple times, after a power failure, the database was empty. By restoring a backup of the database I almost always were able to recovery all devices.

maxime1992 commented 1 year ago

Hey thanks for the answer @reneklootwijk. I've got it working by doing just that but I had an unfortunate queue of events that nearly put me down with no working backups :sweat: ... Anyway I've opened an issue here: https://github.com/Koenkk/zigbee2mqtt/issues/15868#issuecomment-1368544234 if you want to follow along as I think even though having backups is important, having the DB being dropped is a real issue

reneklootwijk commented 1 year ago

https://github.com/Koenkk/zigbee2mqtt/issues/11759 is related