New add-on for running zigpy-cli commands (Like Energy Scans)

I’ve created a new addon - TubesZB Zigpy-CLI Tools to run some of the zigpy-cli commands for anyone not comfortable with the command line and python. Or anyone just lazy :wink:

You’ll need to stop Zigbee2MQTT or ZHA before running the addon as only one thing can talk to the radio at a time.

It supports usb and network coordinators

Currently the addon supports the following commands from zigpy-cli

  • info - Reads the current network informationf from the radio

  • energy-scan - Runs an environmental RF Energy Scan to assist with identifying the best channel

  • form - create a network on a new coordinator

  • reset - Reset a coordinator - removing it’s network configuration

Happy to take feed back or the docs/experience with this.

Thanks!

2 Likes

Awesome!

For reference, if comfortable with using the command line then also check out zha-toolkit by @le_top

FYI, a benefit with mdeweerd’s “ZHA Toolkit” is that you do not need to stop the ZHA integration to use it, (and advanced users can optionally also build reusable automation blueprints that others to also reuse).

Thanks @Hedda The ZHA Tool Kit is good for advanced ZHA users. this addon is intended more for troubleshooting, and assisting users not comfortable with the command line.

version 0.2.2 adds backup and restore functions too.

1 Like

Wow thanks @tube0013 !

Is it also possible to reset a SONOFF Zigbee Dongle Plus (P-Model) using the Router Firmware?
I am searching for a solution described in the following thread but I don’t know how…

Thanks a lot in advance!

Best,
Dominik

Note that resetting a Zigbee Coordinator does not change its unique IEEE address, and to need to write a new unique IEEE address with a flasher tool if re-purposing a previously used Zigbee Coordinator as a Zigbee Router so do not get two devices on the Zigbee network with same IEEE address. All devices on the same Zigbee network need to have unique IEEE addresses, see my reply in your other thread:

Hello!!!

I download it and try but have some problems.
Conbee2 as adapter

I config the conbee adapter, the radio type as deconz, and the backup file name. But when i push save i got this error:

No se pudo guardar la configuración del complemento, Missing required option 'network_device' in TubesZB Zigpy-CLI Tools (d0f5a498_tzb-zigpy-cli-tools). Got {'network_device': None, 'device': '/dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2463707-if00', 'device_type': False, 'action': None, 'radio_type': 'deconz', 'baudrate': '115200', 'backup_filename': 'backup_zigbee.js'}

zigbee2mqtt is stoped, and works as addon of haos

Make sure the “use network device” toggle is turned off, but still enter something in the “Network Device” field.

I just entered a “0”.

thanks!!!
exact this was the error, I put “0” in network device and runs.
either the “use network device” is turned off.

i receive a warning in the logs but aparently works fine

I am struggling to follow the instructions and I do not know where my mistake is.

  1. I quit z2mqtt.

  2. I open the TubesZB Zigpy-CLI Tools config

  3. I choose my conbee2 from the list

  4. I enter my HomeAssistantIP to fill the blank

  5. I chose deconz as radio type.

  6. I left the baudrate at 115200

  7. I chose “backup”

  8. I entered the file name “conbee_II”

  9. I unplugged the conbee2 and plugged in the conbee3

  10. I rebootet my mini computer running HA

  11. I ran the TubesZB Zigpy-CLI Tools restore option on my conbee 3 (new file path).

  12. I quit the add on.

  13. I start z2mqtt with the new device path, specific to the conbee 3

  14. z2mqtt is stuck in a loop where all it shows in the logs is 3 lines, each with “starting…” in green writing.

I am assuming it cannot recognize the conbee3 but I do not know what else to do. Can anyone help me out here?
Thanks!

I thought I read somewhere the conbee3 is based on an efr32 chip, does ezsp work with it?

Unfortunately I get an error in the following scenario:

  • I backup my conbee 2 choosing deconz as radio type.
  • I insert my conbee 3 and reboot the computer.
  • I choose restore with “ezsp” from the save file

I appreciate the help!

Does anyone else have any idea?

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service banner: starting

