Repository navigation
refactor: give water slide modes their own enum values - #993
Open
rohitpatil9121 wants to merge 1 commit into
Open
rohitpatil9121 wants to merge 1 commit into
rohitpatil9121 wants to merge 1 commit into
Conversation
Water slide members of WaterModes reused the value strings of the legacy
modes ("low", "medium", "high", "extreme"), so StrEnum collapsed them into
aliases and dropped their codes (225, 235, 245, 250). Give each a unique
value and keep the shared user-facing name in display_name, like
CleanRoutes.DEEP_PLUS_CN.
This removes the workarounds that existed only to preserve those codes:
the WATER_SLIDE_MODE_MAPPING side table, the reverse lookup in
get_cleaning_mode_parameters, and the inline patch in
get_current_cleaning_mode (now _resolve_water_mode).
Also add a conformance check that fails when RoborockModeEnum members
alias each other by value. B01Fault already has such aliases and is
tracked in a baseline.
Fixes Python-roborock#987
rohitpatil9121
marked this pull request as ready for review
October 19, 2026 08:13
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #987
WaterModeswater slide members reused the value strings of the legacy modes ("low","medium","high","extreme").StrEnumdeduplicates by value, so these members became aliases ofLOW/MEDIUM/HIGH/EXTREMEand lost their own codes. For example,WaterModes.PURE_WATER_FLOW_MIDDLE.codewas202instead of235, andWaterModes.from_code_optional(235)returnedNone.This follows the approach suggested in the issue:
display_name, the same wayCleanRoutes.DEEP_PLUS_CNworks.WATER_SLIDE_MODE_MAPPINGside table, replaced by a private tuple of slide modesget_cleaning_mode_parameters, which now useswater_box_mode.codedirectlyisinstancepatch inget_current_cleaning_mode, now_resolve_water_mode(value, features), matching_resolve_clean_modeget_water_mode_mappingandget_water_slide_mode_nameusedisplay_name, so the user-facing names and the mapping stay the same.RoborockModeEnumalias each other by value.B01Faultalready has such aliases, so I added it to a baseline (strict xfail) instead of changing it here.Behavior change
.valuefor the four slide modes is nowpure_water_flow_small,pure_water_flow_middle,pure_water_super_beginandpure_water_flow_end. Consumers that readmode.valuefromwater_mode_optionsshould switch tomode.display_name. For Home Assistant, that is step 1 of the upgrade plan in the issue.water_mode_mappingandwater_mode_namereturn the same strings as before.Testing
display_name.test_water_slide_mode_mappingto readdisplay_namefromwater_mode_options.pytest tests/devices tests/conformance tests/data: 1225 passed, 54 xfailedruff checkandruff format --checkpass.mypyreports no errors in the changed files.tests/test_web_api.py::test_url_cyclingfails locally on Windows, onmainas well, so it is unrelated to this change.