Skip to content

fix(a01): skip unsupported DPs in Zeo query_values - #1090

Open
udsy19 wants to merge 1 commit into
Python-roborock:mainfrom
udsy19:ossloop/913-roborock-zeo-mini-a01-wm-a93-intermitten
Open

udsy19 wants to merge 1 commit into
Python-roborock:mainfrom
udsy19:ossloop/913-roborock-zeo-mini-a01-wm-a93-intermitten

Conversation

@udsy19

@udsy19 udsy19 commented Nov 24, 2026

Copy link
Copy Markdown

Zeo models without a softener compartment, such as the Zeo Mini (roborock.wm.a93), never answer the softener data points, so any ZeoApi.query_values call that included them timed out and repeated timeouts triggered MQTT session restarts, leaving the device unavailable. query_values now filters out data points the model is known not to support (softener block, DP 225, feature bits) using a new supports_dp helper that reuses the existing model gates, and returns None for 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:cacheprovider passed (the 1 test that also fail on the unchanged base branch here, typically for lack of a service or optional dependency, are unaffected).

Changes

roborock/devices/traits/a01/__init__.py       | 25 +++++++++++++------
 roborock/devices/traits/a01/device_feature.py | 32 ++++++++++++++++++------
 tests/devices/traits/a01/test_init.py         | 35 +++++++++++++++++++++++++++
 3 files changed, 77 insertions(+), 15 deletions(-)

@allenporter allenporter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clean, focused fix for #913! Two small things to address before merging (see inline comments):

  1. Return early in ZeoApi.query_values() when supported is empty so _merge_query_response() doesn't update last_message_time when nothing was sent or received.
  2. Narrow message.payload (bytes | None) before passing it to unpad() in tests/devices/traits/a01/test_init.py so 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.

Comment on lines +452 to +458
response: dict[RoborockZeoProtocol, Any] = {}
if supported:
response = await send_decoded_command(
self._channel,
{RoborockZeoProtocol.ID_QUERY: supported},
value_encoder=json.dumps,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RoborockMessage.payload is bytes | None, so Mypy (check_untyped_defs = true) will reject passing it directly to unpad() without narrowing it first:

Suggested change
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 Lash-L left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 out AutoSoftener 212, SoftenerType 214, CacheWashingPreference 225 and IsSoftenerEmpty 227 for isM1Series || isMuseSeries || isMetisSeries || isCleanDryer (726.js:1223). The DP numbers come from 723.js:39.
  • Confirmed: roborock.wm.a93 is isM1Overseas (441.js:452-455), and isM1Series includes it (441.js:682-684). This matches _M1_SERIES and has_softener_compartment().
  • Confirmed: FEATURE_BITS (237) is gated by isSupportFeatureBits (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_SETTING and is not new in this PR.

Priority 2: Lifecycle & state

  1. roborock/devices/traits/a01/__init__.py:451-464: false liveness timestamp when nothing is sent (still open from the maintainer review). When supported is empty, the code still reaches self._merge_query_response(values). While unsubscribed, that sets _last_message_time = now even 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 the if supported: nesting.

  2. Non-blocking question: supports_dp() (roborock/devices/traits/a01/device_feature.py, new function) covers fewer DPs than build_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 (on supports_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 make supports_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_bits when 237 is missing, and applies the same handling to Dyad. It still costs 10 s per poll on an a93.
  • Both build the same values comprehension (convert_zeo_value(...) if protocol in response else None), so whichever PR lands second can resolve the conflict by keeping the supported filter (with the early return above) and that shared comprehension. Landing both is reasonable.
  • Context for #1080: the app's own publishDp() resolves a QueryDP as 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

  1. tests/devices/traits/a01/test_init.py:562: mypy fails (still open from the maintainer review). uv run mypy roborock tests reports Argument 1 to "unpad" has incompatible type "bytes | None" at line 562 on the PR head, and at line 655 after merging current main. 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))
  2. Also from the maintainer review: in test_zeo_api_query_values_only_unsupported_dps, assert zeo_api.last_message_time is None, which locks in finding 1. 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.
  3. Issue link: #1013 is the exact report (a93 polling 214/227 and timing out). #913 is the broader "connection reset" symptom. Consider Fixes #1013 and Refs #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.

@Lash-L Lash-L added the /review run Code review skill (/review) has been run label Nov 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

/review run Code review skill (/review) has been run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Roborock Zeo Mini (a01/wm.a93) intermittently unavailable — “Connection reset by peer” despite recent core version

3 participants