zigpy / zigpy-cli

Command line interface for zigpy
GNU General Public License v3.0
44 stars 12 forks source link

Implement new radio API #2

Closed puddly closed 2 years ago

puddly commented 2 years ago

This change introduces a network backup/restore utility for any adapter implementing the new radio API:

The following adapters also implement the new radio API but their firmware does not allow much network information to be read, making this form of migration impossible:


Instructions

You'll need access to a Python environment. zigpy-znp has documentation that describes how to do this for every common platform.

# Make a new venv, these packages are heavily modified
virtualenv -p 3 venv  # Python 3.7 or above is required
# Or python3 -m venv venv (if `virtualenv` isn't installed)
source venv/bin/activate

# Install HA OS packages (only if using HA OS)
apk add gcc musl-dev libffi-dev

# Install zigpy-cli
pip install git+https://github.com/zigpy/zigpy-cli.git

# Back up the old radio.      Note: this backup format will change in the future.

# Conbee/Raspbee
zigpy -vv radio deconz /dev/serial/by-id/... backup deconz.json

# CC2531, CC2652, etc.
# zigpy -vv radio znp /dev/serial/by-id/... backup znp.json

# HUSBZB-1, EFR32, etc.
# zigpy -vv radio ezsp /dev/serial/by-id/... backup ezsp.json

# Restore a backup to the new one
zigpy -vv radio znp /dev/serial/by-id/... restore deconz.json
# zigpy -vv radio ezsp /dev/serial/by-id/... restore deconz.json
# zigpy -vv radio deconz /dev/serial/by-id/... restore deconz.json

# Leave the virtualenv
deactivate

Once that's done, edit /config/.storage/core.config_entries (take a backup of the file first!) and change the coordinator's path to the new radio's /dev/serial/by-id/... path. If you're switching to a CC2652, make sure to delete the flow_control key and set the baudrate to 115200.

mattague commented 2 years ago

I'm not entirely sure what might have gone wrong, but I can't seem to get this owrking. I am running in a virtual environment, but I can not get the commands to work. After running pip install... I get the following error at the end:

Successfully built zigpy zigpy-cli zigpy-znp zigpy-deconz bellows pure_pcapy3 scapy pyrsistent Failed to build aiohttp pycryptodome frozenlist multidict yarl ERROR: Could not build wheels for aiohttp, frozenlist, multidict, yarl, which is required to install pyproject.toml-based projects

And then trying to run zigpy -vv radio znp /dev/ttyACM0 backup znp.json gets me bash: zigpy: command not found.

Edit:

I did not get this working on my raspberry pi running Home assistant OS but I tried from another linux machine and it worked flawlessly, Thank you very much for the instructions.

p71-yes commented 2 years ago

great work @puddly !!! huge thanks..

Once installed, it was a smooth move from deconz to a sonoff zigbee stick...

hcrohland commented 2 years ago

Just migrated from a raspbee to a conbee without problems

francodutch commented 2 years ago

great work @puddly !!! huge thanks..

Once installed, it was a smooth move from deconz to a sonoff zigbee stick...

I need to do the same/similar - raspbi on ZHA to sonoff dongle on ZHA. I've read through the chain but if you're interested we could do a clean procedure and test it for others to use?

Hedda commented 2 years ago

Originally posted by @pipiche38 in https://github.com/zigpy/zigpy-zigate/issues/117#issuecomment-1109583647

@puddly , I found that https://github.com/fairecasoimeme/ZiGate/blob/5a64452e3cc4f32afe217a332d0c9b1d97e17d84/ModuleRadio/Firmware/src/ZiGate/Source/ZigbeeNodeControlBridge/app_start.c#L1191 which can be interested for you as regards to a Backup/Restore solution. If we take in consideration this procedure is used when the PDM size is changed during a firmware upgrade, we might think that can be used for Backup and then Restore.

@doudz Do you have any input in regards to achieving ZiGate Zigbee network backup via this network backup/restore utility?

thefjordkeeper commented 2 years ago

@puddly - I'm fairly certain this worked okay for me on Ubuntu 22.04 but I am unable to locate the ezsp.json file. Where is that saved? I'm not moving from one Coordinator to another, I just flashed a spare Sonoff EFR32MG21 dongle with the latest firmware in an attempt to iron out some Zigbee network behavior. I want to verify that the backup actually exists, it's a sickness that comes from working in IS.

Thank you!

Hedda commented 2 years ago

@puddly - I'm fairly certain this worked okay for me on Ubuntu 22.04 but I am unable to locate the ezsp.json file. Where is that saved? I'm not moving from one Coordinator to another, I just flashed a spare Sonoff EFR32MG21 dongle with the latest firmware in an attempt to iron out some Zigbee network behavior. I want to verify that the backup actually exists, it's a sickness that comes from working in IS.

Suggest that now that this is merged (i.e. closed as merged) maybe instead post any additional questions as new issues https://github.com/zigpy/zigpy-cli/issues or discussions https://github.com/zigpy/zigpy-cli/discussions or ?

balucanb commented 1 year ago

@puddly If this is obvious sorry, I do not really understand yet how to use this tool but my question is this- I want to move my Zigbee2Mqtt network currently on Rpi4 w/ Sonoff 3.0 dongle to a a Home assistant Yellow and keep it on Z2M is that possible with this tool ( or any other way) Thanks

asriva13 commented 1 year ago

Hi, I am trying to move from conbee2 to sonoff. While executing the backup command I am getting a timeout error (attached in the png file). Any help or directions would be appreciated. error

Hedda commented 1 year ago

@asriva13 Have you first upgraded to the latest deconz firmware on your ConBee/RaspBee adapter?

For procedure step reference see example(s):

1. In the deCONZ app, under Settings > Gateway, check the firmware version. It should be version 26720700 or newer.

2. If the version is not up-to-date, select Update to 26720700.

Also see: