Repository navigation
fix(v1): give VacuumModes.OFF a distinct code from GENTLE - #1066
saruk-vedant wants to merge 11 commits into
Conversation
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Neon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary & Verdict
Does not pass /review — recommend reconsidering the approach (and fixing the CI test/lint failures).
While the PR cleanly threads vacuum_mode_wire_code() through internal call sites, assigning a fabricated code (107) to VacuumModes.OFF breaks the RoborockModeEnum.code public consumer contract, contradicts the WaterModes pattern in the same file, and introduces a future-firmware misclassification risk — all to solve a value-aliasing problem that does not actually exist on VacuumModes.
RR_API Wire Protocol Verification
Cross-checking against the Roborock V1 app bundles (hermes/com.roborock.tanos/output/module_1631.js and nonhermes/com.roborock.tanos/output/1850.js):
- The V1
fan_powerwire namespace uses101(Quiet),102(Balanced /CleanModeNormal),103(Turbo),104(Max),105(CleanModeZero— shared for Gentle and Off/mop-only),106(CustomCleanMode),108(CleanModeMaxPlus), and110(SmartCleanMode). 107is not a wire code forOFF— it is currently an unassigned gap in the101–110V1fan_powernamespace.VacuumModes.GENTLE = ("gentle", 105)andVacuumModes.OFF = ("off", 105)already have distinct.valuestrings ("gentle"vs"off"), so unlike theWaterModesbug fixed in #990 (where water-slide members reused"low"/"medium"/"high"and collapsed into PythonStrEnumaliases),VacuumModes.GENTLEandVacuumModes.OFFare already distinct enum members and passtests/conformance/test_enum_conformance.py::test_roborock_mode_enum_has_no_value_aliasesonmain.
Architectural Layer Review (Priority 1 → 3)
- Priority 1 — Public Trait APIs & Consumer Contracts (Blocking):
- Across
python-roborock, everyRoborockModeEnummember's.coderepresents its literal wire protocol integer (including peer shared-code pairs inWaterModes:LOW/MILD = 201,MEDIUM/STANDARD = 202,HIGH/INTENSE = 203). - Changing
VacuumModes.OFF.codefrom105to synthetic107silently breaks downstream consumers (e.g., Home Assistant or any caller iteratingStatusTrait.fan_speed_optionsand sendingmode.codetoSET_CUSTOM_MODE, or comparingstatus.fan_power == VacuumModes.OFF/VacuumModes.OFF.code), causing them to send invalid code107to real hardware unless they know about the one-offvacuum_mode_wire_code()helper.
- Across
- Priority 2 — Data Lifecycle & State Management:
StatusTrait.fan_speed_mappingalready resolves105unambiguously onmainbecauseget_clean_modes()is mutually exclusive onis_pure_clean_mop_supported(OFFvsGENTLE).
- Priority 3 — Wire Protocols, Codecs & Resilient Enums (Blocking):
- Because
107is an unassigned code in Roborock's active101–110fan_powerrange,VacuumModes.from_code_optional(107)and_resolve_clean_mode(107, features)will now returnVacuumModes.OFF(andget_current_cleaning_mode()will reportCleaningMode.MOPwhen mopping) instead of safely returningNoneif future firmware ever assigns107to a new suction mode.
- Because
- Tests & CI (Blocking):
test (3.11)andtest (3.14)fail in CI due to an accidental indentation bug intests/devices/traits/v1/test_status.py(test_fan_speed_name_gentle_without_pure_mopis nested insidetest_fan_speed_name_off_on_pure_mop_device).lintfails in CI ontrailing-whitespaceandruff-formatintests/devices/traits/v1/test_customize_clean_mode.pyandtests/devices/traits/v1/test_status.py.
| # mop-only cleaning, so OFF shares its wire code with GENTLE. It keeps a | ||
| # distinct enum code so code lookups are unambiguous; use | ||
| # vacuum_mode_wire_code() when sending a code to the device. | ||
| OFF = ("off", 107) |
There was a problem hiding this comment.
[Priority 1 & 3 — Breaking Consumer Contract & Wire-Code Collision Risk]
VacuumModes.OFF and VacuumModes.GENTLE already have distinct .value strings ("off" vs "gentle"), so they are not Python StrEnum value aliases (unlike the WaterModes bug addressed by display_name in #990). Sharing .code = 105 reflects the real V1 wire protocol (CleanModeZero = 105 in com.roborock.tanos) and matches the exact pattern used in WaterModes below (LOW/MILD = 201, MEDIUM/STANDARD = 202, HIGH/INTENSE = 203).
Assigning a synthetic code 107 has two concrete downsides:
- Breaks downstream consumers: Any caller that reads
mode.codefromStatusTrait.fan_speed_optionsto callSET_CUSTOM_MODE, or comparesstatus.fan_power == VacuumModes.OFF/VacuumModes.OFF.code, will now send invalid wire code107(or fail equality against105) unless updated to callvacuum_mode_wire_code(). - Future firmware misclassification:
107is an unassigned slot in Roborock's active101–110fan_powerrange. If future firmware assigns107to a new suction mode,VacuumModes.from_code_optional(107)and_resolve_clean_mode(107, features)will silently misclassify it asVacuumModes.OFFinstead of returningNone.
Consider keeping OFF = ("off", 105) (matching WaterModes) and documenting that code 105 requires DeviceFeatures context (_resolve_clean_mode / StatusTrait.fan_speed_mapping) to disambiguate, rather than inventing a synthetic wire code.
| assert status_trait.fan_speed_name == "off" | ||
|
|
||
|
|
||
| def test_fan_speed_name_gentle_without_pure_mop() -> None: |
There was a problem hiding this comment.
[Test Bug — Causes CI test (3.11) / test (3.14) Failure]
def test_fan_speed_name_gentle_without_pure_mop() is indented inside test_fan_speed_name_off_on_pure_mop_device(), so pytest never collects it and lines 833–834 run against the pure-mop status_trait, failing with AssertionError: assert 'off' == 'gentle'.
| def test_fan_speed_name_gentle_without_pure_mop() -> None: | |
| def test_fan_speed_name_gentle_without_pure_mop() -> None: | |
| """Code 105 reports as gentle on devices without pure mop, where GENTLE is offered.""" | |
| status_trait = _create_cleaning_mode_status_trait(is_pure_clean_mop_supported=False) | |
| status_trait.fan_power = 105 |
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Neon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Follow-Up Review (61ffd44, delta from b49f51c)
Verdict: Still does not pass /review.
Fixed Since b49f51c
- Tests & CI: Commits
94bbee9and61ffd44fixed the nested test indentation intests/devices/traits/v1/test_status.pyand the trailing whitespace / formatting issues intests/devices/traits/v1/test_customize_clean_mode.py. All CI checks (lint,test (3.11),test (3.14),test-mqtt,Build Package,Lint Commit Messages,Test Semantic Release) are now green.
Still Blocking (Unchanged in roborock/)
No changes were made under roborock/, so the core Priority 1 & Priority 3 architectural issue from the prior review on b49f51c remains open:
- Priority 1 — Public Trait APIs & Consumer Contracts: Assigning synthetic code
107toVacuumModes.OFFbreaks theRoborockModeEnum.codewire-code contract shared across the codebase (including peer shared-code pairs inWaterModes:LOW/MILD = 201,MEDIUM/STANDARD = 202,HIGH/INTENSE = 203). Downstream consumers readingmode.codefromStatusTrait.fan_speed_optionsor comparingstatus.fan_power == VacuumModes.OFF(which comparesself.code == otherinRoborockModeEnum.__eq__) will send invalid wire code107or fail equality against105unless they know to callvacuum_mode_wire_code(). - Priority 3 — Wire Protocols & Enum Resilience:
107is an unassigned slot in Roborock's active101–110V1fan_powernamespace. If future firmware assigns107to a new suction mode,VacuumModes.from_code_optional(107)and_resolve_clean_mode(107, features)will silently misclassify it asVacuumModes.OFF(andget_current_cleaning_mode()asCleaningMode.MOPwhen mopping) instead of returningNone.
As noted previously, VacuumModes.GENTLE = ("gentle", 105) and VacuumModes.OFF = ("off", 105) already have distinct StrEnum .value strings and are not enum aliases (unlike #990). Recommend keeping OFF = ("off", 105) to match WaterModes and documenting/handling wire-code 105 disambiguation via DeviceFeatures (_resolve_clean_mode / StatusTrait.fan_speed_mapping), or closing #999 as not-an-alias.
Summary
VacuumModes.GENTLE and VacuumModes.OFF shared code 105, so code lookups were ambiguous: from_code(105) always returned GENTLE and both members equalled 105. This applies the same distinct-value pattern used for WaterModes: OFF now keeps its own code (107) while GENTLE keeps 105.
105 stays the wire code: the app sends 105 (CleanModeZero) for mop-only cleaning, so OFF has no wire code of its own. A new vacuum_mode_wire_code() helper translates OFF back to 105 at the boundaries that send codes to the device or map reported codes to names (get_cleaning_mode_parameters, set_clean_then_mop, fan_speed_mapping), and _resolve_clean_mode still resolves a reported 105 by device capability (OFF on pure-mop devices, GENTLE otherwise).
How to test
Fixes
VacuumModes.GENTLEandVacuumModes.OFFshare value 105 #999