Skip to content

Commit 9004bcc

Browse files
author
NOisi-X
committed
fix(zeo): normalize query response keys before projecting into traits
decode_rpc_response() keys the response by integer DP code, while the send_decoded_command() overload reports RoborockZeoProtocol keys. mypy flagged the mismatch when the response was passed to _update_traits(), which expects dict[int, Any]. Normalize the keys explicitly so the runtime representation and the declared type agree.
1 parent 512d43c commit 9004bcc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎roborock/devices/traits/a01/__init__.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,11 @@ async def query_values(self, protocols: list[RoborockZeoProtocol]) -> dict[Robor
571571
value_encoder=json.dumps,
572572
)
573573
if self._unsub is None:
574-
self._update_traits(response)
574+
# Not subscribed, so this response never reaches `_on_message`;
575+
# project it into the traits here. `decode_rpc_response` keys the
576+
# response by integer DP code (the channel signature reports the
577+
# protocol enum), so normalize to the codes the traits expect.
578+
self._update_traits({int(dp): value for dp, value in response.items()})
575579
values = {protocol: convert_zeo_value(protocol, response.get(protocol)) for protocol in protocols}
576580
self._merge_query_response(values)
577581
return values

0 commit comments

Comments
 (0)