Repository navigation
feat(mower): add structured command and reply models - #1022
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 13 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Argon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary
Well-structured RoborockBase models and MowerEnum mappings for remote_pb command and reply payloads.
- Layer 1 (Architecture & Boundaries): Pure data-layer additions under
roborock/data/mower/with no transport or trait coupling. - Layer 2 (Data Models & Wire Mapping): Field names, types,
WIRE_ALIASESforMowAreasConfig.global, and enum codes match therock.common/rock.common.remote/rock.fsmdefinitions, with two wire-mapping findings noted inline (MowerFsmStatemissing codes25..89andMowerMowContinue.continue_statetyped asintinstead ofMowerFsmState). - Layer 3 & 4 (Style & Conformance): All new dataclasses and enums satisfy model and enum conformance rules (
Nonedefaults,UNKNOWNfallback members, unique codes). - Layer 5 (Testing Standards): Comprehensive round-trip, unknown-enum, and partial-payload tests in
tests/data/mower/test_mower_commands.pyandtests/data/mower/test_mower_code_mappings.py.
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).
Follow-Up Review (5c1d2a4, delta from a1795f5)
Verdict: Passes /review with nits.
Both findings from the 2026-11-11 review are fixed:
MowerFsmStatemissing codes 25..89: fixed.roborock/data/mower/mower_code_mappings.py:871-938now defines every code from 0 to 89. I checked all 90 name/code pairs againstrock.fsm.FsmState.Typein the RockMow S1 plugin bundle from August (RR_API049b827c2,module_1048.js:783-961), and they all match. That includes theMenuOptionsspelling at 31.MowerMowContinue.continue_statetyped asint: fixed.mower_commands.py:270is nowMowerFsmState | None. This is confirmed: the bundle'sMowContinuedecoder resolvescontinue_statethroughrock.fsm.FsmState.Type(current bundlemodule_1197.js:415210-415217).RobotTask.working_state(:285183) andRobotMsg.mow_working_state(:335056) use the same enum, which matches how the PR types them. The newtest_robot_msg_fsm_statescovers integer codes, numeric strings, wire names and unknown fallback on all three fields, plus anas_dict()round trip.
The other enum tables in the PR also match the August schema exactly. The command and reply IDs, AppButton, the FsmEvent subset, the preference, plan, rain and SKU enums, FeatureSet.Type, McuType and RtkMode all line up with no wrong codes or names. Note that this August bundle is older than the PR.
Priority 3: Wire protocols, codecs and enums
- The enum tables are already behind the current app schema. This does not block the PR. RR_API refreshed the mower bundles on 2026-11-21 (
dd143d788), after this commit. The current RockMow S1/Z1 schema (hermes/no_package/RockMow S1/output/module_1197.js) adds values and renames two existing ones:rock.fsm.FsmState.Typenow runs to 95:OPTIMIZE90,LEARN91,MCU_POWER_ON92,AFS93,VIDEO_REMOTE_UNDOCK94 andVIDEO_REMOTE_ACTIVE95 (module_1197.js:1304-1314). States 94 and 95 are runtime task states for remote video driving, so they will show up inworking_state/mow_working_stateon newer firmware. Today they decode toMowerFsmState.UNKNOWNwithout crashing, buttest_fsm_state_covers_complete_wire_domain(tests/data/mower/test_mower_code_mappings.py:111-113) pins the "complete" set asrange(90), which is no longer true. Suggested fix: add the six members and change the assertion toset(range(96)). Alternatively, drop the "complete wire domain" wording so the test does not need updating whenever the app changes.RemoteMsg.Type166 is nowSAVE_S1G_CONFIG(module_1197.js:95871). The PR hasSAVE_S1G_IOT_CONFIG(mower_code_mappings.py:582).RobotMsg.Type103 is nowSMART_DOCK_MSG(module_1197.js:337056). The PR hasSET_DOCK_CHARGING_TYPE(mower_code_mappings.py:691); that name now belongs to a nested enum (module_1197.js:297244). The integer codes still resolve correctly. However, on the JSON route the new protobuf names fall through toUNKNOWN, becauseMowerEnum.from_coderesolves names by member name. Suggested fix: rename both members to the current names.- Optional: the current schema also adds
RemoteMsg.Type167-181,RobotMsg.Type119-134,AppButton116-124 andFeatureSet.Type37-48 (for exampleRTK_INFO48 atmodule_1197.js:406772). Unknown values already fall back safely, so these can wait for the protocol or consumer PR.
Tests & PR hygiene
- All mower tests now go through public
from_dict/from_codeand use@pytest.mark.parametrize. No other issues found. - The two earlier inline threads (
mower_code_mappings.pyFSM range,mower_commands.pycontinue_state) are addressed and can be resolved. - Local run at
5c1d2a4:pytest2518 passed / 53 xfailed / 11 deselected;ruff checkandruff format --checkare clean; mypy reports no errors in the mower modules or tests (the 19 local mypy errors are all in files this PR does not touch and come from the local environment; CI lint passes). CI is green. The PR merges cleanly into currentmain(cfa413e).
This is an automated review and can be incorrect, so please reply if any finding looks wrong.
Mower support currently has typed scalar status, but no structured request/reply models. Add the command and response enum tables and
RoborockBasepayload models forremote_pb, including preferences, schedules, task/battery state, capabilities and hardware/version information. This follows #1002 and #1009.Keep the merged status models and enum behavior unchanged. New enums use lowercase domain values, accept protobuf names or numeric codes, and fall back on unknown firmware values. Partial payloads preserve omitted fields separately from zero, false and empty lists; absence records payload presence rather than asserting that a setting is unset. Protobuf default interpretation belongs to the following protocol/consumer layer; 64-bit request IDs retain their decimal-string representation. The
globalpreference key parses asglobal_preference.This PR contains data models only.
as_dict()retains the standard library representation; the following protocol PR will handle snake_case keys, protobuf enum names and the reservedglobalkey. Capability decoding, transport and consumer traits follow separately.Validation: