Coder Social home page Coder Social logo

zigpy-cli's Introduction

zigpy-cli

A unified command line interface for zigpy radios. The goal of this project is to allow low-level network management from an intuitive command line interface and to group useful Zigbee tools into a single binary.

Installation

$ pip install zigpy-cli

Usage

$ zigpy --help
Usage: zigpy [OPTIONS] COMMAND [ARGS]...

Options:
  -v, --verbose
  --help         Show this message and exit.

Commands:
  ota
  radio
  pcap

Make sure ZHA, Zigbee2MQTT, deCONZ, etc. are disabled. Any software controlling your radio requires exclusive access to the hardware: if both are running at once, neither will work.

Network commands

Network commands require the radio type to be specified. See zigpy radio --help for the list of supported types. If your radio requires a different baudrate than the radio library default (mainly EZSP), you must specify it as a command line option. For example, zigpy radio --baudrate 115200 ezsp backup -.

Network backup

$ zigpy radio deconz /dev/ttyUSB0 backup deconz-backup.json

Network restore

$ zigpy radio znp /dev/ttyUSB1 restore deconz-backup.json

Reading network information

$ zigpy radio znp /dev/ttyUSB0 info
PAN ID:                0x718B
Extended PAN ID:       33:29:33:5e:30:42:64:48
Channel:               15
Channel mask:          [15]
NWK update ID:         0
Device IEEE:           00:12:4b:00:1c:ce:33:85
Device NWK:            0x0000
Network key:           cc:44:a6:4e:23:82:30:9e:35:0f:c6:6a:89:c8:dd:7d
Network key sequence:  0

Forming a network

$ zigpy -vvvv radio znp /dev/cu.usb* form
2021-07-12 13:24:54.764 host asyncio DEBUG Using selector: KqueueSelector
2021-07-12 13:24:54.933 host zigpy_znp.uart DEBUG Connecting to /dev/ttyUSB0 at 115200 baud
2021-07-12 13:24:54.940 host zigpy_znp.uart DEBUG Opened /dev/ttyUSB0 serial port
2021-07-12 13:24:54.941 host zigpy_znp.uart DEBUG Toggling RTS/CTS to skip CC2652R bootloader
2021-07-12 13:24:55.404 host zigpy_znp.uart DEBUG Connected to /dev/ttyUSB0 at 115200 baud
2021-07-12 13:24:55.404 host zigpy_znp.api DEBUG Waiting 1s before sending anything
2021-07-12 13:24:56.409 host zigpy_znp.api DEBUG Sending bootloader skip byte
...
PAN ID:                0xAA8A
Extended PAN ID:       35:8f:dc:b6:7a:19:33:c3
Channel:               15
Channel mask:          [15]
NWK update ID:         0
Device IEEE:           00:12:4b:00:1c:ce:33:85
Device NWK:            0x0000
Network key:           8c:2d:2d:a6:ca:95:30:04:11:6b:d5:dd:32:9e:b6:a8
Network key sequence:  0
2021-07-12 13:25:15.316 host zigpy_znp.uart DEBUG Closing serial port

Performing an energy scan

$ zigpy radio znp /dev/cu.usbserial-1420 energy-scan

Channel energy (mean of 1 / 5):
------------------------------------------------
 + Lower energy is better
 + Active Zigbee networks on a channel may still cause congestion
 + TX on 26 in North America may be with lower power due to regulations
 + Zigbee channels 15, 20, 25 fall between WiFi channels 1, 6, 11
 + Some Zigbee devices only join networks on channels 15, 20, and 25
------------------------------------------------
 - 11    80.00%  ################################################################################
 - 12    83.53%  ###################################################################################
 - 13    83.14%  ###################################################################################
 - 14    78.82%  ##############################################################################
 - 15    76.47%  ############################################################################
 - 16    72.16%  ########################################################################
 - 17    76.47%  ############################################################################
 - 18    75.69%  ###########################################################################
 - 19    72.16%  ########################################################################
 - 20    65.49%  #################################################################
 - 21    66.67%  ##################################################################
 - 22    70.59%  ######################################################################
 - 23    80.00%  ################################################################################
 - 24    64.31%  ################################################################
 - 25    77.25%  #############################################################################
 - 26*   81.96%  #################################################################################

Reset a radio

$ zigpy radio --baudrate 115200 ezsp /dev/serial/by-id/some-radio reset

Permit joins

Mainly useful for testing requests.

$ zigpy radio deconz /dev/ttyUSB0 permit -t 60

Changing the network channel

Some devices (like older Aqara sensors) may not migrate.

$ zigpy radio znp /dev/ttyUSB0 change-channel --channel 25

OTA

Display basic information about OTA files

$ zigpy ota info 10047227-1.2-TRADFRI-cv-cct-unified-2.3.050.ota.ota.signed
Header: OTAImageHeader(upgrade_file_id=200208670, header_version=256, header_length=56, field_control=<FieldControl.0: 0>, manufacturer_id=4476, image_type=16902, file_version=587531825, stack_version=2, header_string='GBL GBL_tradfri_cv_cct_unified', image_size=208766, *device_specific_file=False, *hardware_versions_present=False, *key=ImageKey(manufacturer_id=4476, image_type=16902), *security_credential_version_present=False)
Number of subelements: 1
Validation result: ValidationResult.VALID

Dump embedded firmware for further analysis

$ zigpy ota dump-firmware 10047227-1.2-TRADFRI-cv-cct-unified-2.3.050.ota.ota.signed - \
      | commander ebl print /dev/stdin \
      | grep 'Ember Version'
Ember Version:    6.3.1.1

Generate OTA index files

Create a JSON index for a given directory of firmwares:

$ zigpy ota generate-index --ota-url-root="https://example.org/fw" path/to/firmwares/**/*.ota
2023-02-14 12:02:03.532 ubuntu zigpy_cli.ota INFO Parsing path/to/firmwares/fw/test.ota
2023-02-14 12:02:03.533 ubuntu zigpy_cli.ota INFO Writing path/to/firmwares/fw/test.ota
[
    {
        "binary_url": "https://example.org/fw/test.ota",
        "file_version": 1762356,
        "image_type": 1234,
        "manufacturer_id": 5678,
        "changelog": "",
        "checksum": "sha3-256:1ddaa649eb920dea9e5f002fe0d1443cc903ac0c1b26e7ad2c97b928edec2786"
    },
...

Reconstruct an OTA image from a series of packet captures

Requires the tshark binary to be available.

$ zigpy ota reconstruct-from-pcaps --add-network-key aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99 --output-root ./extracted/ *.pcap
Constructing image type=0x298b, version=0x00000005, manuf_code=0x115f: 157424 bytes
2023-02-22 03:39:51.406 ubuntu zigpy_cli.ota ERROR Missing 48 bytes starting at offset 0x0000ADA0: filling with 0xAB
2023-02-22 03:39:51.406 ubuntu zigpy_cli.ota ERROR Missing 48 bytes starting at offset 0x000106B0: filling with 0xAB
Constructing image type=0x298b, version=0x00000009, manuf_code=0x115f: 163136 bytes

PCAP

Re-calculate the FCS on a packet capture

Fixes a bug in current EmberZNet SDK releases:

$ # Fix an existing capture
$ zigpy pcap fix-fcs input.pcap fixed.pcap
$ # Fix a capture from stdin and send it to stdout
$ bellows -d /dev/cu.GoControl_zigbee dump -w /dev/stdout | zigpy pcap fix-fcs - - | wireshark -k -S -i -

Database

Attempt to recover a corrupted zigbee.db database:

$ zigpy -v db recover broken.db fixed.db
2022-05-07 13:01:22.907 host zigpy_cli.database ERROR Failed to insert INSERT INTO "attributes_cache_v7"("_rowid_", "ieee", "endpoint_id", "cluster", "attrid", "value") VALUES( 14507477, '00:15:8d:00:02:5e:f9:ff', 1, 1027, 0, 1001.78 );: IntegrityError('UNIQUE constraint failed: attributes_cache_v7.ieee, attributes_cache_v7.endpoint_id, attributes_cache_v7.cluster, attributes_cache_v7.attrid')
2022-05-07 13:01:22.916 host zigpy_cli.database INFO Done

The final database will have no invalid constraints but data will likely be lost.

zigpy-cli's People

Contributors

damkast avatar natexornate avatar puddly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zigpy-cli's Issues

When I choose zigate to form a network , there is always zigpy.exceptions.NetworkNotFormed appear

Hey all,
The dongle I used is NXP 5169 and the firmware The software is downloaded from https://github.com/openlumi/ZiGate/release.
If I use this dongle with python third-party library zigate, it can form network and pair zigbee devices normally, and I can control device ON of OFF too。
However, I use the command "zigpy -vvvv radio zigate COM4 form",it always fail, and wrong message is "zigpy.exceptions.NetworkNotFormed".
image
I don't know what causes this problem. And when the program starts running, there also appear a warning message "Setting the pan_id is not supported by ZiGate". Em~~~~

Then I use command "zigpy radio zigate COM4 energy-scan", The program reported an error "asyncio.exceptions.TimeoutError" after running for some time. This is what has been bothering me for a long time.
image

Can anyone help me to deal these questions? Thank you, very much.

Migration bugged - Restore does not seem to work

Hello,

is anyone still looking into this?
I posted as a reply in another issue, but wanted to try this here one more time.

I tried following the instructions and I hit a wall and I am not sure how to proceed. Maybe someone here can help me out.

The backup seems to work. I get one or two warnings about unknown devices but that's it.
I followed the post above with the suggested settings.
The problem starts when I try to restore my file to the conbee 3.

I change my settings, including the baudarate, and start the zigpy-cli addon.
There seem to be a lot of errors coming up, as I can only copy-paste parts of it since the rest is not visible anymore:

Does anyone know what the problem could be?
I rebooted my computer when changing the USB stick to make sure it is recognized properly.

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 18:30:23.792 d0f5a498-tzb-zigpy-cli-tools asyncio ERROR Task exception was never retrieved
future: <Task finished name='discover_unknown_device_from_packet-nwk=0xDD6E' 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 18:30:23.808 d0f5a498-tzb-zigpy-cli-tools asyncio ERROR Task exception was never retrieved
future: <Task finished name='discover_unknown_device_from_packet-nwk=0xDD6E' 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 18:30:23.825 d0f5a498-tzb-zigpy-cli-tools asyncio ERROR Task exception was never retrieved
future: <Task finished name='discover_unknown_device_from_packet-nwk=0xDD6E' 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 18:30:23.808 d0f5a498-tzb-zigpy-cli-tools asyncio ERROR Task exception was never retrieved
future: <Task finished name='discover_unknown_device_from_packet-nwk=0xDD6E' 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 18:30:23.825 d0f5a498-tzb-zigpy-cli-tools asyncio ERROR Task exception was never retrieved
future: <Task finished name='discover_unknown_device_from_packet-nwk=0xDD6E' 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 18:30:26.881 d0f5a498-tzb-zigpy-cli-tools zigpy.application WARNING Unknown device AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x2BB3)
2024-02-12 18:30:26.913 d0f5a498-tzb-zigpy-cli-tools zigpy.application WARNING Unknown device AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xDB98)
[18:30:27] INFO: Action Complete
[18:30:27] 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

[BUG] Sonoff Zigbee 3.0 USB Dongle Plus-P (Windows)

Hi,

Source : https://sonoff.tech/product/gateway-and-sensors/sonoff-zigbee-3-0-usb-dongle-plus-p/

Installed (to get COM port) : https://sonoff.tech/wp-content/uploads/2022/08/CP210x_Windows_Drivers_with_Serial_Enumeration.zip

Fresh Python install :

pip install zigpy
pip install zigpy-cli
pip install zigpy-xbee
pip install zigpy-znp
pip install bellows
pip install zha-quirks

Then :

zigpy radio znp com10 reset
zigpy radio znp com10 form
zigpy radio znp com10 info

Getting :

Traceback (most recent call last):
  File "D:\TEST\Python\lib\site-packages\zigpy_znp\api.py", line 228, in load_network_info
    await self._load_network_info(load_devices=load_devices)
  File "D:\TEST\Python\lib\site-packages\zigpy_znp\api.py", line 104, in _load_network_info
    nib = await self.nvram.osal_read(OsalNvIds.NIB, item_type=t.NIB)
  File "D:\TEST\Python\lib\site-packages\zigpy_znp\nvram.py", line 171, in osal_read
    raise KeyError(f"NV item does not exist: {nv_id!r}")
KeyError: 'NV item does not exist: <OsalNvIds.NIB: 33>'

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

Traceback (most recent call last):
  File "D:\TEST\Python\Lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\TEST\Python\Lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\TEST\Python\Scripts\zigpy.exe\__main__.py", line 7, in <module>
  File "D:\TEST\Python\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "D:\TEST\Python\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "D:\TEST\Python\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "D:\TEST\Python\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "D:\TEST\Python\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\TEST\Python\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "D:\TEST\Python\lib\site-packages\click\decorators.py", line 38, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "D:\TEST\Python\lib\site-packages\zigpy_cli\cli.py", line 20, in inner
    return loop.run_until_complete(cmd(*args, **kwargs))
  File "D:\TEST\Python\Lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "D:\TEST\Python\lib\site-packages\zigpy_cli\radio.py", line 86, in info
    await app.load_network_info(load_devices=False)
  File "D:\TEST\Python\lib\site-packages\zigpy_znp\zigbee\application.py", line 160, in load_network_info
    await self._znp.load_network_info(load_devices=load_devices)
  File "D:\TEST\Python\lib\site-packages\zigpy_znp\api.py", line 230, in load_network_info
    raise NetworkNotFormed() from e
zigpy.exceptions.NetworkNotFormed

Any idea how to make it work "out of the box" ?

Regards.

[BUG] Version inconsistency on installation from GitHub

Hi, doing that :

pip install git+https://github.com/zigpy/zigpy.git
pip install git+https://github.com/zigpy/zigpy-cli.git
pip install git+https://github.com/zigpy/zigpy-znp.git
pip install git+https://github.com/zigpy/bellows.git

Getting (with decoration for readability) :

Full installation log (quite long)

 - - - Installing "git+https://github.com/zigpy/zigpy.git" - - - - - - - - - - - - - - - - - - - - - - - -

Collecting git+https://github.com/zigpy/zigpy.git
  Running command git clone --filter=blob:none --quiet https://github.com/zigpy/zigpy.git 'C:\Users\Kochise\AppData\Local\Temp\pip-req-build-tojucrt_'
  Cloning https://github.com/zigpy/zigpy.git to c:\users\Kochise\appdata\local\temp\pip-req-build-tojucrt_
  Resolved https://github.com/zigpy/zigpy.git to commit 85d148f9dc3b5719cf6919ea850eb5f86b288c5e
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting attrs
  Downloading attrs-22.2.0-py3-none-any.whl (60 kB)
     -------------------------------------- 60.0/60.0 kB 245.2 kB/s eta 0:00:00
Collecting aiohttp
  Downloading aiohttp-3.8.4-cp310-cp310-win_amd64.whl (319 kB)
     -------------------------------------- 319.8/319.8 kB 1.5 MB/s eta 0:00:00
Collecting aiosqlite>=0.16.0
  Downloading aiosqlite-0.18.0-py3-none-any.whl (15 kB)
Collecting async_timeout
  Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Collecting crccheck
  Downloading crccheck-1.3.0-py3-none-any.whl (21 kB)
Collecting cryptography
  Downloading cryptography-40.0.1-cp36-abi3-win_amd64.whl (2.6 MB)
     ---------------------------------------- 2.6/2.6 MB 2.6 MB/s eta 0:00:00
Collecting voluptuous
  Downloading voluptuous-0.13.1-py3-none-any.whl (29 kB)
Collecting pyserial-asyncio!=0.5
  Downloading pyserial_asyncio-0.6-py3-none-any.whl (7.6 kB)
Collecting pyserial
  Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
     ---------------------------------------- 90.6/90.6 kB 5.4 MB/s eta 0:00:00
Collecting frozenlist>=1.1.1
  Downloading frozenlist-1.3.3-cp310-cp310-win_amd64.whl (33 kB)
Collecting yarl<2.0,>=1.0
  Downloading yarl-1.8.2-cp310-cp310-win_amd64.whl (56 kB)
     ---------------------------------------- 56.1/56.1 kB 1.5 MB/s eta 0:00:00
Collecting charset-normalizer<4.0,>=2.0
  Downloading charset_normalizer-3.1.0-cp310-cp310-win_amd64.whl (97 kB)
     ---------------------------------------- 97.1/97.1 kB 2.8 MB/s eta 0:00:00
Collecting multidict<7.0,>=4.5
  Downloading multidict-6.0.4-cp310-cp310-win_amd64.whl (28 kB)
Collecting aiosignal>=1.1.2
  Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
Collecting cffi>=1.12
  Downloading cffi-1.15.1-cp310-cp310-win_amd64.whl (179 kB)
     -------------------------------------- 179.1/179.1 kB 1.1 MB/s eta 0:00:00
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     -------------------------------------- 118.7/118.7 kB 1.4 MB/s eta 0:00:00
Collecting idna>=2.0
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     -------------------------------------- 61.5/61.5 kB 814.3 kB/s eta 0:00:00
Building wheels for collected packages: zigpy
  Building wheel for zigpy (setup.py): started
  Building wheel for zigpy (setup.py): finished with status 'done'
  Created wheel for zigpy: filename=zigpy-0.54.0.dev0-py3-none-any.whl size=171689 sha256=dfb8a2ad0a09697ed9b8b94505eaa933a462135528c2d9d3744cce78edbe6a78
  Stored in directory: C:\Users\Kochise\AppData\Local\Temp\pip-ephem-wheel-cache-94e01dkg\wheels\1e\40\8f\81b14cd173c853dbab24dda1b3b810bdac8c4d047abf1d93e3
Successfully built zigpy
Installing collected packages: voluptuous, pyserial, crccheck, pyserial-asyncio, pycparser, multidict, idna, frozenlist, charset-normalizer, attrs, async_timeout, aiosqlite, yarl, cffi, aiosignal, cryptography, aiohttp, zigpy
Successfully installed aiohttp-3.8.4 aiosignal-1.3.1 aiosqlite-0.18.0 async_timeout-4.0.2 attrs-22.2.0 cffi-1.15.1 charset-normalizer-3.1.0 crccheck-1.3.0 cryptography-40.0.1 frozenlist-1.3.3 idna-3.4 multidict-6.0.4 pycparser-2.21 pyserial-3.5 pyserial-asyncio-0.6 voluptuous-0.13.1 yarl-1.8.2 zigpy-0.54.0.dev0

 - - - Installing "git+https://github.com/zigpy/zigpy-cli.git" - - - - - - - - - - - - - - - - - - - - - - - -

Collecting git+https://github.com/zigpy/zigpy-cli.git
  Running command git clone --filter=blob:none --quiet https://github.com/zigpy/zigpy-cli.git 'C:\Users\Kochise\AppData\Local\Temp\pip-req-build-vv1i5g4c'
  Cloning https://github.com/zigpy/zigpy-cli.git to c:\users\Kochise\appdata\local\temp\pip-req-build-vv1i5g4c
  Resolved https://github.com/zigpy/zigpy-cli.git to commit 125b537aa7ca0d76c8af3bf071803de7e3056a5c
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting zigpy-znp>=0.8.0
  Downloading zigpy_znp-0.10.0-py3-none-any.whl (122 kB)
     ------------------------------------ 122.3/122.3 kB 421.4 kB/s eta 0:00:00
