From 21b42e26d5f6da40e37bd9c483cea6f5d9dacb17 Mon Sep 17 00:00:00 2001 From: Pau Lleonart Calvo Date: Mon, 9 Nov 2026 22:24:12 -0500 Subject: [PATCH 1/6] fix(v1): offer custom and SmartPlan cleaning modes on water-slide devices 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 #977 Co-Authored-By: Claude Opus 5.5 --- roborock/data/v1/v1_clean_modes.py | 10 +++- tests/devices/traits/v1/test_status.py | 79 ++++++++++++++++++++++++-- 2 files changed, 83 insertions(+), 6 deletions(-) diff --git a/roborock/data/v1/v1_clean_modes.py b/roborock/data/v1/v1_clean_modes.py index 7d1e1fe05..878538752 100644 --- a/roborock/data/v1/v1_clean_modes.py +++ b/roborock/data/v1/v1_clean_modes.py @@ -243,9 +243,15 @@ def get_cleaning_mode_options(features: DeviceFeatures) -> list[CleaningMode]: options = [CleaningMode.VACUUM, CleaningMode.VAC_AND_MOP] if features.is_pure_clean_mop_supported: options.append(CleaningMode.MOP) - if features.is_customized_clean_supported and WaterModes.CUSTOMIZED in supported_water_modes: + # 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) return options diff --git a/tests/devices/traits/v1/test_status.py b/tests/devices/traits/v1/test_status.py index c8e63e4cc..71e548485 100644 --- a/tests/devices/traits/v1/test_status.py +++ b/tests/devices/traits/v1/test_status.py @@ -825,21 +825,92 @@ async def test_set_cleaning_mode_water_slide_wire_payload( mock_rpc_channel.send_command.assert_called_once_with(RoborockCommand.SET_CLEAN_MOTOR_MODE, params=[expected]) -def test_cleaning_mode_options_water_slide_device() -> None: - """Water-slide devices should not expose unsupported custom or smart water modes.""" +@pytest.mark.parametrize( + ("customized_supported", "smart_supported", "expected_extra"), + [ + (True, True, [CleaningMode.CUSTOM, CleaningMode.SMART_MODE]), + (True, False, [CleaningMode.CUSTOM]), + (False, True, [CleaningMode.SMART_MODE]), + (False, False, []), + ], +) +def test_cleaning_mode_options_water_slide_device( + customized_supported: bool, + smart_supported: bool, + expected_extra: list[CleaningMode], +) -> None: + """Water-slide devices offer custom and SmartPlan modes when their feature flags say so.""" status_trait = _create_cleaning_mode_status_trait( is_water_slide_mode_supported=True, - is_customized_clean_supported=True, - is_smart_clean_mode_set_supported=True, + is_customized_clean_supported=customized_supported, + is_smart_clean_mode_set_supported=smart_supported, ) assert status_trait.cleaning_mode_options == [ CleaningMode.VACUUM, CleaningMode.VAC_AND_MOP, CleaningMode.MOP, + *expected_extra, ] +@pytest.mark.parametrize( + ("fan_power", "water_box_mode", "mop_mode", "expected_mode"), + [ + # Readback from a Qrevo Edge 3 Pro (a296) after writing each mode. + (106, 204, 300, CleaningMode.CUSTOM), + (110, 209, 306, CleaningMode.SMART_MODE), + # Qrevo Edge 2 Flow (a328) in custom mode, from #977. + (106, 204, 302, CleaningMode.CUSTOM), + ], +) +def test_current_cleaning_mode_water_slide_special_modes( + fan_power: int, + water_box_mode: int, + mop_mode: int, + expected_mode: CleaningMode, +) -> None: + """The current custom/SmartPlan mode on a water-slide device is one of its options.""" + status_trait = _create_cleaning_mode_status_trait( + is_water_slide_mode_supported=True, + is_customized_clean_supported=True, + is_smart_clean_mode_set_supported=True, + ) + status_trait.fan_power = fan_power + status_trait.water_box_mode = water_box_mode + status_trait.mop_mode = mop_mode + + assert status_trait.current_cleaning_mode == expected_mode + assert status_trait.current_cleaning_mode in status_trait.cleaning_mode_options + + +@pytest.mark.parametrize( + ("cleaning_mode", "expected_params"), + [ + (CleaningMode.CUSTOM, {"fan_power": 106, "water_box_mode": 204, "mop_mode": 302}), + (CleaningMode.SMART_MODE, {"fan_power": 110, "water_box_mode": 209, "mop_mode": 306}), + ], +) +async def test_set_cleaning_mode_water_slide_special_modes( + mock_rpc_channel: AsyncMock, + cleaning_mode: CleaningMode, + expected_params: dict[str, int], +) -> None: + """Custom and SmartPlan use the same special codes on water-slide devices.""" + status_trait = _create_cleaning_mode_status_trait( + is_water_slide_mode_supported=True, + is_customized_clean_supported=True, + is_smart_clean_mode_set_supported=True, + ) + status_trait._rpc_channel = mock_rpc_channel # type: ignore[assignment] + + await status_trait.set_cleaning_mode(cleaning_mode) + + mock_rpc_channel.send_command.assert_called_once_with( + RoborockCommand.SET_CLEAN_MOTOR_MODE, params=[expected_params] + ) + + def test_current_cleaning_mode_gentle_not_mop_without_pure_mop() -> None: """Test code 105 is not treated as mop-only on devices without pure mop.""" status_trait = _create_cleaning_mode_status_trait(is_pure_clean_mop_supported=False) From 341c3e14626fa21a48b72657236ab0075d0ca2a4 Mon Sep 17 00:00:00 2001 From: infy1995 Date: Mon, 16 Nov 2026 17:03:57 +0100 Subject: [PATCH 2/6] fix(v1): correct which models support custom and soft clean modes RubyPlus, RubySC and RubySE do not support the custom cleaning mode, and RubySC, RubySLite and RubySE support the soft clean (gentle) fan mode. The model lists were compared with the app plugin. --- docs/V1_DEVICE_FEATURES.md | 6 ++++-- roborock/device_features.py | 14 ++++++++++++- .../test_supported_features.ambr | 2 +- tests/test_supported_features.py | 21 +++++++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/docs/V1_DEVICE_FEATURES.md b/docs/V1_DEVICE_FEATURES.md index b731c5520..31327c901 100644 --- a/docs/V1_DEVICE_FEATURES.md +++ b/docs/V1_DEVICE_FEATURES.md @@ -1621,7 +1621,8 @@ These features are enabled/disabled based on specific device model whitelists or --- ### is_soft_clean_mode_supported -**Model Whitelist:** TANOSV, TANOSE, TANOS +**Model Whitelist:** TANOSV, TANOSE, TANOS, RUBYSC, RUBYSLITE, RUBYSE +**Source:** Roborock app `isSoftCleanModeSupportedInMain` **Feature:** Soft Clean Mode **Description:** Gentle cleaning mode for delicate floors. **Impact:** Reduced suction and brush speed for sensitive surfaces. @@ -1629,7 +1630,8 @@ These features are enabled/disabled based on specific device model whitelists or --- ### is_custom_mode_supported -**Model Blacklist:** TANOS (all except TANOS) +**Model Blacklist:** TANOS, RUBYPLUS, RUBYSC, RUBYSE (all except these) +**Source:** Roborock app `isCustomModeSupported` **Feature:** Custom Cleaning Mode **Description:** User-defined custom cleaning modes. **Impact:** Create personalized cleaning modes with specific parameters. diff --git a/roborock/device_features.py b/roborock/device_features.py index 2e2a2be88..448dec5ee 100644 --- a/roborock/device_features.py +++ b/roborock/device_features.py @@ -698,10 +698,22 @@ class DeviceFeatures(RoborockBase): RoborockProductNickname.TANOSV, RoborockProductNickname.TANOSE, RoborockProductNickname.TANOS, + RoborockProductNickname.RUBYSC, + RoborockProductNickname.RUBYSLITE, + RoborockProductNickname.RUBYSE, + ] + } + ) + is_custom_mode_supported: bool = field( + metadata={ + "model_blacklist": [ + RoborockProductNickname.TANOS, + RoborockProductNickname.RUBYPLUS, + RoborockProductNickname.RUBYSC, + RoborockProductNickname.RUBYSE, ] } ) - is_custom_mode_supported: bool = field(metadata={"model_blacklist": [RoborockProductNickname.TANOS]}) is_support_custom_carpet: bool = field(metadata={"model_whitelist": [RoborockProductNickname.ULTRONLITE]}) is_show_general_obstacle_supported: bool = field(metadata={"model_whitelist": [RoborockProductNickname.TANOSSPLUS]}) is_show_obstacle_photo_supported: bool = field( diff --git a/tests/__snapshots__/test_supported_features.ambr b/tests/__snapshots__/test_supported_features.ambr index 61855ead0..cc8924bb5 100644 --- a/tests/__snapshots__/test_supported_features.ambr +++ b/tests/__snapshots__/test_supported_features.ambr @@ -1717,7 +1717,7 @@ 'is_smart_clean_mode_set_supported': False, 'is_smart_water_supported': False, 'is_soak_and_wash_supported': False, - 'is_soft_clean_mode_supported': False, + 'is_soft_clean_mode_supported': True, 'is_sound_record_supported': False, 'is_sr_map_supported': False, 'is_stair_door_sill_supported': False, diff --git a/tests/test_supported_features.py b/tests/test_supported_features.py index 4eaaa4193..1f73a9a99 100644 --- a/tests/test_supported_features.py +++ b/tests/test_supported_features.py @@ -734,3 +734,24 @@ def test_device_features_from_home_data( ) feature_dict = {k: v for k, v in asdict(device_features).items() if isinstance(v, bool)} assert feature_dict == snapshot + + +@pytest.mark.parametrize( + ("nickname", "custom", "soft"), + [ + (RoborockProductNickname.TANOS, False, True), + (RoborockProductNickname.RUBYPLUS, False, False), + (RoborockProductNickname.RUBYSC, False, True), + (RoborockProductNickname.RUBYSE, False, True), + (RoborockProductNickname.RUBYSLITE, True, True), + (RoborockProductNickname.TANOSV, True, True), + (RoborockProductNickname.PEARL, True, False), + ], +) +def test_custom_and_soft_clean_mode_model_lists(nickname: RoborockProductNickname, custom: bool, soft: bool) -> None: + """Custom and soft clean mode model lists match the Roborock app.""" + features = DeviceFeatures.from_feature_flags( + new_feature_info=0, new_feature_info_str="", feature_info=[], product_nickname=nickname + ) + assert features.is_custom_mode_supported is custom + assert features.is_soft_clean_mode_supported is soft From 08cbf8c28d640933e0c2196c2f60fca8c36ab543 Mon Sep 17 00:00:00 2001 From: infy1995 Date: Mon, 16 Nov 2026 17:11:00 +0100 Subject: [PATCH 3/6] feat(v1): keep SmartPlan and custom codes out of fan, water and mop route options --- roborock/data/v1/v1_clean_modes.py | 73 ++++++++++++++--------- roborock/devices/traits/v1/status.py | 11 ++-- tests/devices/traits/v1/test_status.py | 81 ++++++++++++++++++++------ 3 files changed, 115 insertions(+), 50 deletions(-) diff --git a/roborock/data/v1/v1_clean_modes.py b/roborock/data/v1/v1_clean_modes.py index 878538752..13035a833 100644 --- a/roborock/data/v1/v1_clean_modes.py +++ b/roborock/data/v1/v1_clean_modes.py @@ -131,16 +131,8 @@ def get_clean_modes(features: DeviceFeatures) -> list[VacuumModes]: if features.is_max_plus_mode_supported or features.is_none_pure_clean_mop_with_max_plus: # If the vacuum has max plus mode supported modes.append(VacuumModes.MAX_PLUS) - if features.is_pure_clean_mop_supported: - # If the vacuum is capable of 'pure mop clean' aka no vacuum - modes.append(VacuumModes.OFF) - else: - # If not, we can add gentle + if features.is_soft_clean_mode_supported: modes.append(VacuumModes.GENTLE) - if features.is_smart_clean_mode_set_supported: - modes.append(VacuumModes.SMART_MODE) - if features.is_customized_clean_supported: - modes.append(VacuumModes.CUSTOMIZED) return modes @@ -165,10 +157,6 @@ def get_clean_routes(features: DeviceFeatures, region: str) -> list[CleanRoutes] if features.is_clean_route_fast_mode_supported: supported.append(CleanRoutes.FAST) - if features.is_smart_clean_mode_set_supported: - supported.append(CleanRoutes.SMART_MODE) - if features.is_customized_clean_supported: - supported.append(CleanRoutes.CUSTOMIZED) return supported @@ -190,14 +178,54 @@ def get_water_modes(features: DeviceFeatures) -> list[WaterModes]: supported_modes.append(WaterModes.CUSTOM) if features.is_mop_shake_module_supported and features.is_mop_shake_water_max_supported: supported_modes.append(WaterModes.EXTREME) - if features.is_smart_clean_mode_set_supported: - supported_modes.append(WaterModes.SMART_MODE) - if features.is_customized_clean_supported: - supported_modes.append(WaterModes.CUSTOMIZED) return supported_modes +def get_fan_speed_name(code: int, features: DeviceFeatures) -> str | None: + """Name a fan power code: selectable modes first, then SmartPlan, custom and code 105.""" + for mode in get_clean_modes(features): + if mode.code == code: + return mode.value + if code == VacuumModes.SMART_MODE.code: + return VacuumModes.SMART_MODE.value + if code == VacuumModes.CUSTOMIZED.code: + return VacuumModes.CUSTOMIZED.value + if code == VacuumModes.GENTLE.code: + # 105 is the mop-only code on pure-mop devices and "gentle" elsewhere. + return VacuumModes.OFF.value if features.is_pure_clean_mop_supported else VacuumModes.GENTLE.value + return None + + +def get_water_mode_name(code: int, features: DeviceFeatures) -> str | None: + """Name a water box code: selectable modes (or slide ranges) first, then SmartPlan and custom.""" + if features.is_water_slide_mode_supported: + slide_mode = _resolve_water_slide_mode(code) + if slide_mode is not None: + return slide_mode.display_name + else: + for mode in get_water_modes(features): + if mode.code == code: + return mode.display_name + if code == WaterModes.SMART_MODE.code: + return WaterModes.SMART_MODE.display_name + if code == WaterModes.CUSTOMIZED.code: + return WaterModes.CUSTOMIZED.display_name + return None + + +def get_mop_route_name(code: int, features: DeviceFeatures, region: str) -> str | None: + """Name a mop route code: selectable routes first, then SmartPlan and custom.""" + for route in get_clean_routes(features, region): + if route.code == code: + return route.display_name + if code == CleanRoutes.SMART_MODE.code: + return CleanRoutes.SMART_MODE.display_name + if code == CleanRoutes.CUSTOMIZED.code: + return CleanRoutes.CUSTOMIZED.display_name + return None + + def get_water_slide_mode_name(code: int) -> str | None: """Get the app's range name for a water slide code, or None if out of range.""" mode = _resolve_water_slide_mode(code) @@ -239,19 +267,12 @@ 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 diff --git a/roborock/devices/traits/v1/status.py b/roborock/devices/traits/v1/status.py index e2853ef7c..16451b121 100644 --- a/roborock/devices/traits/v1/status.py +++ b/roborock/devices/traits/v1/status.py @@ -18,7 +18,10 @@ get_cleaning_mode_parameters, get_current_cleaning_mode, get_dock_state, + get_fan_speed_name, + get_mop_route_name, get_water_mode_mapping, + get_water_mode_name, get_water_modes, get_water_slide_mode_name, resolve_cleaning_mode, @@ -161,21 +164,19 @@ def cleaning_mode_options(self) -> list[CleaningMode]: def fan_speed_name(self) -> str | None: if self.fan_power is None: return None - return self.fan_speed_mapping.get(self.fan_power) + return get_fan_speed_name(self.fan_power, self._device_features_trait) @property def water_mode_name(self) -> str | None: if self.water_box_mode is None: return None - if self._device_features_trait.is_water_slide_mode_supported: - return get_water_slide_mode_name(self.water_box_mode) - return self.water_mode_mapping.get(self.water_box_mode) + return get_water_mode_name(self.water_box_mode, self._device_features_trait) @property def mop_route_name(self) -> str | None: if self.mop_mode is None: return None - return self.mop_route_mapping.get(self.mop_mode) + return get_mop_route_name(self.mop_mode, self._device_features_trait, self._region or "us") @property def current_cleaning_mode(self) -> CleaningMode | None: diff --git a/tests/devices/traits/v1/test_status.py b/tests/devices/traits/v1/test_status.py index 71e548485..776680fd0 100644 --- a/tests/devices/traits/v1/test_status.py +++ b/tests/devices/traits/v1/test_status.py @@ -633,7 +633,7 @@ def test_get_cleaning_mode_parameters_qrevo_edge_2() -> None: "mop_mode": CleanRoutes.STANDARD.code, } ] - assert VacuumModes.OFF in status_trait.fan_speed_options + assert 105 not in {mode.code for mode in status_trait.fan_speed_options} assert VacuumModes.OFF_RAISE_MAIN_BRUSH not in status_trait.fan_speed_options @@ -825,32 +825,20 @@ async def test_set_cleaning_mode_water_slide_wire_payload( mock_rpc_channel.send_command.assert_called_once_with(RoborockCommand.SET_CLEAN_MOTOR_MODE, params=[expected]) -@pytest.mark.parametrize( - ("customized_supported", "smart_supported", "expected_extra"), - [ - (True, True, [CleaningMode.CUSTOM, CleaningMode.SMART_MODE]), - (True, False, [CleaningMode.CUSTOM]), - (False, True, [CleaningMode.SMART_MODE]), - (False, False, []), - ], -) -def test_cleaning_mode_options_water_slide_device( - customized_supported: bool, - smart_supported: bool, - expected_extra: list[CleaningMode], -) -> None: - """Water-slide devices offer custom and SmartPlan modes when their feature flags say so.""" +def test_cleaning_mode_options_water_slide_device() -> None: + """Custom and SmartPlan options depend only on their feature flags, also on water-slide devices.""" status_trait = _create_cleaning_mode_status_trait( is_water_slide_mode_supported=True, - is_customized_clean_supported=customized_supported, - is_smart_clean_mode_set_supported=smart_supported, + is_customized_clean_supported=True, + is_smart_clean_mode_set_supported=True, ) assert status_trait.cleaning_mode_options == [ CleaningMode.VACUUM, CleaningMode.VAC_AND_MOP, CleaningMode.MOP, - *expected_extra, + CleaningMode.CUSTOM, + CleaningMode.SMART_MODE, ] @@ -993,6 +981,61 @@ def test_water_slide_mode_name_covers_slider_positions(water_box_mode: int, expe assert status_trait.water_mode_name == expected_name +def test_option_lists_exclude_special_codes() -> None: + """SmartPlan and custom codes are never offered as fan, water or mop route choices.""" + trait = _create_cleaning_mode_status_trait(is_smart_clean_mode_set_supported=True) + special = {106, 110, 204, 209, 302, 306} + assert special.isdisjoint(m.code for m in trait.fan_speed_options) + assert special.isdisjoint(m.code for m in trait.water_mode_options) + assert special.isdisjoint(m.code for m in trait.mop_route_options) + assert special.isdisjoint(trait.fan_speed_mapping) + assert special.isdisjoint(trait.water_mode_mapping) + assert special.isdisjoint(trait.mop_route_mapping) + + +@pytest.mark.parametrize("water_slide", [False, True]) +@pytest.mark.parametrize( + ("fan", "water", "mop", "names"), + [ + (110, 209, 306, ("smart_mode", "smart_mode", "smart_mode")), + (106, 204, 302, ("custom", "custom", "custom")), + ], +) +def test_special_code_names(water_slide: bool, fan: int, water: int, mop: int, names: tuple[str, str, str]) -> None: + """Special codes are still named even though they are not selectable.""" + trait = _create_cleaning_mode_status_trait( + is_smart_clean_mode_set_supported=True, is_water_slide_mode_supported=water_slide + ) + trait.fan_power, trait.water_box_mode, trait.mop_mode = fan, water, mop + assert (trait.fan_speed_name, trait.water_mode_name, trait.mop_route_name) == names + + +def test_water_slide_raw_position_name_unchanged() -> None: + """Raw slider positions keep resolving to their app range name.""" + trait = _create_cleaning_mode_status_trait(is_water_slide_mode_supported=True) + trait.water_box_mode = 227 + assert trait.water_mode_name == "low" + + +@pytest.mark.parametrize( + ("soft", "pure_mop", "in_list", "name"), + [(True, False, True, "gentle"), (False, True, False, "off"), (False, False, False, "gentle")], +) +def test_fan_code_105(soft: bool, pure_mop: bool, in_list: bool, name: str) -> None: + """Code 105 is only selectable as gentle on soft-clean devices but is always named.""" + trait = _create_cleaning_mode_status_trait(is_soft_clean_mode_supported=soft, is_pure_clean_mop_supported=pure_mop) + trait.fan_power = 105 + assert (105 in {m.code for m in trait.fan_speed_options}) is in_list + assert trait.fan_speed_name == name + + +def test_unknown_codes_have_no_name() -> None: + """Codes that are neither selectable nor special have no name.""" + trait = _create_cleaning_mode_status_trait() + trait.fan_power, trait.water_box_mode, trait.mop_mode = 999, 999, 999 + assert (trait.fan_speed_name, trait.water_mode_name, trait.mop_route_name) == (None, None, None) + + async def test_update_from_dps(status_trait: StatusTrait) -> None: """Test updating status from data protocol push message.""" assert status_trait.battery is None From 3245a6755eeed290d15b31685f04a1cd24e04637 Mon Sep 17 00:00:00 2001 From: infy1995 Date: Mon, 16 Nov 2026 17:15:00 +0100 Subject: [PATCH 4/6] feat(v1): offer SmartPlan and custom cleaning modes from device flags SmartPlan and custom no longer depend on the water mode list, which never contains their codes on water-slide devices, so those devices now get both modes. Custom depends on the model supporting it and no longer on a shake or spin mop module, so electronic water tank models such as the S6 MaxV get it too. Custom codes are checked before SmartPlan codes, and a recognized mode the device does not offer is reported as None. --- roborock/data/v1/v1_clean_modes.py | 27 ++++++++--- tests/devices/traits/v1/test_status.py | 65 +++++++++++++++++++++++--- 2 files changed, 78 insertions(+), 14 deletions(-) diff --git a/roborock/data/v1/v1_clean_modes.py b/roborock/data/v1/v1_clean_modes.py index 13035a833..54c060d60 100644 --- a/roborock/data/v1/v1_clean_modes.py +++ b/roborock/data/v1/v1_clean_modes.py @@ -270,7 +270,7 @@ def get_cleaning_mode_options(features: DeviceFeatures) -> list[CleaningMode]: options = [CleaningMode.VACUUM, CleaningMode.VAC_AND_MOP] if features.is_pure_clean_mop_supported: options.append(CleaningMode.MOP) - if features.is_customized_clean_supported: + if features.is_custom_mode_supported: options.append(CleaningMode.CUSTOM) if features.is_smart_clean_mode_set_supported: options.append(CleaningMode.SMART_MODE) @@ -383,17 +383,30 @@ def get_current_cleaning_mode( if clean_mode_enum is None or water_mode_enum is None: return None - if is_smart_mode_set(water_mode_enum, clean_mode_enum, mop_mode_enum): - return CleaningMode.SMART_MODE - if is_mode_customized(clean_mode_enum, water_mode_enum, mop_mode_enum): + mode = _classify_cleaning_mode(clean_mode_enum, water_mode_enum, mop_mode_enum, features) + if mode not in get_cleaning_mode_options(features): + return None + return mode + + +def _classify_cleaning_mode( + clean_mode: VacuumModes, + water_mode: WaterModes, + mop_mode: CleanRoutes | None, + features: DeviceFeatures, +) -> CleaningMode: + """Classify resolved mode enums, checking custom before SmartPlan like the app.""" + if is_mode_customized(clean_mode, water_mode, mop_mode): return CleaningMode.CUSTOM - if water_mode_enum != WaterModes.OFF: + if is_smart_mode_set(water_mode, clean_mode, mop_mode): + return CleaningMode.SMART_MODE + if water_mode != WaterModes.OFF: try: - if clean_mode_enum == get_mop_only_vacuum_mode(features): + if clean_mode == get_mop_only_vacuum_mode(features): return CleaningMode.MOP except RoborockUnsupportedFeature: pass - if water_mode_enum == WaterModes.OFF: + if water_mode == WaterModes.OFF: return CleaningMode.VACUUM return CleaningMode.VAC_AND_MOP diff --git a/tests/devices/traits/v1/test_status.py b/tests/devices/traits/v1/test_status.py index 776680fd0..ff2462c21 100644 --- a/tests/devices/traits/v1/test_status.py +++ b/tests/devices/traits/v1/test_status.py @@ -726,7 +726,9 @@ def test_current_cleaning_mode_water_slide_legacy_codes( water_box_mode: int | None, expected_mode: CleaningMode | None ) -> None: """Keep legacy and unknown status decoding on water-slide devices.""" - status_trait = _create_cleaning_mode_status_trait(is_water_slide_mode_supported=True) + status_trait = _create_cleaning_mode_status_trait( + is_water_slide_mode_supported=True, is_smart_clean_mode_set_supported=True + ) status_trait.fan_power = 102 status_trait.water_box_mode = water_box_mode status_trait.mop_mode = 300 @@ -825,20 +827,31 @@ async def test_set_cleaning_mode_water_slide_wire_payload( mock_rpc_channel.send_command.assert_called_once_with(RoborockCommand.SET_CLEAN_MOTOR_MODE, params=[expected]) -def test_cleaning_mode_options_water_slide_device() -> None: +@pytest.mark.parametrize("water_slide", [False, True]) +@pytest.mark.parametrize( + ("custom", "smart", "extra"), + [ + (True, True, [CleaningMode.CUSTOM, CleaningMode.SMART_MODE]), + (False, True, [CleaningMode.SMART_MODE]), + (True, False, [CleaningMode.CUSTOM]), + (False, False, []), + ], +) +def test_cleaning_mode_options_follow_app_flags( + water_slide: bool, custom: bool, smart: bool, extra: list[CleaningMode] +) -> None: """Custom and SmartPlan options depend only on their feature flags, also on water-slide devices.""" status_trait = _create_cleaning_mode_status_trait( - is_water_slide_mode_supported=True, - is_customized_clean_supported=True, - is_smart_clean_mode_set_supported=True, + is_water_slide_mode_supported=water_slide, + is_custom_mode_supported=custom, + is_smart_clean_mode_set_supported=smart, ) assert status_trait.cleaning_mode_options == [ CleaningMode.VACUUM, CleaningMode.VAC_AND_MOP, CleaningMode.MOP, - CleaningMode.CUSTOM, - CleaningMode.SMART_MODE, + *extra, ] @@ -899,6 +912,44 @@ async def test_set_cleaning_mode_water_slide_special_modes( ) +def test_custom_mode_does_not_need_customized_clean() -> None: + """Custom is offered and recognized on models without a shake or spin mop module.""" + status_trait = _create_cleaning_mode_status_trait(is_customized_clean_supported=False) + status_trait.fan_power, status_trait.water_box_mode, status_trait.mop_mode = 106, 204, 302 + + assert CleaningMode.CUSTOM in status_trait.cleaning_mode_options + assert status_trait.current_cleaning_mode == CleaningMode.CUSTOM + + +def test_mixed_custom_and_smart_codes_are_custom() -> None: + """Custom wins over SmartPlan when the codes mix both.""" + trait = _create_cleaning_mode_status_trait(is_custom_mode_supported=True, is_smart_clean_mode_set_supported=True) + trait.fan_power, trait.water_box_mode, trait.mop_mode = 106, 209, 300 + + assert trait.current_cleaning_mode == CleaningMode.CUSTOM + + +def test_current_mode_outside_options_is_none() -> None: + """A mode that the device does not offer is not reported as the current mode.""" + trait = _create_cleaning_mode_status_trait(is_custom_mode_supported=False) + trait.fan_power, trait.water_box_mode, trait.mop_mode = 106, 204, 302 + + assert trait.current_cleaning_mode is None + + +def test_saros_10r_smartplan_is_listed() -> None: + """The Saros 10R SmartPlan codes classify as SmartPlan, which is among the options.""" + trait = _create_cleaning_mode_status_trait( + is_water_slide_mode_supported=True, + is_custom_mode_supported=True, + is_smart_clean_mode_set_supported=True, + ) + trait.fan_power, trait.water_box_mode, trait.mop_mode = 110, 209, 306 + + assert trait.current_cleaning_mode == CleaningMode.SMART_MODE + assert trait.current_cleaning_mode in trait.cleaning_mode_options + + def test_current_cleaning_mode_gentle_not_mop_without_pure_mop() -> None: """Test code 105 is not treated as mop-only on devices without pure mop.""" status_trait = _create_cleaning_mode_status_trait(is_pure_clean_mop_supported=False) From c96115fad5b890ee6b07549a98d68e52eb8f77da Mon Sep 17 00:00:00 2001 From: infy1995 Date: Mon, 16 Nov 2026 17:19:52 +0100 Subject: [PATCH 5/6] chore: update snapshots for cleaning mode option lists --- tests/devices/__snapshots__/test_v1_device.ambr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/devices/__snapshots__/test_v1_device.ambr b/tests/devices/__snapshots__/test_v1_device.ambr index e358417f1..93a786fe3 100644 --- a/tests/devices/__snapshots__/test_v1_device.ambr +++ b/tests/devices/__snapshots__/test_v1_device.ambr @@ -1042,7 +1042,7 @@ }) # --- # name: test_device_trait_command_parsing[status] - StatusTrait(adbumper_status=None, auto_dust_collection=None, avoid_count=None, back_type=None, battery=100, camera_status=None, charge_status=None, clean_area=91287500, clean_fluid_status=None, clean_percent=None, clean_time=5405, cleaning_mode_options=[, , , ], clear_water_box_status=None, collision_avoid_status=None, command=, common_status=None, converter=DefaultConverter, corner_clean_mode=None, current_cleaning_mode=, current_cleaning_mode_name='custom', current_map=0, debug_mode=None, dirty_water_box_status=None, distance_off=0, dnd_enabled=1, dock_cool_fan_status=None, dock_error_status=None, dock_state=, dock_type=None, dry_status=None, dss=None, dust_bag_status=None, dust_collection_status=None, error_code=, error_code_name='none', fan_power=106, fan_speed_mapping={101: 'quiet', 102: 'balanced', 103: 'turbo', 104: 'max', 108: 'max_plus', 105: 'off', 106: 'custom'}, fan_speed_name='custom', fan_speed_options=[, , , , , , ], has_am=None, hatch_door_status=None, home_sec_enable_password=None, home_sec_status=None, in_cleaning=, in_fresh_state=1, in_returning=0, in_warmup=None, is_battery_charging=False, is_exploring=None, is_locating=0, kct=None, lab_status=1, last_clean_t=None, lock_status=0, map_present=1, map_status=3, mop_forbidden_enable=0, mop_mode=None, mop_route_mapping={300: 'standard', 301: 'deep', 302: 'custom'}, mop_route_name=None, mop_route_options=[, , ], msg_seq=515, msg_ver=2, rdt=None, repeat=None, replenish_mode=None, rss=None, square_meter_clean_area=91.3, state=, state_name='charging', subdivision_sets=None, switch_map_mode=None, unsave_map_flag=0, unsave_map_reason=4, wash_phase=None, wash_ready=None, wash_status=None, water_box_carriage_status=0, water_box_filter_status=None, water_box_mode=204, water_box_status=0, water_mode_mapping={200: 'off', 201: 'mild', 202: 'standard', 203: 'intense', 207: 'custom_water_flow', 204: 'custom'}, water_mode_name='custom', water_mode_options=[, , , , , ], water_shortage_status=None) + StatusTrait(adbumper_status=None, auto_dust_collection=None, avoid_count=None, back_type=None, battery=100, camera_status=None, charge_status=None, clean_area=91287500, clean_fluid_status=None, clean_percent=None, clean_time=5405, cleaning_mode_options=[, , , ], clear_water_box_status=None, collision_avoid_status=None, command=, common_status=None, converter=DefaultConverter, corner_clean_mode=None, current_cleaning_mode=, current_cleaning_mode_name='custom', current_map=0, debug_mode=None, dirty_water_box_status=None, distance_off=0, dnd_enabled=1, dock_cool_fan_status=None, dock_error_status=None, dock_state=, dock_type=None, dry_status=None, dss=None, dust_bag_status=None, dust_collection_status=None, error_code=, error_code_name='none', fan_power=106, fan_speed_mapping={101: 'quiet', 102: 'balanced', 103: 'turbo', 104: 'max', 108: 'max_plus'}, fan_speed_name='custom', fan_speed_options=[, , , , ], has_am=None, hatch_door_status=None, home_sec_enable_password=None, home_sec_status=None, in_cleaning=, in_fresh_state=1, in_returning=0, in_warmup=None, is_battery_charging=False, is_exploring=None, is_locating=0, kct=None, lab_status=1, last_clean_t=None, lock_status=0, map_present=1, map_status=3, mop_forbidden_enable=0, mop_mode=None, mop_route_mapping={300: 'standard', 301: 'deep'}, mop_route_name=None, mop_route_options=[, ], msg_seq=515, msg_ver=2, rdt=None, repeat=None, replenish_mode=None, rss=None, square_meter_clean_area=91.3, state=, state_name='charging', subdivision_sets=None, switch_map_mode=None, unsave_map_flag=0, unsave_map_reason=4, wash_phase=None, wash_ready=None, wash_status=None, water_box_carriage_status=0, water_box_filter_status=None, water_box_mode=204, water_box_status=0, water_mode_mapping={200: 'off', 201: 'mild', 202: 'standard', 203: 'intense', 207: 'custom_water_flow'}, water_mode_name='custom', water_mode_options=[, , , , ], water_shortage_status=None) # --- # name: test_device_trait_command_parsing[status].1 dict({ From 2019adf90d905ce4a8c0524c63cb67b6466464fd Mon Sep 17 00:00:00 2001 From: infy1995 Date: Mon, 16 Nov 2026 17:25:30 +0100 Subject: [PATCH 6/6] docs(v1): clarify option lists and current cleaning mode contract Also cover code 105 on pure-mop soft-clean devices and SmartPlan codes without SmartPlan support. --- roborock/data/v1/v1_clean_modes.py | 5 ++++- roborock/devices/traits/v1/status.py | 11 ++++++----- tests/devices/traits/v1/test_status.py | 20 ++++++++++++++++---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/roborock/data/v1/v1_clean_modes.py b/roborock/data/v1/v1_clean_modes.py index 54c060d60..7b3f6776b 100644 --- a/roborock/data/v1/v1_clean_modes.py +++ b/roborock/data/v1/v1_clean_modes.py @@ -374,7 +374,10 @@ def get_current_cleaning_mode( mop_mode: int | CleanRoutes | None, features: DeviceFeatures, ) -> CleaningMode | None: - """Classify the current high-level cleaning mode from individual mode codes.""" + """Classify the current high-level cleaning mode from individual mode codes. + + The result is None when the classified mode is not in get_cleaning_mode_options(features). + """ if not features.is_support_water_mode: return None clean_mode_enum = _resolve_clean_mode(clean_mode, features) diff --git a/roborock/devices/traits/v1/status.py b/roborock/devices/traits/v1/status.py index 16451b121..3f7dee6e9 100644 --- a/roborock/devices/traits/v1/status.py +++ b/roborock/devices/traits/v1/status.py @@ -87,11 +87,12 @@ class StatusTrait(StatusV2, common.V1TraitMixin, TraitUpdateListener): - Water Mode - Mop Route - You should use the _options version of the attribute to know which are - supported for your device (i.e. fan_speed_options) - Then you can use the _mapping to convert an int value to the actual Enum. - (i.e. fan_speed_mapping) - You can use the _name property to get the str value of the enum. (i.e. fan_speed_name) + The _options and _mapping versions of the attribute (i.e. fan_speed_options, + fan_speed_mapping) hold only the user-selectable values, i.e. what you can + write to the device. They do not include SmartPlan or custom codes. + Use the _name property (i.e. fan_speed_name), or get_fan_speed_name, + get_water_mode_name and get_mop_route_name, to name the current value, + including SmartPlan and custom codes. """ diff --git a/tests/devices/traits/v1/test_status.py b/tests/devices/traits/v1/test_status.py index ff2462c21..48d834dd2 100644 --- a/tests/devices/traits/v1/test_status.py +++ b/tests/devices/traits/v1/test_status.py @@ -929,10 +929,17 @@ def test_mixed_custom_and_smart_codes_are_custom() -> None: assert trait.current_cleaning_mode == CleaningMode.CUSTOM -def test_current_mode_outside_options_is_none() -> None: +@pytest.mark.parametrize( + ("features", "codes"), + [ + ({"is_custom_mode_supported": False}, (106, 204, 302)), + ({"is_smart_clean_mode_set_supported": False}, (110, 209, 306)), + ], +) +def test_current_mode_outside_options_is_none(features: dict[str, bool], codes: tuple[int, int, int]) -> None: """A mode that the device does not offer is not reported as the current mode.""" - trait = _create_cleaning_mode_status_trait(is_custom_mode_supported=False) - trait.fan_power, trait.water_box_mode, trait.mop_mode = 106, 204, 302 + trait = _create_cleaning_mode_status_trait(**features) + trait.fan_power, trait.water_box_mode, trait.mop_mode = codes assert trait.current_cleaning_mode is None @@ -1070,7 +1077,12 @@ def test_water_slide_raw_position_name_unchanged() -> None: @pytest.mark.parametrize( ("soft", "pure_mop", "in_list", "name"), - [(True, False, True, "gentle"), (False, True, False, "off"), (False, False, False, "gentle")], + [ + (True, False, True, "gentle"), + (True, True, True, "gentle"), + (False, True, False, "off"), + (False, False, False, "gentle"), + ], ) def test_fan_code_105(soft: bool, pure_mop: bool, in_list: bool, name: str) -> None: """Code 105 is only selectable as gentle on soft-clean devices but is always named."""