Skip to content

Commit af53ca3

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 934545d commit af53ca3

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
@@ -52,11 +52,12 @@ class StatusTrait(StatusV2, common.V1TraitMixin, TraitUpdateListener):
5252
- Water Mode
5353
- Mop Route
5454
55-
You should use the _options version of the attribute to know which are
56-
supported for your device (i.e. fan_speed_options)
57-
Then you can use the _mapping to convert an int value to the actual Enum.
58-
(i.e. fan_speed_mapping)
59-
You can use the _name property to get the str value of the enum. (i.e. fan_speed_name)
55+
The _options and _mapping versions of the attribute (i.e. fan_speed_options,
56+
fan_speed_mapping) hold only the user-selectable values, i.e. what you can
57+
write to the device. They do not include SmartPlan or custom codes.
58+
Use the _name property (i.e. fan_speed_name), or get_fan_speed_name,
59+
get_water_mode_name and get_mop_route_name, to name the current value,
60+
including SmartPlan and custom codes.
6061
6162
"""
6263

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

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

837837

838-
def test_current_mode_outside_options_is_none() -> None:
838+
@pytest.mark.parametrize(
839+
("features", "codes"),
840+
[
841+
({"is_custom_mode_supported": False}, (106, 204, 302)),
842+
({"is_smart_clean_mode_set_supported": False}, (110, 209, 306)),
843+
],
844+
)
845+
def test_current_mode_outside_options_is_none(features: dict[str, bool], codes: tuple[int, int, int]) -> None:
839846
"""A mode that the device does not offer is not reported as the current mode."""
840-
trait = _create_cleaning_mode_status_trait(is_custom_mode_supported=False)
841-
trait.fan_power, trait.water_box_mode, trait.mop_mode = 106, 204, 302
847+
trait = _create_cleaning_mode_status_trait(**features)
848+
trait.fan_power, trait.water_box_mode, trait.mop_mode = codes
842849

843850
assert trait.current_cleaning_mode is None
844851

@@ -976,7 +983,12 @@ def test_water_slide_raw_position_name_unchanged() -> None:
976983

977984
@pytest.mark.parametrize(
978985
("soft", "pure_mop", "in_list", "name"),
979-
[(True, False, True, "gentle"), (False, True, False, "off"), (False, False, False, "gentle")],
986+
[
987+
(True, False, True, "gentle"),
988+
(True, True, True, "gentle"),
989+
(False, True, False, "off"),
990+
(False, False, False, "gentle"),
991+
],
980992
)
981993
def test_fan_code_105(soft: bool, pure_mop: bool, in_list: bool, name: str) -> None:
982994
"""Code 105 is only selectable as gentle on soft-clean devices but is always named."""

0 commit comments

Comments
 (0)