Collecting coloredlogs
  Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)
     ---------------------------------------- 46.0/46.0 kB 2.2 MB/s eta 0:00:00
Collecting click
  Downloading click-8.1.3-py3-none-any.whl (96 kB)
     ---------------------------------------- 96.6/96.6 kB 2.8 MB/s eta 0:00:00
Collecting bellows>=0.34.3
  Downloading bellows-0.35.0-py3-none-any.whl (218 kB)
     -------------------------------------- 218.2/218.2 kB 1.7 MB/s eta 0:00:00
Collecting scapy
  Downloading scapy-2.5.0.tar.gz (1.3 MB)
     ---------------------------------------- 1.3/1.3 MB 2.4 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting zigpy-deconz>=0.18.0
  Downloading zigpy_deconz-0.19.2-py3-none-any.whl (31 kB)
Collecting zigpy>=0.53.0
  Downloading zigpy-0.54.0-py3-none-any.whl (171 kB)
     -------------------------------------- 171.6/171.6 kB 2.6 MB/s eta 0:00:00
Collecting pure-pcapy3==1.0.1
  Downloading pure-pcapy3-1.0.1.tar.gz (5.9 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting click-log>=0.2.1
  Downloading click_log-0.4.0-py2.py3-none-any.whl (4.3 kB)
Collecting jsonschema
  Downloading jsonschema-4.17.3-py3-none-any.whl (90 kB)
     ---------------------------------------- 90.4/90.4 kB 1.7 MB/s eta 0:00:00
Collecting colorama
  Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting humanfriendly>=9.1
  Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)
     ---------------------------------------- 86.8/86.8 kB 1.2 MB/s eta 0:00:00
Collecting pyreadline3
  Downloading pyreadline3-3.4.1-py3-none-any.whl (95 kB)
     ---------------------------------------- 95.2/95.2 kB 1.1 MB/s eta 0:00:00
Collecting pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0
  Downloading pyrsistent-0.19.3-cp310-cp310-win_amd64.whl (62 kB)
     -------------------------------------- 62.7/62.7 kB 846.4 kB/s eta 0:00:00
Building wheels for collected packages: zigpy-cli, pure-pcapy3, scapy
  Building wheel for zigpy-cli (pyproject.toml): started
  Building wheel for zigpy-cli (pyproject.toml): finished with status 'done'
  Created wheel for zigpy-cli: filename=zigpy_cli-0.0.0-py3-none-any.whl size=25453 sha256=079a6373dd5698ec07e461baac561221b61f11ab46238aca9a0e6cf64722f92e
  Stored in directory: C:\Users\Kochise\AppData\Local\Temp\pip-ephem-wheel-cache-zorva2sh\wheels\a0\0f\1e\7d823b6342d74dc11cc963ff1ea3d2a0ef1468c483d716a0d7
  Building wheel for pure-pcapy3 (setup.py): started
  Building wheel for pure-pcapy3 (setup.py): finished with status 'done'
  Created wheel for pure-pcapy3: filename=pure_pcapy3-1.0.1-py3-none-any.whl size=5034 sha256=d79fcb33819034041af5e54f7d0289fd7201f10158584c25d6e18fbf352099cb
  Stored in directory: C:\Users\Kochise\AppData\Local\Temp\pip-ephem-wheel-cache-zorva2sh\wheels\85\cd\07\df2f1523280f09843135c8ac9229b269883fc1df331b784eeb
  Building wheel for scapy (setup.py): started
  Building wheel for scapy (setup.py): finished with status 'done'
  Created wheel for scapy: filename=scapy-2.5.0-py2.py3-none-any.whl size=1444341 sha256=ff73714e03155601ef3bc0b913a4291505f9312e8edbc0c3a767a4d6bbf0a365
  Stored in directory: C:\Users\Kochise\AppData\Local\Temp\pip-ephem-wheel-cache-zorva2sh\wheels\82\b7\03\8344d8cf6695624746311bc0d389e9d05535ca83c35f90241d
Successfully built zigpy-cli pure-pcapy3 scapy
Installing collected packages: pyreadline3, scapy, pyrsistent, pure-pcapy3, humanfriendly, colorama, jsonschema, coloredlogs, click, zigpy, click-log, zigpy-znp, zigpy-deconz, bellows, zigpy-cli
  Attempting uninstall: zigpy
    Found existing installation: zigpy 0.54.0.dev0
    Uninstalling zigpy-0.54.0.dev0:
      Successfully uninstalled zigpy-0.54.0.dev0
Successfully installed bellows-0.35.0 click-8.1.3 click-log-0.4.0 colorama-0.4.6 coloredlogs-15.0.1 humanfriendly-10.0 jsonschema-4.17.3 pure-pcapy3-1.0.1 pyreadline3-3.4.1 pyrsistent-0.19.3 scapy-2.5.0 zigpy-0.54.0 zigpy-cli-0.0.0 zigpy-deconz-0.19.2 zigpy-znp-0.10.0

 - - - Installing "git+https://github.com/zigpy/zigpy-znp.git" - - - - - - - - - - - - - - - - - - - - - - - -

Collecting git+https://github.com/zigpy/zigpy-znp.git
  Running command git clone --filter=blob:none --quiet https://github.com/zigpy/zigpy-znp.git 'C:\Users\Kochise\AppData\Local\Temp\pip-req-build-4v8ntk6n'
  Cloning https://github.com/zigpy/zigpy-znp.git to c:\users\Kochise\appdata\local\temp\pip-req-build-4v8ntk6n
  Resolved https://github.com/zigpy/zigpy-znp.git to commit 3f6ba1b1b6aa57ab6b41413de5a9551fefd72e25
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: zigpy-znp
  Building wheel for zigpy-znp (pyproject.toml): started
  Building wheel for zigpy-znp (pyproject.toml): finished with status 'done'
  Created wheel for zigpy-znp: filename=zigpy_znp-0.0.0-py3-none-any.whl size=122347 sha256=04c26cdc37ef5e4236ef1501e655f528532db7f2c560b3077cf9df89c9912df4
  Stored in directory: C:\Users\Kochise\AppData\Local\Temp\pip-ephem-wheel-cache-amxhvrme\wheels\f7\e2\e9\a248a35764afca6a68e384613c3caeca3027651d29895eaf03
Successfully built zigpy-znp
Installing collected packages: zigpy-znp
  Attempting uninstall: zigpy-znp
    Found existing installation: zigpy-znp 0.10.0
    Uninstalling zigpy-znp-0.10.0:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
zigpy-cli 0.0.0 requires zigpy-znp>=0.8.0, but you have zigpy-znp 0.0.0 which is incompatible.
      Successfully uninstalled zigpy-znp-0.10.0
