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.