@@ -182,6 +182,11 @@ async def _get_association_state(self):
182
182
async def send_packet (self , packet : zigpy .types .ZigbeePacket ) -> None :
183
183
LOGGER .debug ("Sending packet %r" , packet )
184
184
185
+ try :
186
+ device = self .get_device_with_address (packet .dst )
187
+ except (KeyError , ValueError ):
188
+ device = None
189
+
185
190
tx_opts = TXOptions .NONE
186
191
187
192
if packet .extended_timeout :
@@ -193,17 +198,25 @@ async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None:
193
198
long_addr = UNKNOWN_IEEE
194
199
short_addr = UNKNOWN_NWK
195
200
196
- if packet .dst .addr_mode == zigpy .types .AddrMode .IEEE :
197
- long_addr = packet .dst .address
198
- elif packet .dst .addr_mode == zigpy .types .AddrMode .Broadcast :
201
+ if packet .dst .addr_mode == zigpy .types .AddrMode .Broadcast :
199
202
long_addr = EUI64 (
200
203
[
201
204
zigpy .types .uint8_t (b )
202
205
for b in packet .dst .address .to_bytes (8 , "little" )
203
206
]
204
207
)
205
- else :
206
208
short_addr = packet .dst .address
209
+ elif packet .dst .addr_mode == zigpy .types .AddrMode .Group :
210
+ short_addr = packet .dst .address
211
+ elif packet .dst .addr_mode == zigpy .types .AddrMode .IEEE :
212
+ long_addr = EUI64 (packet .dst .address )
213
+ elif device is not None :
214
+ long_addr = EUI64 (device .ieee )
215
+ short_addr = device .nwk
216
+ else :
217
+ raise zigpy .exceptions .DeliveryError (
218
+ "Cannot send a packet to a device without a known IEEE address"
219
+ )
207
220
208
221
send_req = self ._api .tx_explicit (
209
222
long_addr ,
0 commit comments