Successfully installed zigpy-znp-0.0.0

 - - - Installing "git+https://github.com/zigpy/bellows.git" - - - - - - - - - - - - - - - - - - - - - - - -

Collecting git+https://github.com/zigpy/bellows.git
  Running command git clone --filter=blob:none --quiet https://github.com/zigpy/bellows.git 'C:\Users\Kochise\AppData\Local\Temp\pip-req-build-uaorbawi'
  Cloning https://github.com/zigpy/bellows.git to c:\users\Kochise\appdata\local\temp\pip-req-build-uaorbawi
  Resolved https://github.com/zigpy/bellows.git to commit 8ad0c59d04f049a537232149da6af6fb20580ee4
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: bellows
  Building wheel for bellows (setup.py): started
  Building wheel for bellows (setup.py): finished with status 'done'
  Created wheel for bellows: filename=bellows-0.35.0.dev0-py3-none-any.whl size=218282 sha256=10c1ef5d2951ae4f7c1adb2fca3df188579fa8dcc8cb36561b758f547cb4d45b
  Stored in directory: C:\Users\Kochise\AppData\Local\Temp\pip-ephem-wheel-cache-k6m8low3\wheels\e1\73\27\a2a5475650b15cc9062237436a971e10ee76bad785106323ee
Successfully built bellows
Installing collected packages: bellows
  Attempting uninstall: bellows
    Found existing installation: bellows 0.35.0
    Uninstalling bellows-0.35.0:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
zigpy-cli 0.0.0 requires zigpy-znp>=0.8.0, but you have zigpy-znp 0.0.0 which is incompatible.
      Successfully uninstalled bellows-0.35.0
Successfully installed bellows-0.35.0.dev0


Why the following "errors" :

 - - - Installing "git+https://github.com/zigpy/zigpy.git" - - - - - - - - - - - - - - - - - - - - - - - -

  Created wheel for zigpy: filename=zigpy-0.54.0.dev0-py3-none-any.whl size=171689 sha256=dfb8a2ad0a09697ed9b8b94505eaa933a462135528c2d9d3744cce78edbe6a78

Ok so far...

 - - - Installing "git+https://github.com/zigpy/zigpy-cli.git" - - - - - - - - - - - - - - - - - - - - - - - -

Collecting zigpy>=0.53.0
  Downloading zigpy-0.54.0-py3-none-any.whl (171 kB)
     -------------------------------------- 171.6/171.6 kB 2.6 MB/s eta 0:00:00

  Created wheel for zigpy-cli: filename=zigpy_cli-0.0.0-py3-none-any.whl size=25453 sha256=079a6373dd5698ec07e461baac561221b61f11ab46238aca9a0e6cf64722f92e

Installing collected packages: zigpy
  Attempting uninstall: zigpy
    Found existing installation: zigpy 0.54.0.dev0
    Uninstalling zigpy-0.54.0.dev0:
      Successfully uninstalled zigpy-0.54.0.dev0
Successfully installed zigpy-0.54.0

Why 0.0.0 for zigpy-cli ? Why not at least 0.0.0.dev0 ?

Why replacing zigpy-0.54.0.dev0 with zigpy-0.54.0 ?

 - - - Installing "git+https://github.com/zigpy/zigpy-znp.git" - - - - - - - - - - - - - - - - - - - - - - - -

  Created wheel for zigpy-znp: filename=zigpy_znp-0.0.0-py3-none-any.whl size=122347 sha256=04c26cdc37ef5e4236ef1501e655f528532db7f2c560b3077cf9df89c9912df4

Successfully built zigpy-znp
Installing collected packages: zigpy-znp
  Attempting uninstall: zigpy-znp
    Found existing installation: zigpy-znp 0.10.0
    Uninstalling zigpy-znp-0.10.0:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
zigpy-cli 0.0.0 requires zigpy-znp>=0.8.0, but you have zigpy-znp 0.0.0 which is incompatible.
      Successfully uninstalled zigpy-znp-0.10.0
Successfully installed zigpy-znp-0.0.0

Why 0.0.0 for zigpy-znp ? Why not at least 0.0.0.dev0 ?

Why uninstalling zigpy-znp-0.10.0 then immediately installing zigpy-znp-0.0.0 instead ?

Why this :

zigpy-cli 0.0.0 requires zigpy-znp>=0.8.0, but you have zigpy-znp 0.0.0 which is incompatible.

Let's continue...

 - - - Installing "git+https://github.com/zigpy/bellows.git" - - - - - - - - - - - - - - - - - - - - - - - -

  Created wheel for bellows: filename=bellows-0.35.0.dev0-py3-none-any.whl size=218282 sha256=10c1ef5d2951ae4f7c1adb2fca3df188579fa8dcc8cb36561b758f547cb4d45b

Successfully built bellows
Installing collected packages: bellows
  Attempting uninstall: bellows
    Found existing installation: bellows 0.35.0
    Uninstalling bellows-0.35.0:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
zigpy-cli 0.0.0 requires zigpy-znp>=0.8.0, but you have zigpy-znp 0.0.0 which is incompatible.
      Successfully uninstalled bellows-0.35.0
Successfully installed bellows-0.35.0.dev0

Why this again :

zigpy-cli 0.0.0 requires zigpy-znp>=0.8.0, but you have zigpy-znp 0.0.0 which is incompatible.

Doing a pip freeze gives :

bellows @ git+https://github.com/zigpy/bellows.git@8ad0c59d04f049a537232149da6af6fb20580ee4
zigpy==0.54.0
zigpy-cli @ git+https://github.com/zigpy/zigpy-cli.git@125b537aa7ca0d76c8af3bf071803de7e3056a5c
zigpy-deconz==0.19.2
zigpy-znp @ git+https://github.com/zigpy/zigpy-znp.git@3f6ba1b1b6aa57ab6b41413de5a9551fefd72e25

Any reason for the 0.0.0 version for zigpy-cli and zigpy-znp ?

Where if the 0.54.0.dev0 for zigpy ?

Where if the 0.35.0.dev0 for bellows ?

Pretty strange...

Regards.

OTA command failing with HueSBLOTAImage

Running the following command produces an error, as zigpy's HueSBLOTAImage does not have (valid) subelements:
zigpy-cli ota info LivingColors-Atmel-Target_0012.sbl-ota

Download link for the OTA image: https://otau.meethue.com/storage/ZGB_100B_0108/55fb9cf3-afb6-4ef5-8887-905699da7ee8/LivingColors-Atmel-Target_0012.sbl-ota

The error is caused here when printing the number of subelements:

print(f"Number of subelements: {len(image.subelements)}")

