| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | import logging | |
| 6 | 6 | from datetime import timedelta | |
| 7 | - from enum import IntEnum, StrEnum | ||
| 7 | + from enum import IntEnum | ||
| 8 | 8 | from typing import Annotated, Literal | |
| 9 | 9 | ||
| 10 | 10 | from ...feature import Feature | |
@@ -58,13 +58,6 @@ class FanSpeed(IntEnum): | |||
| 58 | 58 | Ultra = 5 | |
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | - class CarpetCleanMode(StrEnum): | ||
| 62 | - """Carpet clean mode.""" | ||
| 63 | - | ||
| 64 | - Normal = "normal" | ||
| 65 | - Boost = "boost" | ||
| 66 | - | ||
| 67 | - | ||
| 68 | 61 | class AreaUnit(IntEnum): | |
| 69 | 62 | """Area unit.""" | |
| 70 | 63 | ||
@@ -184,15 +177,14 @@ def _initialize_features(self) -> None: | |||
| 184 | 177 | self._add_feature( | |
| 185 | 178 | Feature( | |
| 186 | 179 | self._device, | |
| 187 | - id="carpet_clean_mode", | ||
| 188 | - name="Carpet clean mode", | ||
| 180 | + id="carpet_boost", | ||
| 181 | + name="Carpet boost", | ||
| 189 | 182 | container=self, | |
| 190 | - attribute_getter="carpet_clean_mode", | ||
| 191 | - attribute_setter="set_carpet_clean_mode", | ||
| 183 | + attribute_getter="carpet_boost", | ||
| 184 | + attribute_setter="set_carpet_boost", | ||
| 192 | 185 | icon="mdi:rug", | |
| 193 | - choices_getter=lambda: list(CarpetCleanMode.__members__), | ||
| 194 | 186 | category=Feature.Category.Config, | |
| 195 | - type=Feature.Type.Choice, | ||
| 187 | + type=Feature.Type.Switch, | ||
| 196 | 188 | ) | |
| 197 | 189 | ) | |
| 198 | 190 | self._add_feature( | |
@@ -380,22 +372,14 @@ def status(self) -> Status: | |||
| 380 | 372 | return Status.UnknownInternal | |
| 381 | 373 | ||
| 382 | 374 | @property | |
| 383 | - def carpet_clean_mode(self) -> Annotated[str, FeatureAttribute()]: | ||
| 384 | - """Return carpet clean mode.""" | ||
| 385 | - return CarpetCleanMode(self.data["getCarpetClean"]["carpet_clean_prefer"]).name | ||
| 375 | + def carpet_boost(self) -> bool: | ||
| 376 | + """Return carpet boost mode.""" | ||
| 377 | + return self.data["getCarpetClean"]["carpet_clean_prefer"] == "boost" | ||
| 386 | 378 | ||
| 387 | - async def set_carpet_clean_mode( | ||
| 388 | - self, mode: str | ||
| 389 | - ) -> Annotated[dict, FeatureAttribute()]: | ||
| 379 | + async def set_carpet_boost(self, on: bool) -> dict: | ||
| 390 | 380 | """Set carpet clean mode.""" | |
| 391 | - name_to_value = {x.name: x.value for x in CarpetCleanMode} | ||
| 392 | - if mode not in name_to_value: | ||
| 393 | - raise ValueError( | ||
| 394 | - "Invalid carpet clean mode %s, available %s", mode, name_to_value | ||
| 395 | - ) | ||
| 396 | - return await self.call( | ||
| 397 | - "setCarpetClean", {"carpet_clean_prefer": name_to_value[mode]} | ||
| 398 | - ) | ||
| 381 | + mode = "boost" if on else "normal" | ||
| 382 | + return await self.call("setCarpetClean", {"carpet_clean_prefer": mode}) | ||
| 399 | 383 | ||
| 400 | 384 | @property | |
| 401 | 385 | def area_unit(self) -> AreaUnit: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,7 @@ | |||
| 21 | 21 | ("vacuum_status", "status", Status), | |
| 22 | 22 | ("vacuum_error", "error", ErrorCode), | |
| 23 | 23 | ("vacuum_fan_speed", "fan_speed_preset", str), | |
| 24 | - ("carpet_clean_mode", "carpet_clean_mode", str), | ||
| 24 | + ("carpet_boost", "carpet_boost", bool), | ||
| 25 | 25 | ("battery_level", "battery", int), | |
| 26 | 26 | ], | |
| 27 | 27 | ) | |
@@ -71,11 +71,11 @@ async def test_features(dev: SmartDevice, feature: str, prop_name: str, type: ty | |||
| 71 | 71 | id="vacuum_fan_speed", | |
| 72 | 72 | ), | |
| 73 | 73 | pytest.param( | |
| 74 | - "carpet_clean_mode", | ||
| 75 | - "Boost", | ||
| 74 | + "carpet_boost", | ||
| 75 | + True, | ||
| 76 | 76 | "setCarpetClean", | |
| 77 | 77 | {"carpet_clean_prefer": "boost"}, | |
| 78 | - id="carpet_clean_mode", | ||
| 78 | + id="carpet_boost", | ||
| 79 | 79 | ), | |
| 80 | 80 | pytest.param( | |
| 81 | 81 | "clean_count", | |
@@ -218,13 +218,6 @@ async def test_unknown_status( | |||
| 218 | 218 | "Invalid fan speed", | |
| 219 | 219 | id="vacuum_fan_speed", | |
| 220 | 220 | ), | |
| 221 | - pytest.param( | ||
| 222 | - "carpet_clean_mode", | ||
| 223 | - "invalid mode", | ||
| 224 | - ValueError, | ||
| 225 | - "Invalid carpet clean mode", | ||
| 226 | - id="carpet_clean_mode", | ||
| 227 | - ), | ||
| 228 | 221 | ], | |
| 229 | 222 | ) | |
| 230 | 223 | async def test_invalid_settings( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments