2020_LOGGER = logging .getLogger (__name__ )
2121_TIMEOUT = 10.0
2222
23+ # Both RoborockDyadDataProtocol and RoborockZeoProtocol have the same
24+ # value for ID_QUERY
25+ _ID_QUERY = int (RoborockDyadDataProtocol .ID_QUERY )
26+
2327
2428@overload
2529async def send_decoded_command (
@@ -45,12 +49,10 @@ async def send_decoded_command(
4549 _LOGGER .debug ("Sending MQTT command: %s" , params )
4650 roborock_message = encode_mqtt_payload (params )
4751
48- # We only block on a response for queries
52+ # For commands that set values: send the command and do not
53+ # block waiting for a response. Queries are handled below.
4954 param_values = {int (k ): v for k , v in params .items ()}
50- if not (
51- query_values := param_values .get (int (RoborockDyadDataProtocol .ID_QUERY ))
52- or param_values .get (int (RoborockZeoProtocol .ID_QUERY ))
53- ):
55+ if not (query_values := param_values .get (_ID_QUERY )):
5456 await mqtt_channel .publish (roborock_message )
5557 return {}
5658
@@ -64,12 +66,14 @@ def find_response(response_message: RoborockMessage) -> None:
6466 """Handle incoming messages and resolve the future."""
6567 try :
6668 decoded = decode_rpc_response (response_message )
67- except RoborockException :
69+ except RoborockException as ex :
70+ _LOGGER .info ("Failed to decode a01 message: %s: %s" , response_message , ex )
6871 return
6972 for key , value in decoded .items ():
7073 if key in query_values :
7174 result [key ] = value
7275 if len (result ) != len (query_values ):
76+ _LOGGER .debug ("Incomplete query response: %s != %s" , result , query_values )
7377 return
7478 _LOGGER .debug ("Received query response: %s" , result )
7579 if not finished .is_set ():
0 commit comments