|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from enum import StrEnum |
| 4 | + |
| 5 | +from roborock import DeviceFeatures |
| 6 | + |
| 7 | + |
| 8 | +class RoborockModeEnum(StrEnum): |
| 9 | + """A custom StrEnum that also stores an integer code for each member.""" |
| 10 | + |
| 11 | + code: int |
| 12 | + |
| 13 | + def __new__(cls, value: str, code: int) -> RoborockModeEnum: |
| 14 | + """Creates a new enum member.""" |
| 15 | + member = str.__new__(cls, value) |
| 16 | + member._value_ = value |
| 17 | + member.code = code |
| 18 | + return member |
| 19 | + |
| 20 | + |
| 21 | +class CleanModes(RoborockModeEnum): |
| 22 | + GENTLE = ("gentle", 105) |
| 23 | + OFF = ("off", 105) |
| 24 | + QUIET = ("quiet", 101) |
| 25 | + BALANCED = ("balanced", 102) |
| 26 | + TURBO = ("turbo", 103) |
| 27 | + MAX = ("max", 104) |
| 28 | + MAX_PLUS = ("max_plus", 108) |
| 29 | + CUSTOM = ("custom", 204) |
| 30 | + SMART_MODE = ("smart_mode", 209) |
| 31 | + |
| 32 | + |
| 33 | +class CleanRoutes(RoborockModeEnum): |
| 34 | + STANDARD = ("standard", 300) |
| 35 | + DEEP = ("deep", 301) |
| 36 | + DEEP_PLUS = ("deep_plus", 303) |
| 37 | + FAST = ("fast", 304) |
| 38 | + DEEP_PLUS_CN = ("deep_plus", 305) |
| 39 | + |
| 40 | + |
| 41 | +class CleanModesOld(RoborockModeEnum): |
| 42 | + QUIET = ("quiet", 38) |
| 43 | + BALANCED = ("balanced", 60) |
| 44 | + TURBO = ("turbo", 75) |
| 45 | + MAX = ("max", 100) |
| 46 | + |
| 47 | + |
| 48 | +class WaterModes(RoborockModeEnum): |
| 49 | + OFF = ("off", 200) |
| 50 | + LOW = ("low", 201) |
| 51 | + MILD = ("mild", 201) |
| 52 | + MEDIUM = ("medium", 202) |
| 53 | + STANDARD = ("standard", 202) |
| 54 | + HIGH = ("high", 203) |
| 55 | + INTENSE = ("intense", 203) |
| 56 | + CUSTOM = ("custom", 207) |
| 57 | + EXTREME = ("extreme", 208) |
| 58 | + |
| 59 | + |
| 60 | +def get_clean_modes(features: DeviceFeatures) -> list[CleanModes]: |
| 61 | + modes = [CleanModes.QUIET, CleanModes.BALANCED, CleanModes.TURBO, CleanModes.MAX] |
| 62 | + if features.is_max_plus_mode_supported or features.is_none_pure_clean_mop_with_max_plus: |
| 63 | + modes.append(CleanModes.MAX_PLUS) |
| 64 | + if features.is_pure_clean_mop_supported: |
| 65 | + modes.append(CleanModes.OFF) |
| 66 | + else: |
| 67 | + modes.append(CleanModes.GENTLE) |
| 68 | + return modes |
| 69 | + |
| 70 | + |
| 71 | +def get_clean_routes(features: DeviceFeatures, region: str) -> list[CleanRoutes]: |
| 72 | + if features.is_none_pure_clean_mop_with_max_plus: |
| 73 | + return [CleanRoutes.FAST, CleanRoutes.STANDARD] |
| 74 | + supported = [CleanRoutes.STANDARD, CleanRoutes.DEEP] |
| 75 | + if features.is_careful_slow_mop_supported: |
| 76 | + if not ( |
| 77 | + features.is_corner_clean_mode_supported |
| 78 | + and features.is_clean_route_deep_slow_plus_supported |
| 79 | + and region == "CN" |
| 80 | + ): |
| 81 | + supported.append(CleanRoutes.DEEP_PLUS_CN) |
| 82 | + else: |
| 83 | + supported.append(CleanRoutes.DEEP_PLUS) |
| 84 | + |
| 85 | + if features.is_clean_route_fast_mode_supported: |
| 86 | + supported.append(CleanRoutes.FAST) |
| 87 | + return supported |
| 88 | + |
| 89 | + |
| 90 | +def get_water_modes(features: DeviceFeatures) -> list[WaterModes]: |
| 91 | + supported_modes = [WaterModes.OFF] |
| 92 | + if features.is_mop_shake_module_supported: |
| 93 | + supported_modes.extend([WaterModes.MILD, WaterModes.STANDARD, WaterModes.INTENSE]) |
| 94 | + else: |
| 95 | + supported_modes.extend([WaterModes.LOW, WaterModes.MEDIUM, WaterModes.HIGH]) |
| 96 | + if features.is_custom_water_box_distance_supported: |
| 97 | + supported_modes.append(WaterModes.CUSTOM) |
| 98 | + if features.is_mop_shake_module_supported and features.is_mop_shake_water_max_supported: |
| 99 | + supported_modes.append(WaterModes.EXTREME) |
| 100 | + return supported_modes |
0 commit comments