@@ -43,25 +43,26 @@ def find_response(response_message: RoborockMessage) -> None:
4343 _LOGGER .info ("Failed to decode b01 message: %s: %s" , response_message , ex )
4444 return
4545
46- for _ , dps_value in decoded_dps .items ():
46+ for dps_value in decoded_dps .values ():
4747 # valid responses are JSON strings wrapped in the dps value
48- if isinstance (dps_value , str ):
49- try :
50- inner = json .loads (dps_value )
51- except (json .JSONDecodeError , TypeError ):
52- _LOGGER .debug ("Received unexpected response: %s" , dps_value )
53- continue
48+ if not isinstance (dps_value , str ):
49+ _LOGGER .debug ("Received unexpected response: %s" , dps_value )
50+ continue
5451
55- if isinstance (inner , dict ) and inner .get ("msgId" ) == msg_id :
56- _LOGGER .debug ("Received query response: %s" , inner )
57- data = inner .get ("data" )
58- if not future .done ():
59- if isinstance (data , dict ):
60- future .set_result (data )
61- else :
62- future .set_exception (RoborockException (f"Unexpected data type for response: { data } " ))
63- else :
52+ try :
53+ inner = json .loads (dps_value )
54+ except (json .JSONDecodeError , TypeError ):
6455 _LOGGER .debug ("Received unexpected response: %s" , dps_value )
56+ continue
57+
58+ if isinstance (inner , dict ) and inner .get ("msgId" ) == msg_id :
59+ _LOGGER .debug ("Received query response: %s" , inner )
60+ data = inner .get ("data" )
61+ if not future .done ():
62+ if isinstance (data , dict ):
63+ future .set_result (data )
64+ else :
65+ future .set_exception (RoborockException (f"Unexpected data type for response: { data } " ))
6566
6667 unsub = await mqtt_channel .subscribe (find_response )
6768
0 commit comments