"Zzh!" (short for "Zig-a-zig-ah!") open-source hardware licensed Zigbee USB-stick based on TI CC2652R

I get the following response:

PS D:\> python -m zigpy_znp.tools.nvram_read -p COM3 -o backup.json
usage: nvram_read.py [-h] [-v] [--output OUTPUT] serial
nvram_read.py: error: unrecognized arguments: -p

When trying the docker route I also get an error (running Docker on Win10)

PS D:\> docker run --rm -v.:/opt/firmware/backup --device=/dev/ttyACM0:/dev/ttyACM0 -it walthowd/znp-firmware bash
docker: Error response from daemon: create .: volume name is too short, names should be at least two alphanumeric characters.
See 'docker run --help'.

Tried some combinations with -p COM3 but non of them seem to work.

*edit
While playing around with the settings I seem to be getting something

PS D:\> python -m zigpy_znp.tools.nvram_read -v COM3 -o backup.json
2021-02-23 21:21:54 pcmark zigpy_znp.uart[18320] DEBUG Connecting to COM3 at 115200 baud
2021-02-23 21:21:54 pcmark zigpy_znp.uart[18320] DEBUG Opened COM3 serial port
2021-02-23 21:21:54 pcmark zigpy_znp.uart[18320] DEBUG Toggling RTS/CTS to skip CC2652R bootloader
2021-02-23 21:21:55 pcmark zigpy_znp.uart[18320] DEBUG Connected to COM3 at 115200 baud
2021-02-23 21:21:55 pcmark zigpy_znp.api[18320] DEBUG Waiting 1s before sending anything
2021-02-23 21:21:56 pcmark zigpy_znp.api[18320] DEBUG Sending bootloader skip byte
2021-02-23 21:21:56 pcmark zigpy_znp.api[18320] DEBUG Waiting 1s or until a reset indication is received
2021-02-23 21:21:57 pcmark zigpy_znp.api[18320] DEBUG Testing connection to COM3
2021-02-23 21:21:57 pcmark zigpy_znp.api[18320] DEBUG Sending request: SYS.Version.Req()
2021-02-23 21:22:12 pcmark zigpy_znp.api[18320] DEBUG Connection to COM3 failed, cleaning up
Traceback (most recent call last):
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\api.py", line 507, in request
    response = await response_future
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\tools\nvram_read.py", line 95, in <module>
    asyncio.run(main(sys.argv[1:]))  # pragma: no cover
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\tools\nvram_read.py", line 90, in main
    obj = await backup(args.serial)
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\tools\nvram_read.py", line 18, in backup
    await znp.connect()
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\api.py", line 234, in connect
    self._version = await self.request(c.SYS.Version.Req())
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\api.py", line 507, in request
    response = await response_future
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\async_timeout\__init__.py", line 55, in __aexit__
    self._do_exit(exc_type)
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\async_timeout\__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
PS D:\>
1 Like

I think you were / are pretty close. Try without pressing / holding the BSL button on the board while plugging the device into the host.

Tried it without pressing the BSL button but it gave me the same result. Tried another USB-port (COM4) but also no change there.

Also getting an error if I’m trying to run the Energy scan.

D:\>python -m zigpy_znp.tools.energy_scan -v COM4
2021-02-25 22:31:23 pcmark __main__[17788] INFO Starting up zigpy-znp
2021-02-25 22:31:23 pcmark zigpy_znp.uart[17788] DEBUG Connecting to COM4 at 115200 baud
2021-02-25 22:31:23 pcmark zigpy_znp.uart[17788] DEBUG Opened COM4 serial port
2021-02-25 22:31:23 pcmark zigpy_znp.uart[17788] DEBUG Toggling RTS/CTS to skip CC2652R bootloader
2021-02-25 22:31:23 pcmark zigpy_znp.uart[17788] DEBUG Connected to COM4 at 115200 baud
2021-02-25 22:31:23 pcmark zigpy_znp.api[17788] DEBUG Waiting 1s before sending anything
2021-02-25 22:31:24 pcmark zigpy_znp.api[17788] DEBUG Sending bootloader skip byte
2021-02-25 22:31:24 pcmark zigpy_znp.api[17788] DEBUG Waiting 1s or until a reset indication is received
2021-02-25 22:31:25 pcmark zigpy_znp.api[17788] DEBUG Testing connection to COM4
2021-02-25 22:31:25 pcmark zigpy_znp.api[17788] DEBUG Sending request: SYS.Version.Req()
2021-02-25 22:31:40 pcmark zigpy_znp.api[17788] DEBUG Connection to COM4 failed, cleaning up
2021-02-25 22:31:40 pcmark zigpy.application[17788] ERROR Couldn't start application
Traceback (most recent call last):
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\api.py", line 507, in request
    response = await response_future