Command output:

Header: OTAImageHeader(upgrade_file_id=200208670, header_version=256, header_length=56, field_control=<FieldControl.0: 0>, manufacturer_id=4107, image_type=264, file_version=1124099330, stack_version=2, header_string='', image_size=256696, *device_specific_file=False, *hardware_versions_present=False, *key=ImageKey(manufacturer_id=4107, image_type=264), *security_credential_version_present=False)
Traceback (most recent call last):
  File "/Users/test/GP/zigpy-cli/venv/bin/zigpy", line 33, in <module>
    sys.exit(load_entry_point('zigpy-cli==0.0.1', 'console_scripts', 'zigpy')())
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/zigpy_cli/ota.py", line 37, in info
    print(f"Number of subelements: {len(image.subelements)}")
AttributeError: 'HueSBLOTAImage' object has no attribute 'subelements'

[BUG] no attribute 'attribute_updated' on 'permit'

Hi,

Fresh Python install :

pip install zigpy
pip install zigpy-cli
pip install zigpy-xbee
pip install zigpy-znp
pip install bellows
pip install zha-quirks

Then :

zigpy radio znp com10 reset
zigpy radio znp com10 form
zigpy radio znp com10 info

Getting :

PAN ID:                0x7486
Extended PAN ID:       d1:39:b5:2c:db:0b:04:25
Channel:               20
Channel mask:          [20]
NWK update ID:         0
Device IEEE:           00:12:4b:00:2a:2e:c1:cd
Device NWK:            0x0000
Network key:           13:76:a0:98:2a:6a:d1:3c:52:38:f7:0f:2d:7c:7a:61
Network key sequence:  0
Network key counter:   0

Now when I pair various devices (RGB bulb, contactless switch, temperature sensor), I get :

D:\TEST>zigpy radio znp com10 permit
2023-04-07 10:10:59.562 TEST zigpy.util WARNING Error calling listener <bound method ClusterPersistingListener.attribute_updated of <zigpy.zcl.ClusterPersistingListener object at 0x0000028E6D3B10F0>> with args (4, 'HEIMAN'): AttributeError("'NoneType' object has no attribute 'attribute_updated'")
2023-04-07 10:10:59.562 TEST zigpy.util WARNING Error calling listener <bound method ClusterPersistingListener.attribute_updated of <zigpy.zcl.ClusterPersistingListener object at 0x0000028E6D3B10F0>> with args (5, 'ColorLight'): AttributeError("'NoneType' object has no attribute 'attribute_updated'")

D:\TEST>zigpy radio znp com10 permit
2023-04-07 11:54:16.742 TEST zigpy.util WARNING Error calling listener <bound method ClusterPersistingListener.attribute_updated of <zigpy.zcl.ClusterPersistingListener object at 0x000002356E4219F0>> with args (4, 'eWeLink'): AttributeError("'NoneType' object has no attribute 'attribute_updated'")
2023-04-07 11:54:16.742 TEST zigpy.util WARNING Error calling listener <bound method ClusterPersistingListener.attribute_updated of <zigpy.zcl.ClusterPersistingListener object at 0x000002356E4219F0>> with args (5, 'WB01'): AttributeError("'NoneType' object has no attribute 'attribute_updated'")

Additional '-vv' log is zigpy_cli_permit_attribute_updated_bug.txt

Regards.

Add parameter to set channel

In order to force the channel, I updated the 'form' function like this:

async def form(app):
    app.config[conf.CONF_NWK][conf.CONF_NWK_CHANNEL]=11
    app.config[conf.CONF_NWK][conf.CONF_NWK_CHANNELS]=[11]
    await app.startup(auto_form=True)
    await app.form_network()
    dump_app_info(app)

I suggest to add a command line option allowing to force the channel or channel list.

[REQUEST] Add command to probe running firmware?

Suggest add unified command in zigpy-cli to probe running firmware in order to dump EmberZNet Ember config from bellows via EZSP.

$ bellows -d /dev/ttyUSB1 -b 115200 config --all

and

$ bellows -d /dev/ttyUSB1 -b 115200 info

Then such zigpy CLI command could possibly later be extended to offer similar information probe in other radio libraries for zigpy too?

PS: @darkxst pull request for universal-silabs-flasher added wrappr for it here -> NabuCasa/universal-silabs-flasher#37

PPS: Also related to same feature request by xconverge here -> NabuCasa/universal-silabs-flasher#16

Add Child, Remove Child, Remove Neighbor via direct manipulation of child/neighbor table by the application?

Feature for direct manipulation of child/neighbour table by the application to "Add Child", "Remove Child", "Remove Neighbor" might be nice to have for a few reasons but I think that it would be especially nice to be able to configure some devices to not use some device as a router(?).

I think what I would like to achieve is the option to manually blacklist specific devices so they are not used as Zigbee routers.

FYI, new API feature added Silabs Zigbee EmberZNet 6.10.0.0 which might be nice to consider for zigpy-cli for ZHA integration?

https://www.silabs.com/documents/public/release-notes/emberznet-release-notes-6.10.3.0.pdf

Added in release 6.10.0.0

emberAddChild() - SoC-only API for adding a child to the child/neighbor table, allowing direct manipulation of these tables by the application.

emberRemoveChild() - SoC-only API for removing a node from child/neighbor table, allowing direct manipulation of these tables by the application.

emberRemoveNeighbor() - SoC-only API for removing a node from neighbor table, allowing direct manipulation of these tables by the application.

[REQUEST] Publish zigpy-cli on PyPi?

@puddly Please consider publishing "zigpy-cli" on PyPI (similar to how zigpy is) so that it can more easily be used stand-alone:

https://pypi.org/project/zigpy

verses

https://pypi.org/project/zigpy-cli

Would be great if users want to use stand-alone zigpy-cli for backup and restore outside of Home Assistant's ZHA integration.

See these two use cases where the users are using Home Assistant SkyConnect USB adapter with Zigbee2MQTT instead of ZHA:

#24

Koenkk/zigbee2mqtt#16478

Unable to backup HUSBZB-1

I am struggling to back up my HUSBZB-1 - with the goal of migrating to a Sonoff Zigbee USB dongle.

environment info:

(venv)  zigpy $ python --version
Python 3.8.12
(venv)  zigpy $ udevadm info -a -n /dev/ttyUSB1 | grep '{interface}' | head -n1
    ATTRS{interface}=="HubZ ZigBee Com Port"

I was trying to follow along with this ticket, so I used the braches there: #2

