@@ -547,7 +547,9 @@ async def call_get_location_query(self, location_hilo_id: str) -> None:
547547 async def subscribe_to_device_updated (
548548 self , location_hilo_id : str , callback : callable = None
549549 ) -> None :
550+ LOG .debug ("subscribe_to_device_updated called" )
550551 while True : # Loop to reconnect if the connection is lost
552+ LOG .debug ("subscribe_to_device_updated while true" )
551553 access_token = await self ._get_access_token ()
552554 transport = WebsocketsTransport (
553555 url = f"wss://platform.hiloenergie.com/api/digital-twin/v3/graphql?access_token={ access_token } "
@@ -559,14 +561,25 @@ async def subscribe_to_device_updated(
559561 async for result in session .subscribe (
560562 query , variable_values = {"locationHiloId" : location_hilo_id }
561563 ):
562- LOG .debug (f"Received subscription result { result } " )
564+ LOG .debug (
565+ f"subscribe_to_device_updated: Received subscription result { result } "
566+ )
563567 device_hilo_id = self ._handle_device_subscription_result (result )
564568 if callback :
565569 callback (device_hilo_id )
566570 except Exception as e :
567- LOG .debug (f"Connection lost: { e } . Reconnecting in 5 seconds..." )
571+ LOG .debug (
572+ f"subscribe_to_device_updated: Connection lost: { e } . Reconnecting in 5 seconds..."
573+ )
568574 await asyncio .sleep (5 )
569- await self .call_get_location_query (location_hilo_id )
575+ try :
576+ await self .call_get_location_query (location_hilo_id )
577+ LOG .debug ("subscribe_to_device_updated, call_get_location_query success" )
578+
579+ except Exception as e2 :
580+ LOG .error (
581+ f"subscribe_to_device_updated, exception while reconnecting, retrying: { e2 } "
582+ )
570583
571584 async def subscribe_to_location_updated (
572585 self , location_hilo_id : str , callback : callable = None
0 commit comments