Git Product home page Git Product logo

zigpy-xbee's Introduction

zigpy

Build Coverage Status

zigpy is a hardware independent Zigbee protocol stack integration project to implement Zigbee standard specifications as a Python 3 library.

Zigbee integration via zigpy allows you to connect one of many off-the-shelf Zigbee Coordinator adapters using one of the available Zigbee radio library modules compatible with zigpy to control Zigbee based devices. There is currently support for controlling Zigbee device types such as binary sensors (e.g., motion and door sensors), sensors (e.g., temperature sensors), lights, switches, buttons, covers, fans, climate control equipment, locks, and intruder alarm system devices. Note that Zigbee Green Power devices currently are unsupported.

Zigbee stacks and hardware from many different hardware chip manufacturers are supported via radio libraries which translate their proprietary communication protocol into a common API which is shared among all radio libraries for zigpy. If some Zigbee stack or Zigbee Coordinator hardware for other manufacturers is not supported by yet zigpy it is possible for any independent developer to step-up and develop a new radio library for zigpy which translates its proprietary communication protocol into the common API that zigpy can understand.

zigpy contains common code implementing ZCL (Zigbee Cluster Library) and ZDO (Zigbee Device Object) application state management which is being used by various radio libraries implementing the actual interface with the radio modules from different manufacturers. The separate radio libraries interface with radio hardware adapters/modules over USB and GPIO using different native UART serial protocols.

The ZHA integration component for Home Assistant, the Zigbee Plugin for Domoticz, and the Zigbee Plugin for Jeedom (competing open-source home automation software) are all using zigpy libraries as dependencies, as such they could be used as references of different implementations if looking to integrate a Zigbee solution into your application.

Zigbee device OTA updates

zigpy have ability to download and perform Zigbee OTAU (Over-The-Air Updates) of Zigbee devices firmware. The Zigbee OTA update firmware image files should conform to standard Zigbee OTA format and OTA provider source URLs need to be published for public availability. Updates from a local OTA update directory also is also supported and can be used as an option for offline firmware updates if user provide correct Zigbee OTA formatted firmware files themselves.

Support for automatic download from existing online OTA providers in zigpy OTA provider code is currently only available for IKEA, Inovelli, LEDVANCE/OSRAM, SALUS/Computime, and SONOFF/ITEAD devices. Support for additional OTA providers for other manufacturers devices could be added to zigpy in the future, if device manufacturers publish their firmware images publicly and developers contribute the needed download code for them.

How to install and test, report bugs, or contribute to this project

For specific instructions on how-to install and test zigpy or contribute bug-reports and code to this project please see the guidelines in the CONTRIBUTING.md file:

This CONTRIBUTING.md file will contain information about using zigpy, testing new releases, troubleshooting and bug-reporting as, as well as library + code instructions for developers and more. This file also contain short summaries and links to other related projects that directly or indirectly depends in zigpy libraries.

You can contribute to this project either as an end-user, a tester (advanced user contributing constructive issue/bug-reports) or as a developer contributing code.

Compatible Zigbee coordinator hardware

Radio libraries for zigpy are separate projects with their own repositories and include bellows (for communicating with Silicon Labs EmberZNet based radios), zigpy-deconz (for communicating with deCONZ based radios from Dresden Elektronik), and zigpy-xbee (for communicating with XBee based Zigbee radios), zigpy-zigate for communicating with ZiGate based radios, zigpy-znp or zigpy-cc for communicating with Texas Instruments based radios that have Z-Stack ZNP coordinator firmware.

Note! Zigbee 3.0 support or not in zigpy depends primarily on your Zigbee coordinator hardware and its firmware. Some Zigbee coordinator hardware support Zigbee 3.0 but might be shipped with an older firmware which does not, in which case may want to upgrade the firmware manually yourself. Some other Zigbee coordinator hardware may not support a firmware that is capable of Zigbee 3.0 at all but can still be fully functional and feature complete for your needs, (this is very common as many if not most Zigbee devices do not yet Zigbee 3.0 or are backwards-compable with a Zigbee profile that is support by your Zigbee coordinator hardware and its firmware). As a general rule, newer Zigbee coordinator hardware released can normally support Zigbee 3.0 firmware and it is up to its manufacturer to make such firmware available for them.

Compatible zigpy radio libraries

  • Digi XBee based Zigbee radios via the zigpy-xbee library for zigpy.
  • dresden elektronik deCONZ based Zigbee radios via the zigpy-deconz library for zigpy.
  • Silicon Labs (EmberZNet) based Zigbee radios using the EZSP protocol via the bellows library for zigpy.
  • Texas Instruments based Zigbee radios with all compatible Z-Stack firmware via the zigpy-znp library for zigpy.
  • ZiGate based ZigBee radios via the zigpy-zigate library for zigpy.

Legacy or obsolete zigpy radio libraries

  • Texas Instruments with Z-Stack legacy firmware via the zigpy-cc library for zigpy.

Release packages available via PyPI

New packages of tagged versions are also released via the "zigpy" project on PyPI

Older packages of tagged versions are still available on the "zigpy-homeassistant" project on PyPI

Packages of tagged versions of the radio libraries are released via separate projects on PyPI

zigpy-xbee's People

Contributors

adminiuga avatar damarco avatar gamester17 avatar hedda avatar onkelbeh avatar puddly avatar rcloran avatar schiermi avatar shulyaka avatar thejulianjes avatar

Stargazers

 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

zigpy-xbee's Issues

Exception in callback when Aqara Human Motion Sensor detects motion

I'm using a S2B-Pro as coordinator.

2019-01-13 22:38:23 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f60a6308d68>, Serial<id=0x7f60a6308f28, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
AttributeError: 'NoneType' object has no attribute 'handle_rx'
2019-01-13 22:38:23 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f60a6308d68>, Serial<id=0x7f60a6308f28, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
AttributeError: 'NoneType' object has no attribute 'handle_rx'

[DEPENDENCY] The pre-commit/mirrors-isort mirror repository is deprecated so should use isort directly instead?

Probably need to update dependencies in .pre-commit-config.yaml & setup.cfg & tox.ini plus possibly other source for isort or in other way seperate isort dependency for all zigpy libraries as upstream repo for isort has moved?

@Adminiuga This is only to bring this to your attention as I don't know the best solution for this, I just happened to stumble on the fact that the mirror of isort package for pre-commit is deprecated and that upstream isort has also recently been moved. I think that this applies to all zigpy libraries, including zigpy, bellows, zigpy-cc, zigpy-deconz, zigpy-xbee, zigpy-zigate, and zha-device-handlers, plus zigpy-znp as well?

For reference, updated now in zigpy, zigpy-deconz, and bellows:

zigpy/zigpy#488

zigpy/zigpy-deconz#124

zigpy/bellows#349

See comment in https://github.com/pre-commit/mirrors-isort where is says that the pre-commit mirror for isort repository is deprecated, and to instead use isort directly.

