@@ -61,10 +61,7 @@ def build_roborock_message(self, method: RoborockCommand, params: Optional[list]
61
61
62
62
async def send_command (self , device_id : str , method : RoborockCommand , params : Optional [list ] = None ):
63
63
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 ]
68
65
69
66
async def async_local_response (self , roborock_message : RoborockMessage ):
70
67
request_id = roborock_message .get_request_id ()
@@ -89,10 +86,15 @@ async def send_message(self, device_id: str, roborock_messages: list[RoborockMes
89
86
_LOGGER .debug (f"Requesting device with { roborock_messages } " )
90
87
await listener .send_message (msg )
91
88
92
- return await asyncio .gather (
89
+ responses = await asyncio .gather (
93
90
* [self .async_local_response (roborock_message ) for roborock_message in roborock_messages ],
94
91
return_exceptions = True ,
95
92
)
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
96
98
97
99
98
100
class RoborockSocket (socket .socket ):
@@ -130,7 +132,7 @@ def data_received(self, message):
130
132
self .on_message (parser_msg )
131
133
132
134
def connection_lost (self , exc ):
133
- print ("The server closed the connection" )
135
+ _LOGGER . debug ("The server closed the connection" )
134
136
135
137
def is_connected (self ):
136
138
return self .transport and self .transport .is_reading ()
0 commit comments