pip install \
    git+https://github.com/puddly/zigpy.git@puddly/new-radio-settings-api \
    git+https://github.com/puddly/zigpy-cli.git@puddly/zigpy-radio-api \
    git+https://github.com/puddly/zigpy-znp.git@puddly/new-radio-settings-api \
    git+https://github.com/puddly/zigpy-deconz.git@puddly/new-radio-api \
    git+https://github.com/puddly/bellows.git@puddly/zigpy-radio-api

This is what I see when I try to run a backup. After the last line it just hangs for minutes until I send ^c.

(venv)  zigpy $ zigpy -vv radio ezsp /dev/ttyUSB1 backup backup.json
2022-03-12 15:53:58.133 localhost.localdomain asyncio DEBUG Using selector: EpollSelector
2022-03-12 15:53:58.238 localhost.localdomain zigpy.appdb DEBUG SQLite version for <module 'sqlite3' from '/usr/lib64/python3.8/sqlite3/__init__.py'>: 3.37.2
2022-03-12 15:53:58.292 localhost.localdomain asyncio DEBUG Using selector: EpollSelector
2022-03-12 15:53:58.412 localhost.localdomain bellows.ezsp DEBUG Resetting EZSP
2022-03-12 15:53:58.413 localhost.localdomain bellows.uart DEBUG Resetting ASH
2022-03-12 15:53:58.413 localhost.localdomain bellows.uart DEBUG Sending: b'1ac038bc7e'
2022-03-12 15:53:59.712 localhost.localdomain bellows.uart DEBUG RSTACK Version: 2 Reason: RESET_POWER_ON frame: b'c102029b7b7e'
2022-03-12 15:53:59.712 localhost.localdomain bellows.ezsp ERROR NCP entered failed state. Requesting APP controller restart
2022-03-12 15:53:59.713 localhost.localdomain bellows.uart DEBUG Closed serial connection

^c results in this log:

2022-03-12 15:59:45.700 localhost.localdomain asyncio ERROR Task was destroyed but it is pending!
task: <Task pending name='Task-6' coro=<Gateway.reset() running at ~/dev/zigpy/venv/lib/python3.8/site-packages/bellows/uart.py:223> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f31031cdaf0>()]> cb=[_chain_future.<locals>._call_set_state() at /usr/lib64/python3.8/asyncio/futures.py:367]>

and have also tried the master branch:

(venv)  zigpy $ pip install  --force-reinstall   git+https://github.com/puddly/zigpy.git     git+https://github.com/puddly/zigpy-cli.git    git+https://github.com/puddly/zigpy-znp.git    git+https://github.com/puddly/zigpy-deconz.git     git+https://github.com/puddly/bellows.git