Mirror of isort package for pre-commit split and moved

For pre-commit: see https://github.com/pre-commit/pre-commit

For isort: see https://github.com/PyCQA/isort

Also note that isort upstream recently moved from https://github.com/timothycrosley/isort to https://github.com/PyCQA/isort

Currently, the latest release is 5.5.0 (as of September 3, 2020) and since isort 5.0.0 and later it now requires Python 3.6 or later:

https://pycqa.github.io/isort/CHANGELOG/

Some more information should be available at https://pycqa.github.io/isort/

PS: If you decide on changing this then please also remember to reflect the changes in the CONTRIBUTING.md file for zigpy:

https://github.com/zigpy/zigpy/blob/dev/CONTRIBUTING.md

zigpy/zigpy#490

Prerequicites

It is recommended that code is formatted with black and sorted with isort. The check format script that runs in CI will ensure that code meets this requirement and that it is correctly formatted with black. Instructions for installing black in many editors can be found here: https://github.com/psf/black#editor-integration

https://github.com/psf/black
https://github.com/timothycrosley/isort

Baudrate 9600 need to be specified for Digi XStick USB Adapter (XU-Z11)?

Apparently plug-and-play does maybe not currently work for Digi XBee Series 2 at 9600 baudrate?

https://www.digikey.com/en/product-highlight/d/digi-intl/xu-a11-and-xu-z11-xbee-xstick

I don't have one but noticed this issue reported and currency discussed for Home Assistant ZHA:

https://community.home-assistant.io/t/zha-with-digi-xstick/125934

Home Assistant community users only get it working by manually setting it to baud rate 9600 or?

Digi XStick USB Adapter (XU-Z11) is also sold as "Digi XStick 2", "Digi X-Stick ZB", "Digi XBee 2 USB Adapter" USB to XBee ZB Network Adapter. FCC part 15.247 (USA): MCQ-XSTICK2 / MCQ-STICK1

Errors "Handling AT command mode response" - "Couldn't ascii decode AT command mode response: 'ascii' codec can't decode byte 0x88 in position 3: ordinal not in range(128)"

I have been trying to get Home Assistant up and running with me XBee without success.

Looking at the debugs most of the XBee initialisation commands work, as can be seen in this except in the log. A command is sent and a frame is received-

2019-11-03 13:20:19 DEBUG (MainThread) [zigpy_xbee.uart] Sending: b'\x08\x0bSP\x03\x00'
2019-11-03 13:20:19 DEBUG (MainThread) [zigpy_xbee.uart] Frame received: b'\x88\x0bSP\x00'

Later in the log I see-

2019-11-03 19:07:03 DEBUG (MainThread) [zigpy_xbee.uart] Sending: b'\x08\rID'
2019-11-03 19:07:03 DEBUG (MainThread) [zigpy_xbee.uart] Couldn't ascii decode AT command mode response: 'ascii' codec can't decode byte 0x88 in position 3: ordinal not in range(128)
2019-11-03 19:07:03 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback SerialTransport._read_ready()
Traceback (most recent call last):
File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/srv/homeassistant/lib/python3.7/site-packages/serial_asyncio/init.py", line 106, in _read_ready
self._protocol.data_received(data)
File "/srv/homeassistant/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 79, in data_received
self.command_mode_rsp(rsp)
File "/srv/homeassistant/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 57, in command_mode_rsp
data = data.decode("ascii")
UnicodeDecodeError: 'ascii' codec can't decode byte 0x88 in position 3: ordinal not in range(128)
20

The command is sent but we then hit an exception processing the response.

[REQUEST] Automagically auto-detect port-path and discover radio-type?

This is a feature request that I'm not exactly sure if it belongs to the Home Assistant core, the ZHA integration for Home Assistant, to zigpy, to each and every radio library for zigpy, or in many of all those mentioned in order to be achieved. Anyway, my main point with this feature request is this:

Is it possible to add some kind of "auto-detect" scanning option for automatic discovery/detection of port-path and radio-type (with recommended select) to achieve an even more plug-and-play experience of the initial install/configuration of the ZHA integration in Home Assistant or a zigpy implementation in any other software for that matter? An option for a so-called "next next next" installation process if you will.

From an end-users point-of-view the ZHA integration implementation of zigpy I think that it would be absolutely awesome if the installation process could automagically detect exactly which type of Zigbee adapter(s) you have plugged in and which USB-port(s) that the Zigbee adapter(s) is plugged into. Is this possible?

I think nicest would probably be if the user would be greeted by an option for "auto-detect and recommend Zigbee adapter(s)" that you could then simply click for automagic plug-and-play configuration of your Zigbee stick hardware instead of having to manually type the full port-path and the radio-type as you have to do today in ZHA.

Such an automagical auto-detect port-path and discover radio-type would make the ZHA integration component in Home Assistant even easier to install and configure for first-time ZHA users by removing the need for end-user to manually configure port-path and radio-type.

I believe that a plug-and-play oriented hardware configuration could be the last piece that is missing to make the ZHA in Home Assistant a much more user-friendly initial installation and configuration process experience.

Coordinator backup

I'd like to start a discussion on how to back up the network key on XBee coordinators.
The issue is that on XBee devices the network key is write-only, so we have to remember it from the moment we set it. Luckily, we have a backup mechanism that we can use. Currently, however, we only use the last backup to restore the state if the device is not already configured, and optionally for verification.
Current flow:

  1. For a new network, we generate a new random key and write it to the device
  2. The key is kept in memory until the next restart, and will be saved in the backup once it is created.
  3. After the restart, we set the key to the default value (unknown), and because we can't get the key from the device, it remains unknown.

Suggestions:

  1. Enhance zigpy ControllerApplication.initialize() function to use last_backup to set the initial network_info (instead of default) before trying to load it from the device. Something like:
     async def initialize(self, *, auto_form: bool = False) -> None:
         """Starts the network on a connected radio, optionally forming one with random
         settings if necessary.
         """

         last_backup = self.backups.most_recent_backup()

+        if last_backup:
+            self.state.network_info = zigpy.state.NetworkInfo.from_dict(last_backup.network_info.as_dict())
+
         try:
             await self.load_network_info(load_devices=False)
         except zigpy.exceptions.NetworkNotFormed:

