Skip to content

Commit 905a2e4

Browse files
committed
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.
1 parent fe4fb6d commit 905a2e4

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

‎roborock/data/v1/v1_clean_modes.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,10 @@ def get_current_cleaning_mode(
374374
mop_mode: int | CleanRoutes | None,
375375
features: DeviceFeatures,
376376
) -> CleaningMode | None:
377-
"""Classify the current high-level cleaning mode from individual mode codes."""
377+
"""Classify the current high-level cleaning mode from individual mode codes.
378+
379+
The result is None when the classified mode is not in get_cleaning_mode_options(features).
380+
"""
378381
if not features.is_support_water_mode:
379382
return None
380383
clean_mode_enum = _resolve_clean_mode(clean_mode, features)

‎roborock/devices/traits/v1/status.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ class StatusTrait(StatusV2, common.V1TraitMixin, TraitUpdateListener):
8787
- Water Mode
8888
- Mop Route
8989
90-
You should use the _options version of the attribute to know which are
91-
supported for your device (i.e. fan_speed_options)
92-
Then you can use the _mapping to convert an int value to the actual Enum.
93-
(i.e. fan_speed_mapping)
94-
You can use the _name property to get the str value of the enum. (i.e. fan_speed_name)
90+
The _options and _mapping versions of the attribute (i.e. fan_speed_options,
91+
fan_speed_mapping) hold only the user-selectable values, i.e. what you can
92+
write to the device. They do not include SmartPlan or custom codes.
93+
Use the _name property (i.e. fan_speed_name), or get_fan_speed_name,
94+
get_water_mode_name and get_mop_route_name, to name the current value,
95+
including SmartPlan and custom codes.
9596
9697
"""
9798

‎tests/devices/traits/v1/test_status.py‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,10 +929,17 @@ def test_mixed_custom_and_smart_codes_are_custom() -> None:
929929
assert trait.current_cleaning_mode == CleaningMode.CUSTOM
930930

931931

932-
def test_current_mode_outside_options_is_none() -> None:
932+
@pytest.mark.parametrize(
933+
("features", "codes"),
934+
[
935+
({"is_custom_mode_supported": False}, (106, 204, 302)),
936+
({"is_smart_clean_mode_set_supported": False}, (110, 209, 306)),
937+
],
938+
)
939+
def test_current_mode_outside_options_is_none(features: dict[str, bool], codes: tuple[int, int, int]) -> None:
933940
"""A mode that the device does not offer is not reported as the current mode."""
934-
trait = _create_cleaning_mode_status_trait(is_custom_mode_supported=False)
935-
trait.fan_power, trait.water_box_mode, trait.mop_mode = 106, 204, 302
941+
trait = _create_cleaning_mode_status_trait(**features)
942+
trait.fan_power, trait.water_box_mode, trait.mop_mode = codes
936943

937944
assert trait.current_cleaning_mode is None
938945

@@ -1070,7 +1077,12 @@ def test_water_slide_raw_position_name_unchanged() -> None:
10701077

10711078
@pytest.mark.parametrize(
10721079
("soft", "pure_mop", "in_list", "name"),
1073-
[(True, False, True, "gentle"), (False, True, False, "off"), (False, False, False, "gentle")],
1080+
[
1081+
(True, False, True, "gentle"),
1082+
(True, True, True, "gentle"),
1083+
(False, True, False, "off"),
1084+
(False, False, False, "gentle"),
1085+
],
10741086
)
10751087
def test_fan_code_105(soft: bool, pure_mop: bool, in_list: bool, name: str) -> None:
10761088
"""Code 105 is only selectable as gentle on soft-clean devices but is always named."""

0 commit comments

Comments
 (0)