-----------------------------------------------------------
 Add-on: TubesZB Zigpy-CLI Tools
 TubesZB Zigpy-CLI Toolsadd-on
-----------------------------------------------------------
 Add-on version: 0.2.2
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.5  (amd64 / generic-x86-64)
 Home Assistant Core: 2024.2.1
 Home Assistant Supervisor: 2024.01.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service banner successfully started
s6-rc: info: service zigpy-cli: starting
[17:42:00] INFO: Directoty Exists
[17:42:01] INFO: Running zigpy - restore on /dev/ttyUSB0 to /config/tzb-zigpy-cli-tools/conbee_II
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/bellows/uart.py", line 262, in reset
    return await self._reset_future
           ^^^^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/zigpy", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 45, in new_func
    return f(get_current_context().obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy_cli/cli.py", line 20, in inner
    return loop.run_until_complete(cmd(*args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy_cli/radio.py", line 143, in restore
    await app.connect()
  File "/usr/local/lib/python3.11/site-packages/bellows/zigbee/application.py", line 148, in connect
    await ezsp.startup_reset()
  File "/usr/local/lib/python3.11/site-packages/bellows/ezsp/__init__.py", line 125, in startup_reset
    await self.reset()
  File "/usr/local/lib/python3.11/site-packages/bellows/ezsp/__init__.py", line 151, in reset
    await self._gw.reset()
  File "/usr/local/lib/python3.11/site-packages/bellows/uart.py", line 261, in reset
    async with asyncio_timeout(RESET_TIMEOUT):
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError
[17:42:07] INFO: zigpy-cli-up script exited with code 1
s6-rc: warning: unable to start service zigpy-cli: command exited 1
s6-rc: info: service banner: stopping
/run/s6/basedir/scripts/rc.init: warning: s6-rc failed to properly bring all the services up! Check your logs (in /run/uncaught-logs/current if you have in-container logging) for more information.
/run/s6/basedir/scripts/rc.init: fatal: stopping the container.
s6-rc: info: service banner successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

This is the message I get when using “deconz” as radio type. It also seems to not work properly:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service banner: starting
-----------------------------------------------------------

 Add-on: TubesZB Zigpy-CLI Tools
 TubesZB Zigpy-CLI Toolsadd-on
-----------------------------------------------------------
 Add-on version: 0.2.2
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.5  (amd64 / generic-x86-64)
 Home Assistant Core: 2024.2.1
 Home Assistant Supervisor: 2024.01.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service banner successfully started
s6-rc: info: service zigpy-cli: starting
[17:45:41] INFO: Directoty Exists
[17:45:41] INFO: Running zigpy - restore on /dev/ttyUSB0 to /config/tzb-zigpy-cli-tools/conbee_II
2024-02-12 17:45:42.650 d0f5a498-tzb-zigpy-cli-tools zigpy.application WARNING Unknown device AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xD905)
2024-02-12 17:45:42.681 d0f5a498-tzb-zigpy-cli-tools zigpy_deconz.zigbee.application WARNING Unexpected transmit confirm for request id 22, Status: TXStatus.SUCCESS
2024-02-12 17:45:42.745 d0f5a498-tzb-zigpy-cli-tools zigpy_deconz.zigbee.application WARNING Unexpected transmit confirm for request id 23, Status: TXStatus.SUCCESS
2024-02-12 17:45:42.809 d0f5a498-tzb-zigpy-cli-tools zigpy_deconz.zigbee.application WARNING Unexpected transmit confirm for request id 24, Status: TXStatus.SUCCESS
2024-02-12 17:45:42.873 d0f5a498-tzb-zigpy-cli-tools zigpy_deconz.zigbee.application WARNING Unexpected transmit confirm for request id 25, Status: TXStatus.SUCCESS
2024-02-12 17:45:42.937 d0f5a498-tzb-zigpy-cli-tools zigpy_deconz.zigbee.application WARNING Unexpected transmit confirm for request id 26, Status: TXStatus.SUCCESS
2024-02-12 17:45:43.001 d0f5a498-tzb-zigpy-cli-tools zigpy_deconz.zigbee.application WARNING Unexpected transmit confirm for request id 28, Status: TXStatus.SUCCESS
2024-02-12 17:45:43.065 d0f5a498-tzb-zigpy-cli-tools asyncio ERROR Task exception was never retrieved
future: <Task finished name='discover_unknown_device_from_packet-nwk=0xD905' coro=<ControllerApplication._discover_unknown_device() done, defined at /usr/local/lib/python3.11/site-packages/zigpy/application.py:942> exception=DeliveryError("Failed to enqueue packet: CommandError('<CommandId.aps_data_request: 18>, status: <Status.NO_NETWORK: 6>')")>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/zigpy_deconz/zigbee/application.py", line 508, in send_packet
    await self._api.aps_data_request(
  File "/usr/local/lib/python3.11/site-packages/zigpy_deconz/api.py", line 871, in aps_data_request
    rsp = await self.send_command(
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy_deconz/api.py", line 508, in send_command
    return await self._command(cmd, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy_deconz/api.py", line 586, in _command
    return await fut
           ^^^^^^^^^
zigpy_deconz.exception.CommandError: <CommandId.aps_data_request: 18>, status: <Status.NO_NETWORK: 6>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/zigpy/application.py", line 945, in _discover_unknown_device
    return await zigpy.zdo.broadcast(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/device.py", line 623, in broadcast
    return await app.broadcast(
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/application.py", line 921, in broadcast
    await self.send_packet(
  File "/usr/local/lib/python3.11/site-packages/zigpy_deconz/zigbee/application.py", line 522, in send_packet
    raise zigpy.exceptions.DeliveryError(
zigpy.exceptions.DeliveryError: Failed to enqueue packet: CommandError('<CommandId.aps_data_request: 18>, status: <Status.NO_NETWORK: 6>')
2024-02-12 17:45:46.168 d0f5a498-tzb-zigpy-cli-tools zigpy_deconz.zigbee.application WARNING Unexpected transmit confirm for request id 30, Status: TXStatus.SUCCESS
[17:45:46] INFO: Action Complete
[17:45:46] INFO: zigpy-cli-up script exited with code 0
s6-rc: info: service zigpy-cli successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service zigpy-cli: stopping
s6-rc: info: service zigpy-cli successfully stopped
s6-rc: info: service banner: stopping
s6-rc: info: service banner successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

No they are using a custom firmware with their own proprietary deconz serial protocol interface, same as ConBee II and Raspbee II, see:

zigpy-cli should bowever have the same compatible with ConBee III as with ConBee II via the zigpy-deconz radio library.

Must be missing something. Installed zigpy-cli some time ago … not even sure how long ago. Used it back then to check channel traffic/clutter.

Was recently informed (by HA) of an upgrade. Upgraded, now at 0.3.0.0.

Decided I needed to use it again. SSH in to the HA server. Type zigpy. Get

-bash: zigpy: command not found

Huh? What am I not doing now that I did do back then?

Thanks for any thoughts.

@tube0013 FYI, puddly who is one of the lead developers of zha and zigpy is working in adding a new “Advanced energy scan” feature/function to zigpy-cli (command line interface for zigpy radios used by zha) as well as “implement a standard interface for network scanning” for zigpy. Maybe you could look into creating frontend interface for that to make it more accessible to all users? See:

and

Also see related development discussion here:

As well as these for Silicon Labs EmberZNet EZSP and Texas Instruments Z-Stack ZNP zigpy radios respectively:

I’m aware no need to post here, it will be ready when it is ready. I watch the zigpy repositories closely and am in contact with puddly and dmulcahey.

Hi!

Sorry if that is a “dumb” question, but I just found this post and wondered if it’s possible to migrate my zigbee2mqtt devices from Conbee 2 to Sonoff ZBDongle-E using zigpy-cli or do I have to re-pair all devices step by step?

Thanks for the help.

Give it a shot, backup the conbee and restore the -e and update the z2m config to use ember… just make sure you update the sonoff -e to a 7.4.x firmware build.