which gave me a syntax error (it looks like backup isn't a command there yet?)

I don't remember what firmware version I have on my HUSBZB-1, but I did update it within the last year to the latest.

Any help is appreciated. Let me know if there is more info I can provide.

Silicon Labs Zigbee EmberZNet 7.0.0.0 migrated to the new unified CLI system for Ember

Silabs released Zigbee EmberZNet 7.0.0.0 which among other new things apper to migrate to a new unified CLI system for Ember:

https://www.silabs.com/documents/public/release-notes/emberznet-release-notes-7.0.0.0.pdf

https://docs.silabs.com/gecko-platform/4.0/service/cli/overview

http://docs.silabs.com/zigbee/7.0

They also for the first time release the Zigbee SDK publicly on GitHub

https://github.com/SiliconLabs/gecko_sdk/releases

https://github.com/SiliconLabs/gecko_sdk

https://github.com/SiliconLabs/gecko_sdk/tree/gsdk_4.0/protocol/zigbee

https://docs.silabs.com/gecko-platform/4.0/

1.1 New APIs

New in release 7.0.0.0

For an extensive list of new APIs in this release, refer to Zigbee Stack API documentation and Zigbee Application Framework API documentation on https://docs.silabs.com/ .

Command Line Interface (CLI)

Zigbee migrated to the new/unified CLI system. All emberXXXArgument() APIs are changed to sl_cli_XXX_argument_XXX()
APIs (e.g., emberCommandArgumentCount() → sl_cli_get_argument_count()). Refer to the sl_cli.h header file and its documentation
for available CLI command APIs.

In the newly integrated CLI, hexadecimal string and ASCII string arguments have dedicated types. These arguments can be retrieved
using the related APIs sl_cli_get_command_string() and sl_cli_get_argument_hex(). See sl_cli.h for more information.

1.3 New Documentation

New in release 7.0.0.0

All components have documentation available. If you have an issue seeing the documentation when you select the component in Project Configurator, you can find it here: http://docs.silabs.com/zigbee/7.0

New software documentation available through Simplicity Studio’s Documentation page includes:

• AN1301: Transitioning from Zigbee EmberZNet SDK 6.x to SDK 7.x
• AN1322: Dynamic Multiprotocol Development with Bluetooth and and Zigbee EmberZNet SDK 7.0 and Higher
• AN1325: Zigbee Cluster Configurator User's Guide
• AN1333: Running Zigbee, OpenThread, and Bluetooth Concurrently on a Linux Host with a Multiprotocol RCP
• QSG180: Zigbee EmberZNet Quick-Start Guide for SDK 7.0 and Higher
• UG491: Zigbee Application Framework Developer’s Guide for SDK 7.0 and Higher

PS: Not sure if Gecko SDK 4.0 was accidentally released or official as of yet as their version history still says that Gecko SDK Suite 3.2 is latest:

https://docs.silabs.com/gecko-platform/latest/version-history

Link to 4.0 seem to work through:

https://docs.silabs.com/gecko-platform/4.0/

Worth taking a look at pyspinel CLI as a reference?

While the pyspinel is not made for Zigbee but for OpenThread NCPs instead, concepts in the Spinel CLI might however still be interesting as it is a relatively mature CLI for an NCP and actively maintained so might cover a lot of the same wishlist that developers and users would want?

A Python CLI tool called "Pyspinel" is available for testing purposes (and it is an active project so still being developed):

https://openthread.io/guides/pyspinel

Pyspinel, available on the pyspinel GitHub repository, is a Python CLI for the Spinel protocol.

The Spinel CLI exposes the OpenThread configuration and management APIs running on an NCP build via a command line interface. Spinel CLI is primarily targeted for driving the automated continuous integration tests, and is suitable for manual experimentation with controlling OpenThread NCP instances.

Pyspinel is used to:

  • Add simulated Co-Processor testing to continuous integration.
  • Automate testing of testbeds running Co-Processor firmware on hardware.
  • Debug Co-Processor builds of OpenThread.
  • Convert an OpenThread Co-Processor into a packet sniffer.

Use the CLI to play with NCP builds of OpenThread on a Linux or Mac OS platform, including starting a basic tunnel interface to allow IPv6 applications to run on the HOST and use the Thread network.

The power of this tool is threefold:

  1. As a path to add testing of the NCP in simulation to continuous integration
  2. As a path to automated testing of testbeds running NCP firmware on hardware
  3. As a simple debugging tool for NCP builds of OpenThread

For more information, see the Internet-Draft for the Spinel Host-Controller Protocol:

https://datatracker.ietf.org/doc/html/draft-rquattle-spinel-unified

This full protocol source code is also included with OpenThread at /src/lib/spinel in openthread repo:

https://github.com/openthread/openthread/tree/master/src/lib/spinel

For a production grade host driver that uses the Spinel CLI , see the "wpantund" project:

https://github.com/openthread/wpantund

One specific concept it had is "Vendor package" extension of the Spinel CLI with custom properties and commands:

https://github.com/openthread/pyspinel#vendor-package

"This plugin-like extension adds vendor-specific commands and properties to pyspinel in a way that does not impact the implementation of core pyspinel functionalities."

Just noticed this when Elelabs (maker of the Elelabs and Popp Zigbee sticks) forked it and made a vendor package for it:

https://github.com/Elelabs/pyspinel/tree/elelabs/elelabs

With that they have started by including "btl", "data", and "help" as Elelabs Pyspinel vendor package commands:

https://github.com/Elelabs/pyspinel/blob/elelabs/elelabs/README.md

https://github.com/Elelabs/pyspinel/tree/elelabs/elelabs#btl

https://github.com/Elelabs/pyspinel/tree/elelabs/elelabs#data

https://github.com/Elelabs/pyspinel/tree/elelabs/elelabs#help

I guess that "MFG_LAUNCH_BOOTLOADER" command to could maybe be ported first as command to enter Silabs bootloader?

https://github.com/Elelabs/pyspinel/tree/elelabs/elelabs#elelabs-thread-spinel-commands

"Launch Bootloader NCP command. Causes the NCP to perform a software reset and enter XMODEM bootloader mode"

$ cd <path-to-pyspinel>
$ spinel-cli.py -u /dev/ttyS1 -b 115200 --vendor-path=elelabs
spinel-cli > version
SL-OPENTHREAD/1.1.2.0_GitHub-5c2ad91cf; EFR32; Jun 16 2021 22:54:45
Done
spinel-cli > vendor data
Elelabs
Done
ELU013
Done
spinel-cli > vendor btl
spinel-cli > exit

Maybe also worth taking a look at the Zigbee Shell / CLI wrapper for Nordic Semi nRF5 family of NCP as a reference?

Nordic Semi who makes nRF5 series of multi-protocol chips have a Zigbee Shell / CLI wrapper might be worth a look for reference?

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/zigbee/shell/README.html

Their arguments for going with the CLI Zigbee architecture they did in this command shell is shortly described here:

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.1.0%2Fzigbee_architectures.html&cp=8_7_0_3_2

Nordic Semiconductor has this quick reference with commands supported by their Zigbee CLI:

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.1.0%2Fzigbee_example_cli_reference.html

And examples for Zigbee NCP:

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.1.0%2Fzigbee_only_examples.html

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.1.0%2Fzigbee_example_cli_agent.html

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.1.0%2Fzigbee_example_cli_agent.html&cp=8_3_3_8_5_1_0&anchor=zigbee_example_cli_agent_interfaces

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.1.0%2Fzigbee_example_ota_examples.html

It also includes a sample implementation of how their Zigbee CLI can be used for the implementation of a Zigbee-MQTT gateway:

https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/zigbee_cli_wrapper.html#zigbee_cli_wrapper_mqtt

There is also this real-world example of a project implementing a slightly older version of that Nordic Semi's Zigbee CLI wrapper:

https://github.com/hipiphock/Dongle-Handler/ (and related https://github.com/ninima0323/TestGUI which uses that handler).

FYI; nRF52 series and nRF53 Evaluation Kir and Development Kit hardware for nRF Connect SDK is relatively inexpensive to buy:

https://www.nordicsemi.com/Products/nRF52840

https://www.nordicsemi.com/Products/nRF5340

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#ug-nrf52

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf53.html#ug-nrf53

Note that their NCP solution for nRF52/nRF53 (nRF52840/nRF52833/nRF5340) has now reached a v1.0.0 milestone in NCS v1.7.0:

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/releases/release-notes-1.7.0.html#zigbee

PS: Most of the links comes from zigpy/zigpy#394 which is a request for nRF5 Zigbee radio library for Nordic Semi nRF52 / nRF53.

zigpy-cli - socket interface

Just a suggestion - add a daemon mode with a socket interface.

The socket interface would accept the same commands as the CLI but without addint the call to zigpy or the radio setting.

So the daemon could be started like this:

zigpy radio znp /dev/ttyUSB0 daemon --host 127.0.0.4 --port 3400

And then connections can be made to port 3400 to send commands, using telnet, netcat or whatever.

Example:

telnet 127.0.0.4 3400

Then inside the telnet session:

network info

The parsing of the commands would remain the same as on the cli, but then the tool would have a broader range of uses and the zigpy session can keep on running without requiring reinitialisation, potentially reporting incoming messages as well.

Error using zigpy-cli

I have a jn5169 usb dongle for which I flashed zigate firmware.

Trying to use zigpy-cli, I got the following error, how should I use it properly?

PS D:\Workspace\zigpy-cli> zigpy radio zigate COM12 info
Traceback (most recent call last):
  File "C:\Users\lyy\AppData\Local\Programs\Python\Python310\Scripts\zigpy-script.py", line 33, in <module>
    sys.exit(load_entry_point('zigpy-cli==0.0.1', 'console_scripts', 'zigpy')())
  File "C:\Users\lyy\AppData\Local\Programs\Python\Python310\Scripts\zigpy-script.py", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "C:\Users\lyy\AppData\Local\Programs\Python\Python310\lib\importlib\metadata\__init__.py", line 162, in load
    module = import_module(match.group('module'))
  File "C:\Users\lyy\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\lyy\AppData\Local\Programs\Python\Python310\lib\site-packages\zigpy_cli\__main__.py", line 1, in <module>
    import zigpy_cli.ota  # noqa: F401
  File "C:\Users\lyy\AppData\Local\Programs\Python\Python310\lib\site-packages\zigpy_cli\ota.py", line 7, in <module>
    from zigpy.ota.image import ElementTagId, parse_ota_image
ImportError: cannot import name 'parse_ota_image' from 'zigpy.ota.image' (C:\Users\lyy\AppData\Local\Programs\Python\Python310\lib\site-packages\zigpy\ota\image.py)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.