asyncio.exceptions.CancelledError

Finally some success! Tried the same commands in Git Bash and everything seems to work! :smiley:

$ python -m zigpy_znp.tools.nvram_read -v COM4 -o backup.json
2021-02-25 23:12:36 pcmark zigpy_znp.uart[11188] DEBUG Connecting to COM4 at 115200 baud
2021-02-25 23:12:36 pcmark zigpy_znp.uart[11188] DEBUG Opened COM4 serial port
2021-02-25 23:12:36 pcmark zigpy_znp.uart[11188] DEBUG Toggling RTS/CTS to skip CC2652R bootloader
2021-02-25 23:12:36 pcmark zigpy_znp.uart[11188] DEBUG Connected to COM4 at 115200 baud
2021-02-25 23:12:36 pcmark zigpy_znp.api[11188] DEBUG Waiting 1s before sending anything
2021-02-25 23:12:37 pcmark zigpy_znp.api[11188] DEBUG Sending bootloader skip byte
2021-02-25 23:12:37 pcmark zigpy_znp.api[11188] DEBUG Waiting 1s or until a reset indication is received
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Testing connection to COM4
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Sending request: SYS.Ping.Req()
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Received command: SYS.Ping.Rsp(Capabilities=<MTCapabilities.CAP_APP_CNF|CAP_GP|CAP_UTIL|CAP_ZDO|CAP_AF|CAP_SYS: 1625>)
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Sending request: SYS.NVLength.Req(SysId=<NvSysIds.ZSTACK: 1>, ItemId=<ExNvIds.TCLK_TABLE: 4>, SubId=0)
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Received command: SYS.NVLength.Rsp(Length=20)
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Sending request: SYS.NVRead.Req(SysId=<NvSysIds.ZSTACK: 1>, ItemId=<ExNvIds.TCLK_TABLE: 4>, SubId=0, Offset=0, Length=20)
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Received command: SYS.NVRead.Rsp(Status=<Status.SUCCESS: 0>, Value=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\x00\x00\x00')
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Detected Z-Stack 3.3
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Connected to COM4 at 115200 baud

Did a succesfull NVRAM backup, erased the device firmware, flashed the new firmware and restored the NVRAM backup! Connected the stick to home assistant again and boom, all the devices came back online! :smiley: :ok_hand:

Thank you @Hedda & @balu79 for your support!

3 Likes

FYI, there is a bug in pyserial-asyncio v0.5 release for Windows so need to use pyserial-asyncio v0.4

zigpy-znp is installed via pip should automatically use pyserial-asyncio v0.4 (as it has blacklisted v0.5).

I’ve ordered the CC2652R and should arrived in a few weeks. I will be upgrading from CC2531 to CC2652. I have read through the whole post and did not find a solid how to steps. These are the steps I will be doing. Is this more or less ok? I have 15 devices total connected to HA.

Steps:
shutdown zigbee2mqtt
change the pan_id to a different number
change permit_join to true
Reboot HA
make sure zigbee2mqtt is running
pair each devices one by one

Questions:
Do I need to delete all the devices in mqtt integrations prior to repairing?
I was using Channel 11. Is there a better channel # I should use or it is base on my surrounds to find the best channel?
The port path will still be the same if I use the exact usb port of CC2531? Currently /dev/ttyACM0
During the pairing process, will the friendly name be the same and any automations setup using the devices will work once again?

Your other option is to use this guide to back up your CC2531’s network and restore that to the new stick.

Then you won’t have to change anything else, or re-pair your devices.

1 Like

Ok. I have installed zigpy-znp on a separate rpi. Do I use this cmd to backup the file? What port do I use?

python -m zigpy_znp.tools.network_backup socket://192.168.1.123:4567

You need to run the commands on the computer the device is connected to.

Thanks was searching for a guide like that, but couldn’t find it from google earlier this week.

However when running Home Assistant (OS) it wasn’t that straight forward for me. As Home Assistant OS is missing the buildtools the installing of pycryptodome package will fail. After a lot of Googling and trying it turns out you need to issue to following command first:
apk add alpine-sdk

Then the default buildtools will be available pip can do the job. It is really great to be able to backup your network and migrate easily. Many thanks to everyone who invested their time and effort into it!

And you should use python3 instead of python in the example commands.

Another lesson learned: as you need exclusive access to the stick you need to stop ha core (ha core stop) before taking the backup.

Well, they’re not my guides, and hopefully you only have Python 3.x installed :man_shrugging:

@Tinkerer was not meant as criticism or anything, just a heads up for anyone trying to follow the guides when they are Home Assistant OS. Glad you shared the guide :slight_smile:

I guess I have to use python3 as that was chosen in the migration path from Python 2 in HA OS or something, no real clue about it. I have come across it more often (same a with pip and pip3 sometimes), but just to warn people who haven’t seen it before as it might be difficult to find out what is wrong.

I’ve tried to setup via another RPI having a fresh install of HA Supervised over Debian 10, but failed on backing up the network file. Backing up the nvram file works, however. So I tried the Windows 10 setup with success.

Windows 10 Setup (Guide Ref.)
This is the steps I took for anyone who have trouble.

-Download and install Python Windows Installer(64-bit) . Latest as of today is 3.9.5
-Open Windows CMD on pc for the following steps.

Press win Key + r key
Type cmd
cd Downloads

-Create a virtualenv before installing the zigpy-znp by running these line one at a time in windows cmd.

py -3 -m venv venv
venv\Scripts\activate.bat

-Install zigpy-znp for windows

pip install https://github.com/zigpy/zigpy-znp/archive/dev.tar.gz

-Plug in your CC2531 or the like usb stick into your pc usb port.
Note: CC2652 will need to install this driver for windows to be able to recognize the COM Port

-Navigate to device manager to find the COM Port #.

press win key
type 'device manager'

-Backup network. The saved file will be under Downloads folder
Note: change the COM5 to whatever yours is

py -m zigpy_znp.tools.network_backup COM5 -o network.json

Do you run it with hassio? or by chance are you using HA with docker. I am facing some difficulties setting the system up.

Straight Hassos image onto an SD card on my Pi4. Have since switched over to ZHA. What issues are you seeing?

I am able to use the zzh! with hassos directly, however I am interested in the HA with docker and when I try to install the supervised HA version using docker I got stuck and the installation fails every time I try, the ssh connection is suddenly rejected.

If you’re looking for help with the Supervised installer then:

  1. You should start a fresh thread
  2. The Supervised installer is for experts in Docker, Linux, and networking only

I ordered about 10 days ago and set it up last weekend. I am using it with Zigbee2mqtt. It was painless to get up-and-running. I followed the instructions step-by-step and everything worked first time. I haven’t stressed it much but added some Ikea motion sensors without issue.

I run HA on an N2+ box and have the stick plugged directly into a USB port. The range seems ok and is covering three floors of the house so far without an issue.

I also get ‘Device offline’. How do I get it to go online?

I have verified it has been flashed correctly.

1 Like

A post was merged into an existing topic: Do NOT Buy Slaesh’s Zigbee Stick

Also have a device thats showing as offline, did you solve this?