Skip to content

Commit ab61a1a

Browse files
Lash-Lallenporter
andauthored
chore: update roborock/devices/b01_channel.py
Co-authored-by: Allen Porter <allen.porter@gmail.com>
1 parent f792f49 commit ab61a1a

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

roborock/devices/b01_channel.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,22 @@ def find_response(response_message: RoborockMessage) -> None:
4646

4747
for _, dps_value in decoded_dps.items():
4848
# valid responses are JSON strings wrapped in the dps value
49-
if isinstance(dps_value, str):
50-
try:
51-
inner = json.loads(dps_value)
52-
except (json.JSONDecodeError, TypeError):
53-
_LOGGER.debug("Received unexpected response: %s", dps_value)
54-
continue
49+
if not isinstance(dps_value, str):
50+
_LOGGER.debug("Received unexpected response: %s", dps_value)
51+
continue
5552

56-
if isinstance(inner, dict) and inner.get("msgId") == msg_id:
57-
_LOGGER.debug("Received query response: %s", inner)
58-
data = inner.get("data")
59-
if isinstance(data, dict):
60-
result.update(data)
61-
finished.set()
62-
else:
53+
try:
54+
inner = json.loads(dps_value)
55+
except (json.JSONDecodeError, TypeError):
6356
_LOGGER.debug("Received unexpected response: %s", dps_value)
57+
continue
58+
59+
if isinstance(inner, dict) and inner.get("msgId") == msg_id:
60+
_LOGGER.debug("Received query response: %s", inner)
61+
data = inner.get("data")
62+
if isinstance(data, dict):
63+
result.update(data)
64+
finished.set()
6465

6566
unsub = await mqtt_channel.subscribe(find_response)
6667

0 commit comments

Comments
 (0)