Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/V1_DEVICE_FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1296,15 +1296,17 @@ 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.

---

### 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.
Expand Down
99 changes: 72 additions & 27 deletions roborock/data/v1/v1_clean_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -239,13 +267,14 @@ 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)
if features.is_customized_clean_supported and WaterModes.CUSTOMIZED in supported_water_modes:
# The customized-clean flag stays required until the app's custom switch
# condition is verified; without it electronic-mop models would gain CUSTOM.
if features.is_custom_mode_supported and features.is_customized_clean_supported:
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:
options.append(CleaningMode.SMART_MODE)
return options

Expand Down Expand Up @@ -347,7 +376,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)
Expand All @@ -356,17 +388,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

Expand Down
14 changes: 13 additions & 1 deletion roborock/device_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,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(
Expand Down
23 changes: 12 additions & 11 deletions roborock/devices/traits/v1/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
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,
)
from roborock.devices.traits.common import DpsDataConverter, TraitUpdateListener
Expand Down Expand Up @@ -50,11 +52,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.

"""

Expand Down Expand Up @@ -115,21 +118,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:
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/test_supported_features.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@
'is_small_side_mop_supported': False,
'is_smart_clean_mode_set_supported': False,
'is_soak_and_wash_supported': False,
'is_soft_clean_mode_supported': False,
'is_soft_clean_mode_supported': True,
'is_sr_map_supported': False,
'is_super_deep_wash_supported': False,
'is_support_api_app_stop_grasp_supported': False,
Expand Down
2 changes: 1 addition & 1 deletion tests/devices/__snapshots__/test_v1_device.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,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=[<CleaningMode.VACUUM: 'vacuum'>, <CleaningMode.VAC_AND_MOP: 'vac_and_mop'>, <CleaningMode.MOP: 'mop'>, <CleaningMode.CUSTOM: 'custom'>], clear_water_box_status=None, collision_avoid_status=None, command=<RoborockCommand.GET_STATUS: 'get_status'>, common_status=None, converter=DefaultConverter, corner_clean_mode=None, current_cleaning_mode=<CleaningMode.CUSTOM: 'custom'>, 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=<RoborockDockState.full: 'full'>, dock_type=None, dry_status=None, dss=None, dust_bag_status=None, dust_collection_status=None, error_code=<RoborockErrorCode.none: 0>, 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=[<VacuumModes.QUIET: 'quiet'>, <VacuumModes.BALANCED: 'balanced'>, <VacuumModes.TURBO: 'turbo'>, <VacuumModes.MAX: 'max'>, <VacuumModes.MAX_PLUS: 'max_plus'>, <VacuumModes.OFF: 'off'>, <VacuumModes.CUSTOMIZED: 'custom'>], has_am=None, hatch_door_status=None, home_sec_enable_password=None, home_sec_status=None, in_cleaning=<RoborockInCleaning.complete: 0>, 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=[<CleanRoutes.STANDARD: 'standard'>, <CleanRoutes.DEEP: 'deep'>, <CleanRoutes.CUSTOMIZED: 'custom'>], msg_seq=515, msg_ver=2, rdt=None, repeat=None, replenish_mode=None, rss=None, square_meter_clean_area=91.3, state=<RoborockStateCode.charging: 8>, 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=[<WaterModes.OFF: 'off'>, <WaterModes.MILD: 'mild'>, <WaterModes.STANDARD: 'standard'>, <WaterModes.INTENSE: 'intense'>, <WaterModes.CUSTOM: 'custom_water_flow'>, <WaterModes.CUSTOMIZED: 'custom'>], 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=[<CleaningMode.VACUUM: 'vacuum'>, <CleaningMode.VAC_AND_MOP: 'vac_and_mop'>, <CleaningMode.MOP: 'mop'>, <CleaningMode.CUSTOM: 'custom'>], clear_water_box_status=None, collision_avoid_status=None, command=<RoborockCommand.GET_STATUS: 'get_status'>, common_status=None, converter=DefaultConverter, corner_clean_mode=None, current_cleaning_mode=<CleaningMode.CUSTOM: 'custom'>, 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=<RoborockDockState.full: 'full'>, dock_type=None, dry_status=None, dss=None, dust_bag_status=None, dust_collection_status=None, error_code=<RoborockErrorCode.none: 0>, 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=[<VacuumModes.QUIET: 'quiet'>, <VacuumModes.BALANCED: 'balanced'>, <VacuumModes.TURBO: 'turbo'>, <VacuumModes.MAX: 'max'>, <VacuumModes.MAX_PLUS: 'max_plus'>], has_am=None, hatch_door_status=None, home_sec_enable_password=None, home_sec_status=None, in_cleaning=<RoborockInCleaning.complete: 0>, 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=[<CleanRoutes.STANDARD: 'standard'>, <CleanRoutes.DEEP: 'deep'>], msg_seq=515, msg_ver=2, rdt=None, repeat=None, replenish_mode=None, rss=None, square_meter_clean_area=91.3, state=<RoborockStateCode.charging: 8>, 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=[<WaterModes.OFF: 'off'>, <WaterModes.MILD: 'mild'>, <WaterModes.STANDARD: 'standard'>, <WaterModes.INTENSE: 'intense'>, <WaterModes.CUSTOM: 'custom_water_flow'>], water_shortage_status=None)
# ---
# name: test_device_trait_command_parsing[status].1
dict({
Expand Down
Loading
Loading