@@ -61,10 +61,7 @@ def build_roborock_message(self, method: RoborockCommand, params: Optional[list]
6161
6262 async def send_command (self , device_id : str , method : RoborockCommand , params : Optional [list ] = None ):
6363 roborock_message = self .build_roborock_message (method , params )
64- response = (await self .send_message (device_id , roborock_message ))[0 ]
65- if isinstance (response , BaseException ):
66- raise response
67- return response
64+ return (await self .send_message (device_id , roborock_message ))[0 ]
6865
6966 async def async_local_response (self , roborock_message : RoborockMessage ):
7067 request_id = roborock_message .get_request_id ()
@@ -89,10 +86,15 @@ async def send_message(self, device_id: str, roborock_messages: list[RoborockMes
8986 _LOGGER .debug (f"Requesting device with { roborock_messages } " )
9087 await listener .send_message (msg )
9188
92- return await asyncio .gather (
89+ responses = await asyncio .gather (
9390 * [self .async_local_response (roborock_message ) for roborock_message in roborock_messages ],
9491 return_exceptions = True ,
9592 )
93+ exception = next ((response for response in responses if isinstance (response , BaseException )), None )
94+ if exception :
95+ listener .disconnect ()
96+ raise exception
97+ return responses
9698
9799
98100class RoborockSocket (socket .socket ):
@@ -130,7 +132,7 @@ def data_received(self, message):
130132 self .on_message (parser_msg )
131133
132134 def connection_lost (self , exc ):
133- print ("The server closed the connection" )
135+ _LOGGER . debug ("The server closed the connection" )
134136
135137 def is_connected (self ):
136138 return self .transport and self .transport .is_reading ()
0 commit comments