So the radio library would only update what it can, and the rest will remain from the backup.

  1. Pass last_backup as a new optional parameter to ControllerApplication.load_network_info and let the radio library (zigpy-xbee`) handle it as it wishes.
         try:
-            await self.load_network_info(load_devices=False)
+            await self.load_network_info(load_devices=False, last_backup=last_backup)
         except zigpy.exceptions.NetworkNotFormed:
  1. To avoid changes to zigpy, overload ControllerApplication.initialize() function in zigpy_xbee.zigbee.ControllerApplication, load last backup inside it and restore the network key in memory there:
    async def initialize(self, *, auto_form: bool = False) -> None:
        """Overloaded initialize() to restore unreadable info from backup."""

        last_backup = self.backups.most_recent_backup()

        if last_backup:
            self.state.network_info = zigpy.state.NetworkInfo.from_dict(last_backup.network_info.as_dict())

        await super().initialize(auto_form=auto_form)
  1. Do not try to read the key from backup, but perform implicit key rotation when making a new backup and the network key is not known. We can simply generate a new network key and write it to the device (and the backup), and it will be distributed to all devices in the network. Might be a bit tricky to implement it to do it only when the backup is created, and I also don't really like the idea of doing implicit actions like rotating the key when a user might not expect it.

  2. There is also a native backup functionality in newer firmwares (the 'BK' AT command), it requires an additional investigation and is not available for legacy modules.

[REQUEST] Energy detection scan with zigpy-xbee for XBee Zigbee based adapters

Requesting an "energy detection scan" feature in zigpy-xbee if possible matching what @puddly has recently added to zigpy-znp

Suggest implement similar channel energy scanning via some energy scanner tool but for XBee based firmware and hardware.

https://github.com/zha-ng/zigpy-znp

https://github.com/zha-ng/zigpy-znp/blob/dev/README.md

Energy scan

Perform an energy scan to find a quiet Zigbee channel:

$ python -m zigpy_znp.tools.energy_scan /dev/cu.usbmodem14101
Channel energy (mean of 1 / 5):
------------------------------------------------
 + Lower energy is better
 + Active Zigbee networks on a channel may still cause congestion
 + Using 26 in the USA may have lower TX power due to FCC 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    61.57%  #############################################################
 - 12    60.78%  ############################################################
 - 13    12.16%  ############
 - 14    58.43%  ##########################################################
 - 15    57.65%  #########################################################
 - 16    29.80%  #############################
 - 17    38.82%  ######################################
 - 18    47.06%  ###############################################
 - 19    36.86%  ####################################
 - 20    10.98%  ##########
 - 21    16.47%  ################
 - 22    33.73%  #################################
 - 23    30.59%  ##############################
 - 24    20.39%  ####################
 - 25     5.88%  #####
 - 26*   20.39%  ####################

[SUGGESTION] Move back to only using the PyPI-project "zigpy-xbee" and stop using the PyPI-project "zigpy-xbee-homeassistant"

Please consider moving back to only using the PyPI-project "zigpy-xbee" for the zigpy library package and stop using the PyPI-project "zigpy-xbee-homeassistant" to distribute the zigpy library package.

I understand that the active PyPI projects being named "zigpy-xbee-homeassistant", "zigpy-xbee-homeassistant", and "bellows-homeassistant" can be confusing to new developers, especially to those who wish to use zigpy, zigpy-xbee, and bellows without Home Assistant as they might think that Home Assistant is a requirement for using these libraries.

Note! This request is indirectly related to my suggestion to rename bellows -> zigpy/bellows#215

PS: @rcloran @Adminiuga & @damarco Regardless of above it is probably also a good idea if you could and would make a few more zigpy developers shared co-owner/co-author/co-maintainers of the "zigpy" and "zigpy-homeassistant" as well as "bellows" and "bellows-homeassistant" plus "zigpy-xbee" and "zigpy-xbee-homeassistant" projects on PyPI. That could help remove personal pressure as well as explicit dependence on specific individuals.

Maybe you can consider making ex. @dmulcahey and @puddly maintainers or those projects as well even if just as a back so that they, in turn, could give access to others if everyone else quit?

I have not seen that @damarco and @AndreasBomholtz as active with zigpy related projects for quite some time, however, @Adminiuga @dmulcahey and @puddly all seem to be very active (considering these are all still just hobby projects).

XBee as end device

Is it possible to use a XBee S2C as a ZigBee end device with this library? I.e. the XBee should join the network and it should be possible to send Home Automation profile commands to the ZigBee coordinator.

UnicodeDecodeError: 'ascii' codec can't decode byte 0x91 in position 3: ordinal not in range(128)

Hello, I am using zigpy_xbee inside homeassistant. It looks like sometimes parts of the API frame header are trying to be interpreted as ASCII. I also find a few other things in my log, which I will include and excerpt from

2019-06-05 06:58:55 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x71ff04f0>, Serial<id=0x71ff0510, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
File "/usr/local/lib/python3.7/site-packages/serial_asyncio/init.py", line 106, in _read_ready
self._protocol.data_received(data)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 78, in data_received
self.command_mode_rsp(rsp)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 55, in command_mode_rsp
data = data.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0x91 in position 3: ordinal not in range(128)
2019-06-05 07:30:17 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x71ff04f0>, Serial<id=0x71ff0510, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
File "/usr/local/lib/python3.7/site-packages/serial_asyncio/init.py", line 106, in _read_ready
self._protocol.data_received(data)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 78, in data_received
self.command_mode_rsp(rsp)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 55, in command_mode_rsp
data = data.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0x91 in position 3: ordinal not in range(128)
2019-06-05 07:34:48 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x71ff04f0>, Serial<id=0x71ff0510, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
File "/usr/local/lib/python3.7/site-packages/serial_asyncio/init.py", line 106, in _read_ready
self._protocol.data_received(data)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 78, in data_received
self.command_mode_rsp(rsp)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 55, in command_mode_rsp
data = data.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0x91 in position 3: ordinal not in range(128)
2019-06-05 08:30:46 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x71ff04f0>, Serial<id=0x71ff0510, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
File "/usr/local/lib/python3.7/site-packages/serial_asyncio/init.py", line 106, in _read_ready
self._protocol.data_received(data)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 78, in data_received
self.command_mode_rsp(rsp)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 55, in command_mode_rsp
data = data.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0x91 in position 3: ordinal not in range(128)
2019-06-05 08:39:39 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x71ff04f0>, Serial<id=0x71ff0510, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
File "/usr/local/lib/python3.7/site-packages/serial_asyncio/init.py", line 106, in _read_ready
self._protocol.data_received(data)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 78, in data_received
self.command_mode_rsp(rsp)
File "/usr/local/lib/python3.7/site-packages/zigpy_xbee/uart.py", line 55, in command_mode_rsp
data = data.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0x91 in position 3: ordinal not in range(128)
2019-06-05 08:43:40 WARNING (MainThread) [zigpy_xbee.zigbee.application] Unexpected response TSN=102 command=1 args=[[]]
2019-06-05 08:43:40 WARNING (MainThread) [zigpy_xbee.zigbee.application] Unexpected response TSN=107 command=1 args=[[]]
2019-06-05 08:43:40 WARNING (MainThread) [zigpy_xbee.zigbee.application] Unexpected response TSN=105 command=1 args=[[]]
2019-06-05 08:43:40 WARNING (MainThread) [zigpy_xbee.zigbee.application] Unexpected response TSN=111 command=1 args=[[]]

I am using a Xbee Pro S2C with whatever the latest zigbee firmware loaded. I'm wondering if I may not have it configured correctly or if these are bugs.

APS Encryption

Is APS encryption required? I have a device that will not join if encryption is enabled, but when it is disabled by changing the hard coded options byte in the _handle_reply and request functions from 0x20 to 0x00 in application.py, it joins and functions perfectly. I haven't noticed any negative effects on the other ZigBee devices either. Just curious if there are any downsides I'm missing.

Watchdog failures

#170 added a watchdog command (VR) that is sent every 30s to ensure the radio is still alive. It seems that the XBee serial protocol can't handle this and the command times out, causing a restart. If I add an asyncio.Lock around _at_partial it doesn't seem to help either.

@Shulyaka Are you familiar with the serial protocol? Do you happen to know why this would be the case?

Below is my patchset to enable a send lock:

diff --git a/zigpy_xbee/api.py b/zigpy_xbee/api.py
index b4a73da..51ba61f 100644
--- a/zigpy_xbee/api.py
+++ b/zigpy_xbee/api.py
@@ -289,6 +289,7 @@ class XBee:
         self._cmd_mode_future: Optional[asyncio.Future] = None
         self._reset: asyncio.Event = asyncio.Event()
         self._running: asyncio.Event = asyncio.Event()
+        self._send_lock = asyncio.Lock()
 
     @property
     def reset_event(self):
@@ -353,12 +354,13 @@ class XBee:
         LOGGER.debug("Remote AT command: %s %s", name, args)
         data = t.serialize(args, (AT_COMMANDS[name],))
         try:
-            return await asyncio.wait_for(
-                self._command(
-                    "remote_at", ieee, nwk, options, name.encode("ascii"), data
-                ),
-                timeout=REMOTE_AT_COMMAND_TIMEOUT,
-            )
+            async with self._send_lock:
+                return await asyncio.wait_for(
+                    self._command(
+                        "remote_at", ieee, nwk, options, name.encode("ascii"), data
+                    ),
+                    timeout=REMOTE_AT_COMMAND_TIMEOUT,
+                )
         except asyncio.TimeoutError:
             LOGGER.warning("No response to %s command", name)
             raise
@@ -367,10 +369,11 @@ class XBee:
         LOGGER.debug("%s command: %s %s", cmd_type, name, args)
         data = t.serialize(args, (AT_COMMANDS[name],))
         try:
-            return await asyncio.wait_for(
-                self._command(cmd_type, name.encode("ascii"), data),
-                timeout=AT_COMMAND_TIMEOUT,
-            )
+            async with self._send_lock:
+                return await asyncio.wait_for(
+                    self._command(cmd_type, name.encode("ascii"), data),
+                    timeout=AT_COMMAND_TIMEOUT,
+                )
         except asyncio.TimeoutError:
             LOGGER.warning("%s: No response to %s command", cmd_type, name)
             raise
@@ -597,9 +600,3 @@ class XBee:
                 raise APIException("Failed to configure XBee for API mode")
         finally:
             self.close()
-
-    def __getattr__(self, item):
-        """Handle supported command requests."""
-        if item in COMMAND_REQUESTS:
-            return functools.partial(self._command, item)
-        raise AttributeError(f"Unknown command {item}")
diff --git a/zigpy_xbee/zigbee/application.py b/zigpy_xbee/zigbee/application.py
index 2158b95..4ad8e62 100644
--- a/zigpy_xbee/zigbee/application.py
+++ b/zigpy_xbee/zigbee/application.py
@@ -302,7 +302,8 @@ class ControllerApplication(zigpy.application.ControllerApplication):
                 "Cannot send a packet to a device without a known IEEE address"
             )
 
-        send_req = self._api.tx_explicit(
+        send_req = self._api._command(
+            "tx_explicit",
             long_addr,
             short_addr,
             packet.src_ep or 0,
@@ -356,7 +357,7 @@ class ControllerApplication(zigpy.application.ControllerApplication):
         # Key type:
         # 0 = Pre-configured Link Key (KY command of the joining device)
         # 1 = Install Code With CRC (I? command of the joining device)
-        await self._api.register_joining_device(node, reserved, key_type, link_key)
+        await self._api._command("register_joining_device", node, reserved, key_type, link_key)
 
     def handle_modem_status(self, status):
         """Handle changed Modem Status of the device."""

Exception in callback when joining new node

I tried to join an Aqara Human Motion Sensor to my S2B-Pro coordinator. I therefore woke up the device several times, as you might figure from the numerous errors in the log.

2019-01-13 22:28:42 INFO (MainThread) [homeassistant.components.zha] Permitting joins for 60s
2019-01-13 22:28:50 INFO (MainThread) [zigpy.application] Device 0x49f6 (00:15:8d:00:02:b9:58:1e) joined the network
2019-01-13 22:28:50 INFO (MainThread) [zigpy.device] [0x49f6] Discovering endpoints
Config directory: /config
Tries remaining: 3
2019-01-13 22:28:50 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f9551a85080>, Serial<id=0x7f9551a85048, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/zigbee/application.py", line 106, in handle_rx
    tsn, command_id, is_reply, args = self.deserialize(device, src_ep, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
2019-01-13 22:28:51 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f9551a85080>, Serial<id=0x7f9551a85048, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/zigbee/application.py", line 106, in handle_rx
    tsn, command_id, is_reply, args = self.deserialize(device, src_ep, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
2019-01-13 22:28:53 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f9551a85080>, Serial<id=0x7f9551a85048, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/zigbee/application.py", line 106, in handle_rx
    tsn, command_id, is_reply, args = self.deserialize(device, src_ep, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
2019-01-13 22:28:53 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f9551a85080>, Serial<id=0x7f9551a85048, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/zigbee/application.py", line 106, in handle_rx
    tsn, command_id, is_reply, args = self.deserialize(device, src_ep, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
2019-01-13 22:28:58 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f9551a85080>, Serial<id=0x7f9551a85048, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/zigbee/application.py", line 106, in handle_rx
    tsn, command_id, is_reply, args = self.deserialize(device, src_ep, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
2019-01-13 22:29:01 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f9551a85080>, Serial<id=0x7f9551a85048, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/zigbee/application.py", line 106, in handle_rx
    tsn, command_id, is_reply, args = self.deserialize(device, src_ep, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
Tries remaining: 2
2019-01-13 22:29:03 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f9551a85080>, Serial<id=0x7f9551a85048, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/zigbee/application.py", line 106, in handle_rx
    tsn, command_id, is_reply, args = self.deserialize(device, src_ep, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
2019-01-13 22:29:08 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <zigpy_xbee.uart.Gateway object at 0x7f9551a85080>, Serial<id=0x7f9551a85048, open=True>(port='/dev/zigbee', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 43, in data_received
    self.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/uart.py", line 48, in frame_received
    self._api.frame_received(frame)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 207, in frame_received
    getattr(self, '_handle_%s' % (command, ))(data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 230, in _handle_explicit_rx_indicator
    self._app.handle_rx(*data)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/zigbee/application.py", line 106, in handle_rx
    tsn, command_id, is_reply, args = self.deserialize(device, src_ep, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
2019-01-13 22:29:09 INFO (MainThread) [zigpy.device] [0x49f6] Discovered endpoints: [1]
2019-01-13 22:29:09 INFO (MainThread) [zigpy.endpoint] [0x49f6:1] Discovering endpoint information
Tries remaining: 3
2019-01-13 22:29:15 WARNING (MainThread) [zigpy_xbee.zigbee.application] Unexpected response TSN=8 command=266 args=b'\x05\x00B\x16lumi.sensor_motion.aq2'
2019-01-13 22:29:15 WARNING (MainThread) [zigpy.endpoint] [0x49f6:1] Message on unknown cluster 0x0000
Tries remaining: 2
2019-01-13 22:29:23 INFO (MainThread) [zigpy.endpoint] [0x49f6:1] Discovered endpoint information: <SimpleDescriptor endpoint=1 profile=260 device_type=263 device_version=1 input_clusters=[0, 65535, 1030, 1024, 1280, 1, 3] output_clusters=[0, 25]>

Missing pins in api.py

/zigpy_xbee/api.py

# I/O commands
"IR": t.uint16_t,
"IC": t.uint16_t,
"P0": t.uint8_t,  # 0 - 5 (an Enum)
"P1": t.uint8_t,  # 0 - 5 (an Enum)
"P2": t.uint8_t,  # 0 - 5 (an Enum)
"P3": t.uint8_t,  # 0 - 5 (an Enum)
"D0": t.uint8_t,  # 0 - 5 (an Enum)
"D1": t.uint8_t,  # 0 - 5 (an Enum)
"D2": t.uint8_t,  # 0 - 5 (an Enum)
"D3": t.uint8_t,  # 0 - 5 (an Enum)
"D4": t.uint8_t,  # 0 - 5 (an Enum)
"D5": t.uint8_t,  # 0 - 5 (an Enum)
"D8": t.uint8_t,  # 0 - 5 (an Enum)
"LT": t.uint8_t,

# I/O commands

D6, D7, D9, D10, D11, D12, D13, D14 is missing and can't be used.

Infinite loop initializing new xbee

Hi!

I've just bought a new xbee and hook it up to my Home Assistant. I got an infinite loop at startup.
According to logs, zigpy-xbee is stuck inside _get_association_state function (called by startup).
My xbee repeatedly responds with FF to the AI command.
The specs say FF is 'Initialization time; no association status has been determined yet.' However because it's a new xbee (never used), I suspect it is normal to respond with FF, no one tried to initialize it yet at the time of calling the startup function.
What is the purpose of this loop anyway, is this a thing that xbee may take time to initialize?
Shall we replace
association_state = await self._get_association_state()
with
association_state = await self._api._at_command("AI")
in the setup fuction at least?
I think that would be sufficient, since all we need there is to find out whether to form network or not.

Device disconnection in XBee3 FW 1006 and above

Hi! I have an XBee3 as a coordinator. When I started adding Xiaomi sensors to my network I've noticed that they often disconnect. This seems to not apply to routers (including xiaomi relay), which stay connected even after losing power, or to end devices that connect via those routers, or to sensors that frequently update its value (such as illuminance sensors).
Strangely, this issue is rarely reproducible on other XBees, so I've been unable to prove it to the Digi support so far.
But I've found a workaround!
It appears that setting ET to a large value (e.g. 0x0E) magically makes things very stable. ET is one of the features introduced in 1006 and defines how long a router or end device should remember its parent router. And I say 'magically' because the command should not affect a coordinator at all.
Is it just me or other users may have a similar issue?
Could someone please help me confirm my observations or tell me where I am wrong?

Zigbee Green Power

Hi! I have an XBee3 working as a coordinator. I also have a couple of Zigbee Green Power Friends of Hue wall switches based on EnOcean PTM215Z module (https://fccid.io/SZV-PTM215Z/User-Manual/usersmanual-2073658.pdf). As per my understanding, while an XBee3 does not support the Green Power messages, it should still be able to receive them and forward to UART. However I was not able to achieve that: when I press the A0 button on the switch and release it after 10 seconds, I receive nothing on UART.
I understand they are not currently supported in software, but did anyone try to experiment with green power devices and achieved different results?

Not working anymore since Zigpy 0.53.3 Release

zigpy/zigpy#1174

Deprecated parameter "is_reply" was finally removed
And now error occured in

  File "/var/www/homeassistant/lib/python3.10/site-packages/zigpy_xbee/zigbee/application.py", line 327, in XBeeGroupResponse
    0x04: foundation.ZCLCommandDef(
TypeError: ZCLCommandDef.__init__() got an unexpected keyword argument 'is_reply'

Compatibility and support for the new "Digi XBee RR Zigbee RF Module"?

Anyone confirmed if the new Digi XBee RR Zigbee RF (xbee-rr/xbrr-24) modules been tested and are compatible with zigpy-xbee?

https://www.digi.com/company/press-releases/2022/digi-unveils-digi-xbee-rr-and-rapid-redesign

https://www.digi.com/xbee-rr

https://www.digi.com/products/embedded-systems/digi-xbee/rf-modules/2-4-ghz-rf-modules/digi-xbee-rr

If so then they can be added to zigpy-xbee README.md under the "Compatible hardware" section:

https://github.com/zigpy/zigpy-xbee/blob/dev/README.md#compatible-hardware

Example would be XBRR-24Z8ST (SMA Ant, Through-hole) and XBRR-24Z8UT (.FL Ant, Through-hole):

https://www.digi.com/products/models/xbrr-24z8st

https://www.digi.com/products/models/xbrr-24z8ut

This new Digi XBee RR series is the latest hardware and PRO has the ability to use higher transmit current/power for +19 dBm.

https://www.digi.com/products/embedded-systems/digi-xbee/rf-modules/2-4-ghz-rf-modules/digi-xbee-rr#partnumbers

https://eu.mouser.com/new/digi-international/digi-xbee-rr-zigbee-3-modules/

Part Number Datasheet Description

  • XBRR-24DMCM Zigbee-moduler - 802.15.4 XBee RR PRO, 2.4 GHz, DigiMesh, Chip Antenna, MMT, 1MB Flash / 96kb RAM
  • XBRR-24Z8UM Zigbee-moduler - 802.15.4 XBee RR PRO - 2.4 GHz ZB 3.0, U.FL Antenna Connector, MMT, 1 MB Flash, 96kB Ram
  • XBRR-24Z8UM-J Zigbee-moduler - 802.15.4 XBee RR - 2.4 GHz ZB 3.0, U.FL Antenna Connector, MMT, 1M/96K
  • XBRR-24Z8CM-J Zigbee-moduler - 802.15.4 XBee RR, 2.4 Ghz, Zigbee, Chip Antenna, MMT, 1M/96k
  • XBRR-24Z8PT-J Zigbee-moduler - 802.15.4 XBee RR, 2.4 Ghz, Zigbee, PCB Antenna, Through Hole, 1M/96K
  • XBRR-24Z8UT Zigbee-moduler - 802.15.4 XBee RR PRO, 2.4 GHz, ZigBee, U.FL, Through Hole, 1M/96K
  • XBRR-24Z8ST Zigbee-moduler - 802.15.4 XBee RR PRO, 2.4 GHz, ZigBee, SMA, Through Hole, 1M/96K
  • XBRR-24Z8RM Zigbee-moduler - 802.15.4 Digi XBee RR PRO, 2.4 Ghz, Zigbee 3.0, RF Pad Ant, MMT, 1M/96K
  • XBRR-24Z8UT-J Zigbee-moduler - 802.15.4 XBee RR, 2.4 Ghz, Zigbee, U.FL, Through Hole, 1M/96K
  • XBRR-24Z8RM-J Zigbee-moduler - 802.15.4 XBee RR - 2.4 GHz ZB 3.0, RF Pad Antenna, MMT, 1MB Flash, 96 kB Ram

Looks like this Digi XBee RR series are based on Silicon Labs EFR32MG hardware

https://www.digi.com/products/embedded-systems/digi-xbee/rf-modules/2-4-ghz-rf-modules/digi-xbee-rr#specifications

but using Digi's own XBee PRO Zigbee stack which comes pre-flashed or flashed with latest Digi's XCTU software version:

https://www.digi.com/resources/documentation/Digidocs/90002002/Default.htm#Tasks/t_load_zb_firmware.htm

https://www.digi.com/products/embedded-systems/digi-xbee/digi-xbee-tools/xctu

PS: Tip to Zigbee developers is that "Digi XBee RR Development Kit" (XKRR-Z8S-WZM) is listed under coming soon:

https://www.digi.com/products/models/xkrr-z8s-wzm

Another developer tip is that these XBee modules can be used in for example SparkFun's XBee Development Board series:

https://www.digi.com/blog/post/sparkfun-and-digi-xbee-ecosystem

test_form_network fails with zigpy 0.50.3

After upgrading zigpy to 0.50.3 we're seeing the following test case fail.

______________________________ test_form_network _______________________________

app = <zigpy_xbee.zigbee.application.ControllerApplication object at 0x7ffff5310f10>

    async def test_form_network(app):
        legacy_module = False
    
        async def mock_at_command(cmd, *args):
            if cmd == "MY":
                return 0x0000
            elif cmd == "WR":
                app._api.coordinator_started_event.set()
            elif cmd == "CE" and legacy_module:
                raise RuntimeError
            return None
    
        app._api._at_command = mock.MagicMock(
            spec=XBee._at_command, side_effect=mock_at_command
        )
        app._api._queued_at = mock.MagicMock(
            spec=XBee._at_command, side_effect=mock_at_command
        )
        app._get_association_state = mock.AsyncMock(
            spec=application.ControllerApplication._get_association_state,
            return_value=0x00,
        )
    
        app.write_network_info = mock.MagicMock(wraps=app.write_network_info)
    
>       await app.form_network()

tests/test_application.py:264: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/nix/store/1w2yfik564svfwg1wbvvlxp0pdqjddwr-python3.10-zigpy-0.50.3/lib/python3.10/site-packages/zigpy/application.py:211: in form_network
    await self.backups.restore_backup(
/nix/store/1w2yfik564svfwg1wbvvlxp0pdqjddwr-python3.10-zigpy-0.50.3/lib/python3.10/site-packages/zigpy/backups.py:162: in restore_backup
    await self.create_backup()
/nix/store/1w2yfik564svfwg1wbvvlxp0pdqjddwr-python3.10-zigpy-0.50.3/lib/python3.10/site-packages/zigpy/backups.py:128: in create_backup
    await self.app.load_network_info(load_devices=load_devices)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <zigpy_xbee.zigbee.application.ControllerApplication object at 0x7ffff5310f10>

    async def load_network_info(self, *, load_devices=False):
        # Load node info
        node_info = self.state.node_info
        node_info.nwk = zigpy.types.NWK(await self._api._at_command("MY"))
        serial_high = await self._api._at_command("SH")
        serial_low = await self._api._at_command("SL")
        node_info.ieee = zigpy.types.EUI64(
>           (serial_high.to_bytes(4, "big") + serial_low.to_bytes(4, "big"))[::-1]
        )
E       AttributeError: 'NoneType' object has no attribute 'to_bytes'

zigpy_xbee/zigbee/application.py:110: AttributeError

legacy modules are not initialized correctly after latest changes

Ha ๐Ÿ˜† I made sure explicitly not to use any of the never versions of the lib, because the recent changes made the library unusable on the Xbee Pro S2B platform, due to the commands that you introduced.

2019-01-14 01:05:53 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry /dev/zigbee for zha
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/config_entries.py", line 252, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/app/homeassistant/components/zha/__init__.py", line 158, in async_setup_entry
    await application_controller.startup(auto_form=True)
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/zigbee/application.py", line 54, in startup
    ce = await self._api._at_command('CE')
  File "/usr/local/lib/python3.6/site-packages/zigpy_xbee/api.py", line 220, in _at_command
    timeout=AT_COMMAND_TIMEOUT)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
Exception: 2

Test failures with zigpy==0.59.0

We're seeing a few test fail on zigpy-xbee==0.19.0 starting with zigpy==0.59.0, which is required by home-assistant==2023.11.0.

zigpy-xbee> FAILED tests/test_application.py::test_rx - AssertionError: Expected 'mock' to be called once. Called 0 times.
zigpy-xbee> FAILED tests/test_application.py::test_rx_nwk_0000 - AssertionError: assert 0 == 1
zigpy-xbee> FAILED tests/test_application.py::test_device_join_new - RuntimeError: no running event loop
zigpy-xbee> FAILED tests/test_application.py::test_device_join_inconsistent_nwk - RuntimeError: no running event loop
zigpy-xbee> FAILED tests/test_application.py::test_device_join_inconsistent_ieee - RuntimeError: no running event loop
zigpy-xbee> FAILED tests/test_application.py::test_rx_device_annce - AssertionError: assert 0 == 1
Full log
zigpy-xbee> ============================= test session starts ==============================
zigpy-xbee> platform linux -- Python 3.11.5, pytest-7.4.2, pluggy-1.2.0
zigpy-xbee> rootdir: /build/source
zigpy-xbee> configfile: pyproject.toml
zigpy-xbee> plugins: asyncio-0.21.1
zigpy-xbee> asyncio: mode=Mode.AUTO
zigpy-xbee> collected 110 items / 1 deselected / 109 selected                              
zigpy-xbee> 
zigpy-xbee> tests/test_api.py ...........................................            [ 39%]
zigpy-xbee> tests/test_application.py .FF..FFF..................F.........           [ 72%]
zigpy-xbee> tests/test_types.py .......                                              [ 78%]
zigpy-xbee> tests/test_uart.py .......................                               [100%]
zigpy-xbee> 
zigpy-xbee> =================================== FAILURES ===================================
zigpy-xbee> ___________________________________ test_rx ____________________________________
zigpy-xbee> 
zigpy-xbee> app = 
zigpy-xbee> 
zigpy-xbee>     def test_rx(app):
zigpy-xbee>         """Test message receiving."""
zigpy-xbee>         device = mock.MagicMock()
zigpy-xbee>         app.handle_message = mock.MagicMock()
zigpy-xbee>         _test_rx(app, device, 0x1234, data=b"\x01\x02\x03\x04")
zigpy-xbee> >       app.handle_message.assert_called_once_with(
zigpy-xbee>             sender=device,
zigpy-xbee>             profile=mock.sentinel.profile_id,
zigpy-xbee>             cluster=mock.sentinel.cluster_id,
zigpy-xbee>             src_ep=mock.sentinel.src_ep,
zigpy-xbee>             dst_ep=mock.sentinel.dst_ep,
zigpy-xbee>             message=b"\x01\x02\x03\x04",
zigpy-xbee>             dst_addressing=t.AddrMode.NWK,
zigpy-xbee>         )
zigpy-xbee> 
zigpy-xbee> tests/test_application.py:118: 
zigpy-xbee> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
zigpy-xbee> 
zigpy-xbee> self = , args = ()
zigpy-xbee> kwargs = {'cluster': sentinel.cluster_id, 'dst_addressing': , 'dst_ep': sentinel.dst_ep, 'message': b'\x01\x02\x03\x04', ...}
zigpy-xbee> msg = "Expected 'mock' to be called once. Called 0 times."
zigpy-xbee> 
zigpy-xbee>     def assert_called_once_with(self, /, *args, **kwargs):
zigpy-xbee>         """assert that the mock was called exactly once and that that call was
zigpy-xbee>         with the specified arguments."""
zigpy-xbee>         if not self.call_count == 1:
zigpy-xbee>             msg = ("Expected '%s' to be called once. Called %s times.%s"
zigpy-xbee>                    % (self._mock_name or 'mock',
zigpy-xbee>                       self.call_count,
zigpy-xbee>                       self._calls_repr()))
zigpy-xbee> >           raise AssertionError(msg)
zigpy-xbee> E           AssertionError: Expected 'mock' to be called once. Called 0 times.
zigpy-xbee> 
zigpy-xbee> /nix/store/ffll6glz3gwx342z0ch8wx30p5cnqz1z-python3-3.11.5/lib/python3.11/unittest/mock.py:950: AssertionError
zigpy-xbee> _______________________________ test_rx_nwk_0000 _______________________________
zigpy-xbee> 
zigpy-xbee> app = 
zigpy-xbee> 
zigpy-xbee>     def test_rx_nwk_0000(app):
zigpy-xbee>         """Test receiving self-addressed message."""
zigpy-xbee>         app._handle_reply = mock.MagicMock()
zigpy-xbee>         app.handle_message = mock.MagicMock()
zigpy-xbee>         app.get_device = mock.MagicMock()
zigpy-xbee>         app.handle_rx(
zigpy-xbee>             b"\x01\x02\x03\x04\x05\x06\x07\x08",
zigpy-xbee>             0x0000,
zigpy-xbee>             mock.sentinel.src_ep,
zigpy-xbee>             mock.sentinel.dst_ep,
zigpy-xbee>             mock.sentinel.cluster_id,
zigpy-xbee>             mock.sentinel.profile_id,
zigpy-xbee>             mock.sentinel.rxopts,
zigpy-xbee>             b"",
zigpy-xbee>         )
zigpy-xbee> >       assert app.handle_message.call_count == 1
zigpy-xbee> E       AssertionError: assert 0 == 1
zigpy-xbee> E        +  where 0 = .call_count
zigpy-xbee> E        +    where  = .handle_message
zigpy-xbee> 
zigpy-xbee> tests/test_application.py:144: AssertionError
zigpy-xbee> _____________________________ test_device_join_new _____________________________
zigpy-xbee> 
zigpy-xbee> app = 
zigpy-xbee> device = ._device at 0x7ffff4cd9bc0>
zigpy-xbee> 
zigpy-xbee>     def test_device_join_new(app, device):
zigpy-xbee>         """Test device join."""
zigpy-xbee>         dev = device()
zigpy-xbee>         data = b"\xee" + dev.nwk.serialize() + dev.ieee.serialize() + b"\x40"
zigpy-xbee>     
zigpy-xbee> >       _device_join(app, dev, data)
zigpy-xbee> 
zigpy-xbee> tests/test_application.py:238: 
zigpy-xbee> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
zigpy-xbee> tests/test_application.py:228: in _device_join
zigpy-xbee>     _test_rx(app, dev, dev.nwk, dst_ep, cluster_id, data)
zigpy-xbee> tests/test_application.py:101: in _test_rx
zigpy-xbee>     app.handle_rx(
zigpy-xbee> zigpy_xbee/zigbee/application.py:375: in handle_rx
zigpy-xbee>     self.packet_received(
zigpy-xbee> /nix/store/1ivd9cbi5i2d3p5abq2kxyswnpjbbkl9-python3.11-zigpy-0.59.0/lib/python3.11/site-packages/zigpy/application.py:985: in packet_received
zigpy-xbee>     device.schedule_initialize()
zigpy-xbee> /nix/store/1ivd9cbi5i2d3p5abq2kxyswnpjbbkl9-python3.11-zigpy-0.59.0/lib/python3.11/site-packages/zigpy/device.py:162: in schedule_initialize
zigpy-xbee>     self._initialize_task = asyncio.create_task(self.initialize())
zigpy-xbee> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
zigpy-xbee> 
zigpy-xbee> coro = 
zigpy-xbee> 
zigpy-xbee>     def create_task(coro, *, name=None, context=None):
zigpy-xbee>         """Schedule the execution of a coroutine object in a spawn task.
zigpy-xbee>     
zigpy-xbee>         Return a Task object.
zigpy-xbee>         """
zigpy-xbee> >       loop = events.get_running_loop()
zigpy-xbee> E       RuntimeError: no running event loop
zigpy-xbee> 
zigpy-xbee> /nix/store/ffll6glz3gwx342z0ch8wx30p5cnqz1z-python3-3.11.5/lib/python3.11/asyncio/tasks.py:371: RuntimeError
zigpy-xbee> ______________________ test_device_join_inconsistent_nwk _______________________
zigpy-xbee> 
zigpy-xbee> app = 
zigpy-xbee> device = ._device at 0x7ffff4cd93a0>
zigpy-xbee> 
zigpy-xbee>     def test_device_join_inconsistent_nwk(app, device):
zigpy-xbee>         """Test device join inconsistent NWK."""
zigpy-xbee>         dev = device()
zigpy-xbee>         data = b"\xee" + b"\x01\x02" + dev.ieee.serialize() + b"\x40"
zigpy-xbee>     
zigpy-xbee> >       _device_join(app, dev, data)
zigpy-xbee> 
zigpy-xbee> tests/test_application.py:246: 
zigpy-xbee> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
zigpy-xbee> tests/test_application.py:228: in _device_join
zigpy-xbee>     _test_rx(app, dev, dev.nwk, dst_ep, cluster_id, data)
zigpy-xbee> tests/test_application.py:101: in _test_rx
zigpy-xbee>     app.handle_rx(
zigpy-xbee> zigpy_xbee/zigbee/application.py:375: in handle_rx
zigpy-xbee>     self.packet_received(
zigpy-xbee> /nix/store/1ivd9cbi5i2d3p5abq2kxyswnpjbbkl9-python3.11-zigpy-0.59.0/lib/python3.11/site-packages/zigpy/application.py:985: in packet_received
zigpy-xbee>     device.schedule_initialize()
zigpy-xbee> /nix/store/1ivd9cbi5i2d3p5abq2kxyswnpjbbkl9-python3.11-zigpy-0.59.0/lib/python3.11/site-packages/zigpy/device.py:162: in schedule_initialize
zigpy-xbee>     self._initialize_task = asyncio.create_task(self.initialize())
zigpy-xbee> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
zigpy-xbee> 
zigpy-xbee> coro = 
zigpy-xbee> 
zigpy-xbee>     def create_task(coro, *, name=None, context=None):
zigpy-xbee>         """Schedule the execution of a coroutine object in a spawn task.
zigpy-xbee>     
zigpy-xbee>         Return a Task object.
zigpy-xbee>         """
zigpy-xbee> >       loop = events.get_running_loop()
zigpy-xbee> E       RuntimeError: no running event loop
zigpy-xbee> 
zigpy-xbee> /nix/store/ffll6glz3gwx342z0ch8wx30p5cnqz1z-python3-3.11.5/lib/python3.11/asyncio/tasks.py:371: RuntimeError
zigpy-xbee> ______________________ test_device_join_inconsistent_ieee ______________________
zigpy-xbee> 
zigpy-xbee> app = 
zigpy-xbee> device = ._device at 0x7ffff4cd9a80>
zigpy-xbee> 
zigpy-xbee>     def test_device_join_inconsistent_ieee(app, device):
zigpy-xbee>         """Test device join inconsistent IEEE."""
zigpy-xbee>         dev = device()
zigpy-xbee>         data = b"\xee" + dev.nwk.serialize() + b"\x01\x02\x03\x04\x05\x06\x07\x08" + b"\x40"
zigpy-xbee>     
zigpy-xbee> >       _device_join(app, dev, data)
zigpy-xbee> 
zigpy-xbee> tests/test_application.py:254: 
zigpy-xbee> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
zigpy-xbee> tests/test_application.py:228: in _device_join
zigpy-xbee>     _test_rx(app, dev, dev.nwk, dst_ep, cluster_id, data)
zigpy-xbee> tests/test_application.py:101: in _test_rx
zigpy-xbee>     app.handle_rx(
zigpy-xbee> zigpy_xbee/zigbee/application.py:375: in handle_rx
zigpy-xbee>     self.packet_received(
zigpy-xbee> /nix/store/1ivd9cbi5i2d3p5abq2kxyswnpjbbkl9-python3.11-zigpy-0.59.0/lib/python3.11/site-packages/zigpy/application.py:985: in packet_received
zigpy-xbee>     device.schedule_initialize()
zigpy-xbee> /nix/store/1ivd9cbi5i2d3p5abq2kxyswnpjbbkl9-python3.11-zigpy-0.59.0/lib/python3.11/site-packages/zigpy/device.py:162: in schedule_initialize
zigpy-xbee>     self._initialize_task = asyncio.create_task(self.initialize())
zigpy-xbee> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
zigpy-xbee> 
zigpy-xbee> coro = 
zigpy-xbee> 
zigpy-xbee>     def create_task(coro, *, name=None, context=None):
zigpy-xbee>         """Schedule the execution of a coroutine object in a spawn task.
zigpy-xbee>     
zigpy-xbee>         Return a Task object.
zigpy-xbee>         """
zigpy-xbee> >       loop = events.get_running_loop()
zigpy-xbee> E       RuntimeError: no running event loop
zigpy-xbee> 
zigpy-xbee> /nix/store/ffll6glz3gwx342z0ch8wx30p5cnqz1z-python3-3.11.5/lib/python3.11/asyncio/tasks.py:371: RuntimeError
zigpy-xbee> _____________________________ test_rx_device_annce _____________________________
zigpy-xbee> 
zigpy-xbee> app = 
zigpy-xbee> ieee = 07:06:05:04:03:02:01:00, nwk = 256
zigpy-xbee> 
zigpy-xbee>     def test_rx_device_annce(app, ieee, nwk):
zigpy-xbee>         """Test receiving device announce."""
zigpy-xbee>         dst_ep = 0
zigpy-xbee>         cluster_id = zdo_t.ZDOCmd.Device_annce
zigpy-xbee>         device = mock.MagicMock()
zigpy-xbee>         device.status = device.Status.NEW
zigpy-xbee>         device.zdo = zigpy.zdo.ZDO(None)
zigpy-xbee>         app.get_device = mock.MagicMock(return_value=device)
zigpy-xbee>         app.handle_join = mock.MagicMock()
zigpy-xbee>         app.handle_message = mock.MagicMock()
zigpy-xbee>     
zigpy-xbee>         data = t.uint8_t(0xAA).serialize()
zigpy-xbee>         data += nwk.serialize()
zigpy-xbee>         data += ieee.serialize()
zigpy-xbee>         data += t.uint8_t(0x8E).serialize()
zigpy-xbee>     
zigpy-xbee>         app.handle_rx(
zigpy-xbee>             ieee,
zigpy-xbee>             nwk,
zigpy-xbee>             mock.sentinel.src_ep,
zigpy-xbee>             dst_ep,
zigpy-xbee>             cluster_id,
zigpy-xbee>             mock.sentinel.profile_id,
zigpy-xbee>             mock.sentinel.rx_opt,
zigpy-xbee>             data,
zigpy-xbee>         )
zigpy-xbee>     
zigpy-xbee> >       assert app.handle_message.call_count == 1
zigpy-xbee> E       AssertionError: assert 0 == 1
zigpy-xbee> E        +  where 0 = .call_count
zigpy-xbee> E        +    where  = .handle_message
zigpy-xbee> 
zigpy-xbee> tests/test_application.py:639: AssertionError

LQI and RSSI not available?

ZHA is showing LQI and RSSI as unknown with an xbee3 and an old xbee2. Is this unsupported on the xbee module itself or a limitation of this library?

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.