diff --git a/zigpy_xbee/__init__.py b/zigpy_xbee/__init__.py index 917e6cb..76e502e 100644 --- a/zigpy_xbee/__init__.py +++ b/zigpy_xbee/__init__.py @@ -1,5 +1,5 @@ MAJOR_VERSION = 0 MINOR_VERSION = 16 -PATCH_VERSION = "0" +PATCH_VERSION = "1" __short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__ = f"{__short_version__}.{PATCH_VERSION}" diff --git a/zigpy_xbee/zigbee/application.py b/zigpy_xbee/zigbee/application.py index 639ba47..2b58e10 100644 --- a/zigpy_xbee/zigbee/application.py +++ b/zigpy_xbee/zigbee/application.py @@ -182,6 +182,11 @@ async def _get_association_state(self): async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None: LOGGER.debug("Sending packet %r", packet) + try: + device = self.get_device_with_address(packet.dst) + except (KeyError, ValueError): + device = None + tx_opts = TXOptions.NONE if packet.extended_timeout: @@ -193,17 +198,25 @@ async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None: long_addr = UNKNOWN_IEEE short_addr = UNKNOWN_NWK - if packet.dst.addr_mode == zigpy.types.AddrMode.IEEE: - long_addr = packet.dst.address - elif packet.dst.addr_mode == zigpy.types.AddrMode.Broadcast: + if packet.dst.addr_mode == zigpy.types.AddrMode.Broadcast: long_addr = EUI64( [ zigpy.types.uint8_t(b) for b in packet.dst.address.to_bytes(8, "little") ] ) - else: short_addr = packet.dst.address + elif packet.dst.addr_mode == zigpy.types.AddrMode.Group: + short_addr = packet.dst.address + elif packet.dst.addr_mode == zigpy.types.AddrMode.IEEE: + long_addr = EUI64(packet.dst.address) + elif device is not None: + long_addr = EUI64(device.ieee) + short_addr = device.nwk + else: + raise zigpy.exceptions.DeliveryError( + "Cannot send a packet to a device without a known IEEE address" + ) send_req = self._api.tx_explicit( long_addr,