Repository navigation
fix(v1): offer custom and SmartPlan cleaning modes on water-slide devices - #1025
paulleonartcalvo wants to merge 1 commit into
Conversation
…ices Water-slide devices report flow as slider positions, so get_water_modes() has no CUSTOMIZED (204) or SMART_MODE (209) entry for them and get_cleaning_mode_options() dropped CUSTOM and SMART_MODE even when the feature flags are set. get_current_cleaning_mode() still classifies those states, so consumers such as Home Assistant showed an unknown cleaning mode whenever the device was in custom or SmartPlan mode. Gate both options on the feature flags alone for water-slide devices. Verified on a Qrevo Edge 3 Pro (roborock.vacuum.a296): writing 106/204/302 and 110/209/306 with set_clean_motor_mode is accepted and read back as 106/204/300 and 110/209/306. Fixes Python-roborock#977 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
allenporter
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Carbon in Antigravity using our code-review skill and AGENTS.md.
Thanks for the thorough fix and hardware verification on #977! The approach and test coverage look great — left one inline question on simplifying get_cleaning_mode_options().
| # Water-slide devices report flow as slider positions, so their water mode | ||
| # list has no CUSTOMIZED (204) or SMART_MODE (209) entry, but they still | ||
| # accept and report those codes for the custom and SmartPlan modes. | ||
| is_water_slide = features.is_water_slide_mode_supported | ||
| if features.is_customized_clean_supported and (is_water_slide or WaterModes.CUSTOMIZED in supported_water_modes): | ||
| options.append(CleaningMode.CUSTOM) | ||
| if features.is_smart_clean_mode_set_supported and WaterModes.SMART_MODE in supported_water_modes: | ||
| if features.is_smart_clean_mode_set_supported and ( | ||
| is_water_slide or WaterModes.SMART_MODE in supported_water_modes | ||
| ): | ||
| options.append(CleaningMode.SMART_MODE) |
There was a problem hiding this comment.
Quick question on get_cleaning_mode_options(): on non-slide devices, get_water_modes() already appends WaterModes.SMART_MODE and WaterModes.CUSTOMIZED unconditionally whenever is_smart_clean_mode_set_supported / is_customized_clean_supported are set (lines 193–196) — checking supported_water_modes here was originally added in #817 only to exclude water-slide devices.
Now that water-slide devices support them too, can we drop supported_water_modes altogether and gate directly on the feature flags (matching get_clean_modes() and get_clean_routes())?
def get_cleaning_mode_options(features: DeviceFeatures) -> list[CleaningMode]:
if not features.is_support_water_mode:
return []
- supported_water_modes = get_water_modes(features)
options = [CleaningMode.VACUUM, CleaningMode.VAC_AND_MOP]
if features.is_pure_clean_mop_supported:
options.append(CleaningMode.MOP)
- # Water-slide devices report flow as slider positions, so their water mode
- # list has no CUSTOMIZED (204) or SMART_MODE (209) entry, but they still
- # accept and report those codes for the custom and SmartPlan modes.
- is_water_slide = features.is_water_slide_mode_supported
- if features.is_customized_clean_supported and (is_water_slide or WaterModes.CUSTOMIZED in supported_water_modes):
+ if features.is_customized_clean_supported:
options.append(CleaningMode.CUSTOM)
- if features.is_smart_clean_mode_set_supported and (
- is_water_slide or WaterModes.SMART_MODE in supported_water_modes
- ):
+ if features.is_smart_clean_mode_set_supported:
options.append(CleaningMode.SMART_MODE)
return options|
Confirming this on a second water-slide model: Roborock Saros 20 Complete ( While the robot is in SmartPlan it reports I applied the same idea locally (adding |
Fixes #977.
Problem
Water-slide devices report water flow as slider positions, so
get_water_modes()returns only the slide range for them. That list has noCUSTOMIZED(204) orSMART_MODE(209) entry, soget_cleaning_mode_options()dropsCUSTOMandSMART_MODEeven whenis_customized_clean_supported/is_smart_clean_mode_set_supportedare set.get_current_cleaning_mode()still returnscustom/smart_modefor those states, so Home Assistant's cleaning mode select showsunknownwhenever the device is in either mode, because the current value is not one of its options.Change
For water-slide devices,
CUSTOMandSMART_MODEare gated on their feature flags alone. Non-slide devices are unchanged. The existingtest_cleaning_mode_options_water_slide_deviceasserted the old behaviour; it now covers each flag combination, and there are new tests for readback and for the write payloads on slide devices.Device testing
#977 noted that writes had not been tested on hardware. On a Qrevo Edge 3 Pro (
roborock.vacuum.a296, water slide, both flags true), docked, throughset_clean_motor_mode:get_statusget_current_cleaning_modecustomsmart_modeBoth were accepted. Before this change both read back as a mode that is not in
cleaning_mode_options. The device was restored to 102 / 248 / 300 afterwards.uv run pytest(2287 passed) anduv run pre-commit run --all-filespass.🤖 Generated with Claude Code