@@ -546,7 +546,9 @@ async def call_get_location_query(self, location_hilo_id: str) -> None:
546546 async def subscribe_to_device_updated (
547547 self , location_hilo_id : str , callback : callable = None
548548 ) -> None :
549+ LOG .debug ("subscribe_to_device_updated called" )
549550 while True : # Loop to reconnect if the connection is lost
551+ LOG .debug ("subscribe_to_device_updated while true" )
550552 access_token = await self ._get_access_token ()
551553 transport = WebsocketsTransport (
552554 url = f"wss://platform.hiloenergie.com/api/digital-twin/v3/graphql?access_token={ access_token } "
@@ -558,14 +560,25 @@ async def subscribe_to_device_updated(
558560 async for result in session .subscribe (
559561 query , variable_values = {"locationHiloId" : location_hilo_id }
560562 ):
561- LOG .debug (f"Received subscription result { result } " )
563+ LOG .debug (
564+ f"subscribe_to_device_updated: Received subscription result { result } "
565+ )
562566 device_hilo_id = self ._handle_device_subscription_result (result )
563567 if callback :
564568 callback (device_hilo_id )
565569 except Exception as e :
566- LOG .debug (f"Connection lost: { e } . Reconnecting in 5 seconds..." )
570+ LOG .debug (
571+ f"subscribe_to_device_updated: Connection lost: { e } . Reconnecting in 5 seconds..."
572+ )
567573 await asyncio .sleep (5 )
568- await self .call_get_location_query (location_hilo_id )
574+ try :
575+ await self .call_get_location_query (location_hilo_id )
576+ LOG .debug ("subscribe_to_device_updated, call_get_location_query success" )
577+
578+ except Exception as e2 :
579+ LOG .error (
580+ f"subscribe_to_device_updated, exception while reconnecting, retrying: { e2 } "
581+ )
569582
570583 async def subscribe_to_location_updated (
571584 self , location_hilo_id : str , callback : callable = None
0 commit comments