|
21 | 21 | resolve_cleaning_mode, |
22 | 22 | ) |
23 | 23 | from roborock.devices.traits.common import DpsDataConverter, TraitUpdateListener |
| 24 | +from roborock.exceptions import RoborockUnsupportedFeature |
24 | 25 | from roborock.roborock_message import RoborockDataProtocol |
25 | 26 | from roborock.roborock_typing import RoborockCommand |
26 | 27 |
|
@@ -51,6 +52,7 @@ class StatusTrait(StatusV2, common.V1TraitMixin, TraitUpdateListener): |
51 | 52 | - Fan Speed |
52 | 53 | - Water Mode |
53 | 54 | - Mop Route |
| 55 | + - Clean then mop (``clean_then_mop``, independent of the cleaning mode) |
54 | 56 |
|
55 | 57 | You should use the _options version of the attribute to know which are |
56 | 58 | supported for your device (i.e. fan_speed_options) |
@@ -135,10 +137,18 @@ def mop_route_name(self) -> str | None: |
135 | 137 |
|
136 | 138 | @property |
137 | 139 | def clean_then_mop(self) -> bool | None: |
138 | | - """Whether the current run vacuums each room fully before mopping it. |
| 140 | + """Whether each room is vacuumed fully before it is mopped. |
139 | 141 |
|
140 | | - Reported by the device as ``seq_type``. It describes the run in |
141 | | - progress; it is not a persisted setting and cannot be set directly. |
| 142 | + Reported by the device as ``seq_type`` and persisted on the device: it |
| 143 | + tracks the "vacuum then mop" toggle in the vendor app, also while docked. |
| 144 | +
|
| 145 | + This is a separate axis from ``current_cleaning_mode``. The cleaning |
| 146 | + mode is derived from ``fan_power``, ``water_box_mode`` and ``mop_mode`` |
| 147 | + and describes *what* the robot does in a room (vacuum, mop, both). This |
| 148 | + flag describes the *order* when it does both. Changing one leaves the |
| 149 | + other untouched; set it with ``set_clean_then_mop``. |
| 150 | +
|
| 151 | + ``None`` means the device does not support the feature. |
142 | 152 | """ |
143 | 153 | if self.seq_type is None: |
144 | 154 | return None |
@@ -183,6 +193,27 @@ async def resolve_error(self, error_code: int | None = None) -> None: |
183 | 193 | await self.rpc_channel.send_command(RoborockCommand.RESOLVE_ERROR, params={"error_code": error_code}) |
184 | 194 | await self.refresh() |
185 | 195 |
|
| 196 | + async def set_clean_then_mop(self, enabled: bool) -> None: |
| 197 | + """Set whether each room is vacuumed fully before it is mopped. |
| 198 | +
|
| 199 | + Independent of ``set_cleaning_mode``. The firmware requires the current |
| 200 | + motor-mode values in this request, so they are echoed back unchanged. |
| 201 | + """ |
| 202 | + if not self._device_features_trait.is_clean_then_mop_mode_supported: |
| 203 | + raise RoborockUnsupportedFeature("Clean then mop is not supported") |
| 204 | + seq_type = _SEQ_TYPE_CLEAN_THEN_MOP if enabled else 0 |
| 205 | + params: dict[str, int | None] = { |
| 206 | + "type": seq_type, |
| 207 | + "fan_power": self.fan_power, |
| 208 | + "water_box_mode": self.water_box_mode, |
| 209 | + } |
| 210 | + if self.mop_mode is not None: |
| 211 | + params["mop_mode"] = self.mop_mode |
| 212 | + if enabled and self._device_features_trait.is_ctm_with_repeat_supported: |
| 213 | + params["repeat"] = 1 |
| 214 | + await self.rpc_channel.send_command(RoborockCommand.APP_SET_CLEAN_SEQUENCE_TYPE, params=params) |
| 215 | + self.seq_type = seq_type |
| 216 | + |
186 | 217 | def update_from_dps(self, decoded_dps: dict[RoborockDataProtocol, Any]) -> None: |
187 | 218 | """Update the trait from data protocol push message data. |
188 | 219 |
|
|
0 commit comments