Skip to content

feat(mower): add structured command and reply models - #1022

Merged
allenporter merged 2 commits into
mainfrom
codex/mower-command-models
Nov 26, 2026
Merged

allenporter merged 2 commits into
mainfrom
codex/mower-command-models

Conversation

@Lash-L

@Lash-L Lash-L commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Mower support currently has typed scalar status, but no structured request/reply models. Add the command and response enum tables and RoborockBase payload models for remote_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 global preference key parses as global_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 reserved global key. Capability decoding, transport and consumer traits follow separately.

Validation:

  • Full suite on Python 3.14: 2,487 passed, 53 xfailed, 11 deselected; 99 snapshots passed.
  • All pre-commit hooks passed, including Ruff, Mypy and Codespell.
  • Mower model/enum tests cover a saved preference reply, command/reply parsing, unknown firmware values, omitted versus empty values and large IDs.
  • Checked 142 modeled fields against the app-derived schema catalog and 516 nonzero enum name/code pairs against the app schema source. No live mower commands were sent.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 02:16

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
roborock/data/mower/__init__.py 100.00% <100.00%> (ø)
roborock/data/mower/mower_code_mappings.py 100.00% <100.00%> (ø)
roborock/data/mower/mower_commands.py 100.00% <100.00%> (ø)
tests/data/mower/test_mower_code_mappings.py 100.00% <100.00%> (ø)
tests/data/mower/test_mower_commands.py 100.00% <100.00%> (ø)

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Lash-L Lash-L left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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_ALIASES for MowAreasConfig.global, and enum codes match the rock.common / rock.common.remote / rock.fsm definitions, with two wire-mapping findings noted inline (MowerFsmState missing codes 25..89 and MowerMowContinue.continue_state typed as int instead of MowerFsmState).
  • Layer 3 & 4 (Style & Conformance): All new dataclasses and enums satisfy model and enum conformance rules (None defaults, UNKNOWN fallback members, unique codes).
  • Layer 5 (Testing Standards): Comprehensive round-trip, unknown-enum, and partial-payload tests in tests/data/mower/test_mower_commands.py and tests/data/mower/test_mower_code_mappings.py.

Comment thread roborock/data/mower/mower_commands.py Resolved
@Lash-L Lash-L added Feature New feature Data model changes Changes to data models, device info, or feature mappings /review run Code review skill (/review) has been run Mower Mower platform labels Nov 15, 2026

@Lash-L Lash-L left a comment

Copy link
Copy Markdown
Collaborator Author

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).

Follow-Up Review (5c1d2a4, delta from a1795f5)

Verdict: Passes /review with nits.

Both findings from the 2026-11-11 review are fixed:

  • MowerFsmState missing codes 25..89: fixed. roborock/data/mower/mower_code_mappings.py:871-938 now defines every code from 0 to 89. I checked all 90 name/code pairs against rock.fsm.FsmState.Type in the RockMow S1 plugin bundle from August (RR_API 049b827c2, module_1048.js:783-961), and they all match. That includes the MenuOptions spelling at 31.
  • MowerMowContinue.continue_state typed as int: fixed. mower_commands.py:270 is now MowerFsmState | None. This is confirmed: the bundle's MowContinue decoder resolves continue_state through rock.fsm.FsmState.Type (current bundle module_1197.js:415210-415217). RobotTask.working_state (:285183) and RobotMsg.mow_working_state (:335056) use the same enum, which matches how the PR types them. The new test_robot_msg_fsm_states covers integer codes, numeric strings, wire names and unknown fallback on all three fields, plus an as_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

  1. 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.Type now runs to 95: OPTIMIZE 90, LEARN 91, MCU_POWER_ON 92, AFS 93, VIDEO_REMOTE_UNDOCK 94 and VIDEO_REMOTE_ACTIVE 95 (module_1197.js:1304-1314). States 94 and 95 are runtime task states for remote video driving, so they will show up in working_state / mow_working_state on newer firmware. Today they decode to MowerFsmState.UNKNOWN without crashing, but test_fsm_state_covers_complete_wire_domain (tests/data/mower/test_mower_code_mappings.py:111-113) pins the "complete" set as range(90), which is no longer true. Suggested fix: add the six members and change the assertion to set(range(96)). Alternatively, drop the "complete wire domain" wording so the test does not need updating whenever the app changes.
    • RemoteMsg.Type 166 is now SAVE_S1G_CONFIG (module_1197.js:95871). The PR has SAVE_S1G_IOT_CONFIG (mower_code_mappings.py:582). RobotMsg.Type 103 is now SMART_DOCK_MSG (module_1197.js:337056). The PR has SET_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 to UNKNOWN, because MowerEnum.from_code resolves names by member name. Suggested fix: rename both members to the current names.
    • Optional: the current schema also adds RemoteMsg.Type 167-181, RobotMsg.Type 119-134, AppButton 116-124 and FeatureSet.Type 37-48 (for example RTK_INFO 48 at module_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_code and use @pytest.mark.parametrize. No other issues found.
  • The two earlier inline threads (mower_code_mappings.py FSM range, mower_commands.py continue_state) are addressed and can be resolved.
  • Local run at 5c1d2a4: pytest 2518 passed / 53 xfailed / 11 deselected; ruff check and ruff format --check are 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 current main (cfa413e).

This is an automated review and can be incorrect, so please reply if any finding looks wrong.

@Lash-L Lash-L added the Passed /review Passed the /review skill check label Nov 25, 2026
@Lash-L
Lash-L requested a review from allenporter November 25, 2026 17:13
@allenporter
allenporter merged commit 5c13379 into main Nov 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Data model changes Changes to data models, device info, or feature mappings Feature New feature Mower Mower platform Passed /review Passed the /review skill check /review run Code review skill (/review) has been run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants