Skip to content

Commit 4e06396

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 281ac99 commit 4e06396

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
@@ -376,7 +376,10 @@ def get_current_cleaning_mode(
376376
mop_mode: int | CleanRoutes | None,
377377
features: DeviceFeatures,
378378
) -> CleaningMode | None:
379-
"""Classify the current high-level cleaning mode from individual mode codes."""
379+
"""Classify the current high-level cleaning mode from individual mode codes.
380+
381+
The result is None when the classified mode is not in get_cleaning_mode_options(features).
382+
"""
380383
if not features.is_support_water_mode:
381384
return None
382385
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
@@ -873,10 +873,17 @@ def test_mixed_custom_and_smart_codes_are_custom() -> None:
873873
assert trait.current_cleaning_mode == CleaningMode.CUSTOM
874874

875875

876-
def test_current_mode_outside_options_is_none() -> None:
876+
@pytest.mark.parametrize(
877+
("features", "codes"),
878+
[
879+
({"is_custom_mode_supported": False}, (106, 204, 302)),
880+
({"is_smart_clean_mode_set_supported": False}, (110, 209, 306)),
881+
],
882+
)
883+
def test_current_mode_outside_options_is_none(features: dict[str, bool], codes: tuple[int, int, int]) -> None:
877884
"""A mode that the device does not offer is not reported as the current mode."""
878-
trait = _create_cleaning_mode_status_trait(is_custom_mode_supported=False)
879-
trait.fan_power, trait.water_box_mode, trait.mop_mode = 106, 204, 302
885+
trait = _create_cleaning_mode_status_trait(**features)
886+
trait.fan_power, trait.water_box_mode, trait.mop_mode = codes
880887

881888
assert trait.current_cleaning_mode is None
882889

@@ -1014,7 +1021,12 @@ def test_water_slide_raw_position_name_unchanged() -> None:
10141021

10151022
@pytest.mark.parametrize(
10161023
("soft", "pure_mop", "in_list", "name"),
1017-
[(True, False, True, "gentle"), (False, True, False, "off"), (False, False, False, "gentle")],
1024+
[
1025+
(True, False, True, "gentle"),
1026+
(True, True, True, "gentle"),
1027+
(False, True, False, "off"),
1028+
(False, False, False, "gentle"),
1029+
],
10181030
)
10191031
def test_fan_code_105(soft: bool, pure_mop: bool, in_list: bool, name: str) -> None:
10201032
"""Code 105 is only selectable as gentle on soft-clean devices but is always named."""

0 commit comments

Comments
 (0)