Repository navigation
Conversation
allenporter
left a comment
There was a problem hiding this comment.
Thanks for the clean, focused fix for #913! Two small things to address before merging (see inline comments):
- Return early in
ZeoApi.query_values()whensupportedis empty so_merge_query_response()doesn't updatelast_message_timewhen nothing was sent or received. - Narrow
message.payload(bytes | None) before passing it tounpad()intests/devices/traits/a01/test_init.pyso Mypy passes.
Non-blocking: it would also be nice to add a @pytest.mark.parametrize test for supports_dp in tests/devices/traits/a01/test_device_feature.py covering FEATURE_BITS, DEFAULT_SETTING, _SOFTENER_DPS, and model=None, and assert zeo_api.last_message_time is None in test_zeo_api_query_values_only_unsupported_dps.
| response: dict[RoborockZeoProtocol, Any] = {} | ||
| if supported: | ||
| response = await send_decoded_command( | ||
| self._channel, | ||
| {RoborockZeoProtocol.ID_QUERY: supported}, | ||
| value_encoder=json.dumps, | ||
| ) |
There was a problem hiding this comment.
When supported is empty, falling through to self._merge_query_response(values) still updates self._last_message_time (when unsubscribed), even though no message was sent or received from the device. Returning early avoids a false liveness timestamp and keeps the control flow flat:
| response: dict[RoborockZeoProtocol, Any] = {} | |
| if supported: | |
| response = await send_decoded_command( | |
| self._channel, | |
| {RoborockZeoProtocol.ID_QUERY: supported}, | |
| value_encoder=json.dumps, | |
| ) | |
| if not supported: | |
| return dict.fromkeys(protocols) | |
| response = await send_decoded_command( | |
| self._channel, | |
| {RoborockZeoProtocol.ID_QUERY: supported}, | |
| value_encoder=json.dumps, | |
| ) |
| RoborockZeoProtocol.SOFTENER_EMPTY: None, | ||
| } | ||
| assert len(fake_channel.published_messages) == 1 | ||
| payload_data = json.loads(unpad(fake_channel.published_messages[0].payload, AES.block_size)) |
There was a problem hiding this comment.
RoborockMessage.payload is bytes | None, so Mypy (check_untyped_defs = true) will reject passing it directly to unpad() without narrowing it first:
| payload_data = json.loads(unpad(fake_channel.published_messages[0].payload, AES.block_size)) | |
| message = fake_channel.published_messages[0] | |
| assert message.payload is not None | |
| payload_data = json.loads(unpad(message.payload, AES.block_size)) |
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Claude Opus 5.5 in Claude Code using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary
Verdict: Does not pass /review.
The fix targets a real problem. The Home Assistant poll asks a Zeo Mini (roborock.wm.a93) for SOFTENER_TYPE/SOFTENER_EMPTY, the device never answers, send_decoded_command waits the full 10 s, and repeated timeouts make MqttHealthManager.on_timeout() restart the session. Filtering out known-unsupported DPs in ZeoApi.query_values() before sending them fixes that. The approach is sound and the model gates are reused instead of duplicated. The two changes requested in the earlier maintainer review are still open on 8a4b2c5, and CI mypy fails on the new test.
Device claims checked against the Roborock app bundle (RR_API, nonhermes/com.roborock.wm/Zeo One/output)
- Confirmed: the app's
forceLoad()leaves outAutoSoftener212,SoftenerType214,CacheWashingPreference225 andIsSoftenerEmpty227 forisM1Series || isMuseSeries || isMetisSeries || isCleanDryer(726.js:1223). The DP numbers come from723.js:39. - Confirmed:
roborock.wm.a93isisM1Overseas(441.js:452-455), andisM1Seriesincludes it (441.js:682-684). This matches_M1_SERIESandhas_softener_compartment(). - Confirmed:
FEATURE_BITS(237) is gated byisSupportFeatureBits(441.js:376-377), which leaves out H1 a63 and H1 Lite a90. This matches_UNSUPPORTED_FEATURE_BITS. - Unverifiable: DP 225 being unsupported on a63/a90. The app has no such exclusion, so this comes from this library's own empirical
_UNSUPPORTED_DEFAULT_SETTINGand is not new in this PR.
Priority 2: Lifecycle & state
-
roborock/devices/traits/a01/__init__.py:451-464: false liveness timestamp when nothing is sent (still open from the maintainer review). Whensupportedis empty, the code still reachesself._merge_query_response(values). While unsubscribed, that sets_last_message_time = noweven though no message was sent or received, so a device that has gone silent looks alive. Return early instead:supported = [protocol for protocol in protocols if supports_dp(self._model, protocol)] if not supported: return dict.fromkeys(protocols) response = await send_decoded_command( self._channel, {RoborockZeoProtocol.ID_QUERY: supported}, value_encoder=json.dumps, )
This also removes the pre-declared
response: dict[...] = {}and theif supported:nesting. -
Non-blocking question:
supports_dp()(roborock/devices/traits/a01/device_feature.py, new function) covers fewer DPs thanbuild_force_load_dp_list().supports_dp()gates only 237, 225 and the softener block.build_force_load_dp_list()also gates smart hosting 235/236/238 (onsupports_feature_bits), soak 233, smart clean 239 and remote control 232, and_load_feature_dps()gates UV light 228. If a caller polls one of those on a model that lacks it, the query still waits 10 s. RR_API cannot tell us whether firmware stays silent on those DPs the way it does for the softener block. Either makesupports_dp()mirror the same gates so the two cannot drift, or narrow the docstring to "known non-answering DPs" so callers do not treat it as a complete capability check.
Overlap with #1080
#1080 ("fix(a01): return partial query responses") and this PR complement each other. Neither duplicates the other, but they conflict textually: git merge-tree reports a conflict in roborock/devices/traits/a01/__init__.py because both rewrite the body of ZeoApi.query_values().
- This PR stops the library from asking for DPs it already knows a model lacks, so a known Zeo Mini never waits 10 s on a poll.
- #1080 is the general safety net. After the timeout it returns whatever partial result arrived, records success instead of a timeout, keeps the existing
_feature_bitswhen 237 is missing, and applies the same handling to Dyad. It still costs 10 s per poll on an a93. - Both build the same
valuescomprehension (convert_zeo_value(...) if protocol in response else None), so whichever PR lands second can resolve the conflict by keeping thesupportedfilter (with the early return above) and that shared comprehension. Landing both is reasonable. - Context for #1080: the app's own
publishDp()resolves aQueryDPas soon as the first requested DP comes back (726.js:1343-1355), not after every DP arrives. The library's "wait for every DP" rule is stricter than the app's.
Tests & PR hygiene
tests/devices/traits/a01/test_init.py:562: mypy fails (still open from the maintainer review).uv run mypy roborock testsreportsArgument 1 to "unpad" has incompatible type "bytes | None"at line 562 on the PR head, and at line 655 after merging currentmain. Narrow the payload first:message = fake_channel.published_messages[0] assert message.payload is not None payload_data = json.loads(unpad(message.payload, AES.block_size))
- Also from the maintainer review: in
test_zeo_api_query_values_only_unsupported_dps, assertzeo_api.last_message_time is None, which locks in finding 1. Add a@pytest.mark.parametrizetest forsupports_dpintests/devices/traits/a01/test_device_feature.pycoveringFEATURE_BITS,DEFAULT_SETTING,_SOFTENER_DPSandmodel=None. - Issue link: #1013 is the exact report (a93 polling 214/227 and timing out). #913 is the broader "connection reset" symptom. Consider
Fixes #1013andRefs #913.
Local results on 8a4b2c5 (Python 3.13): pytest 2445 passed, 53 xfailed. ruff check and ruff format --check are clean. mypy fails as described in finding 3. After a local merge with main, the a01 tests pass (81).
This is an automated review and can be incorrect, so please reply if any finding looks wrong.
Zeo models without a softener compartment, such as the Zeo Mini (roborock.wm.a93), never answer the softener data points, so any
ZeoApi.query_valuescall that included them timed out and repeated timeouts triggered MQTT session restarts, leaving the device unavailable.query_valuesnow filters out data points the model is known not to support (softener block, DP 225, feature bits) using a newsupports_dphelper that reuses the existing model gates, and returnsNonefor them. Added regression tests for the a93 model covering a mixed query and a query with only unsupported data points; both time out without the fix and pass with it.Fixes #913
Tests
The new test (
tests/devices/traits/a01/test_init.py) fails on the base branch and passes with this change.The test suite also ran:
python3 -m pytest -q -rfE --continue-on-collection-errors -p no:cacheproviderpassed (the 1 test that also fail on the unchanged base branch here, typically for lack of a service or optional dependency, are unaffected).Changes