4343 ClientNotificationConnectionDropped ,
4444 ClientNotificationConnectionFailed ,
4545 ClientNotificationEpacketReceived ,
46+ ClientNotificationObservedDevices ,
4647 GatewayRequestConnectionRelease ,
4748 GatewayRequestConnectionRequest ,
4849 GatewayRequestEpacketSend ,
50+ GatewayRequestObservedDevices ,
4951 LocalServer ,
5052 default_multicast_address ,
5153)
@@ -388,6 +390,19 @@ def _handle_conn_release(self, req: GatewayRequestConnectionRelease):
388390 Console .log_tx (cmd .ptype , len (encrypted ))
389391 self ._common .port .write (encrypted )
390392
393+ def _handle_observed_devices (self ):
394+ observed_devices = {}
395+ for device , state in self ._common .ddb .devices .items ():
396+ info = {}
397+ if state .network_id is not None :
398+ info ["network_id" ] = state .network_id
399+ if state .device_id is not None :
400+ info ["device_id" ] = state .device_id
401+ if self ._common .ddb .gateway == device :
402+ info ["gateway" ] = True
403+ observed_devices [device ] = info
404+ self ._common .server .broadcast (ClientNotificationObservedDevices (observed_devices ))
405+
391406 def _iter (self ) -> None :
392407 if self ._common .server is None :
393408 time .sleep (1.0 )
@@ -401,6 +416,8 @@ def _iter(self) -> None:
401416 self ._handle_conn_request (req )
402417 elif isinstance (req , GatewayRequestConnectionRelease ):
403418 self ._handle_conn_release (req )
419+ elif isinstance (req , GatewayRequestObservedDevices ):
420+ self ._handle_observed_devices ()
404421 else :
405422 Console .log_error (f"Unhandled request { type (req )} " )
406423
0 commit comments