@@ -421,7 +421,7 @@ async def _async_post_init(self) -> None:
421421
422422 # Initialize WebsocketManager ic-dev21
423423 self .websocket_manager = WebsocketManager (
424- self .session , self .async_request , self ._state_yaml , set_state
424+ self .session , self .async_request , self ._state_yaml , set_state , api = self
425425 )
426426 await self .websocket_manager .initialize_websockets ()
427427
@@ -847,8 +847,6 @@ async def get_devices(self, location_id: int) -> list[dict[str, Any]]:
847847 url = self ._get_url ("Devices" , location_id = location_id )
848848 LOG .debug ("Devices URL is %s" , url )
849849 devices = await self .async_request ("get" , url )
850-
851- #TODO: retirer bloc else, sert comme plus à rien
852850 else :
853851 # No URN available, use REST
854852 LOG .debug ("No URN available, using REST endpoint" )
@@ -891,13 +889,20 @@ async def wait_for_device_cache(self, timeout: float = 10.0) -> bool:
891889 Returns:
892890 True if cache was populated, False if timeout occurred
893891 """
892+ import time
893+ start_time = time .time ()
894+ LOG .debug ("Waiting for websocket device cache (timeout: %.1fs)..." , timeout )
895+
894896 try :
895897 await asyncio .wait_for (self ._device_cache_ready .wait (), timeout = timeout )
896- LOG .debug ("Device cache ready after waiting" )
898+ elapsed = time .time () - start_time
899+ LOG .debug ("Device cache ready after %.2f seconds" , elapsed )
897900 return True
898901 except asyncio .TimeoutError :
902+ elapsed = time .time () - start_time
899903 LOG .warning (
900- "Timeout waiting for websocket device cache, will use fallback method"
904+ "Timeout waiting for websocket device cache after %.2f seconds, will use fallback method" ,
905+ elapsed
901906 )
902907 return False
903908
@@ -1109,4 +1114,4 @@ async def get_weather(self, location_id: int) -> dict[str, Any]:
11091114 LOG .debug ("Weather URL is %s" , url )
11101115 response = await self .async_request ("get" , url )
11111116 LOG .debug ("Weather API response: %s" , response )
1112- return cast (dict [str , Any ], response )
1117+ return cast (dict [str , Any ], response )
0 commit comments