Repository navigation
Commit e6d5196
feat(v1): expose per-room clean-then-mop via customize clean mode (#984)
* feat(v1): expose per-room clean-then-mop via customize clean mode
Follow-up to #959, which models the global get_status seq_type flag but
explicitly leaves the per-room get/set_customize_clean_mode layer alone.
Adds a CustomizeCleanModeTrait exposing each room's SegmentCleanMode
(fan_power/water_box_mode/mop_mode/repeat/seq_type) and a
set_clean_then_mop(segment, enabled, ...) setter, mirroring
StatusTrait.clean_then_mop at room granularity.
* fix(v1): require mop_mode in set_clean_then_mop, document repeat reset
Tested against a real device: omitting mop_mode makes the device reject
the request outright ("Param error, no mop_mode"), it is not silently
defaulted. Omitting repeat does not preserve the room's existing value
either - the device resets it to 1. Address review feedback on #984.
* fix(v1): correct feature gate, require repeat, reject malformed entries
- Gate CustomizeCleanModeTrait on is_customized_clean_supported (the
feature that actually covers get/set_customize_clean_mode) instead of
is_clean_then_mop_mode_supported (which only gates the seq_type axis
within it) - a device can support per-room custom modes without
clean-then-mop specifically.
- repeat now defaults to 1 instead of being left out of the wire request
when unset: omitting it resets the room's repeat to 1 on the device
rather than preserving the previous value, confirmed against a real
device, so leaving it Optional was a footgun.
- CustomizeCleanModeConverter now rejects a response list containing a
non-dict entry instead of silently dropping it.
- Corrected the module docstring's claim that the global clean_then_mop
flag is per-job and clears after every clean - it's persisted, per
StatusTrait.clean_then_mop's own docstring from #959.
- Documented that StatusTrait reports sentinel "customized" codes
(fan_power=106/water_box_mode=204/mop_mode=302) while a per-room custom
mode is active, so it must not be used as a fallback source for those
values when calling set_clean_then_mop on a room with no prior override.
Addresses review feedback on #984.
* fix(v1): serialize writes and round-trip unmodeled fields losslessly
Addresses a second review round on #984 (allenporter, 2026-11-01) plus
two rounds of independent review by a second AI reviewer, both of which
reproduced real bugs rather than just raising theoretical concerns:
- Move SegmentCleanMode/CustomizeCleanModes to data/v1/v1_containers.py
(re-exported via roborock.data), matching how other trait container
models (WashTowelMode, MopDryerSetting, etc.) are organized. Decouple
the module docstring from unmerged #959 (StatusTrait.clean_then_mop
doesn't exist on main).
- CustomizeCleanModeTrait now takes a DeviceFeaturesTrait in __init__
(mirroring WashTowelModeTrait) instead of relying on the dataclass
MRO to run V1TraitMixin.__init__, which it silently didn't.
set_clean_then_mop now raises RoborockUnsupportedFeature up front if
is_clean_then_mop_mode_supported is False, instead of writing seq_type
to firmware that doesn't support it - many per-room-custom-mode
devices (S7 MaxV, S8, Qrevo) don't support clean-then-mop specifically.
- set_clean_then_mop's fan_power/water_box_mode/mop_mode now accept the
typed VacuumModes/WaterModes/CleanRoutes enums (or a raw int, for
codes this library doesn't model) instead of only raw ints.
- The read-merge-write sequence (refresh, build payload, SET, refresh)
is now serialized per trait instance via an asyncio.Lock. Reproduced
the race without it: two concurrent calls enabling different rooms
each read the same stale table, and the second call's write silently
reverted the first call's room.
- set_clean_then_mop sends the full known table on every write, not a
single-entry list: SET_CUSTOMIZE_CLEAN_MODE replaces the whole
customized-segment table on at least some firmware (first-hand Saros
20 Sonic report: https://github.com/orgs/home-assistant/discussions/3998),
so a single-entry write silently wiped other rooms' overrides.
- Untouched rooms are round-tripped from their raw wire dict (now cached
by refresh(), keyed by the canonical typed segment id - not the raw
dict's own possibly-differently-cased/typed "segment" key, which
reproducibly desynced the cache from by_segment) rather than
reconstructed from typed SegmentCleanMode fields, so fields this
library doesn't model at all (not just the two now added to the
dataclass) survive a write instead of being silently dropped. A
response with two entries resolving to the same segment id now raises
RoborockParsingException instead of one silently overwriting the
other in the cache.
- Tests: switched the fixture to real device discovery
(device + discover_features_fixture, Saros 10R for the
clean-then-mop-supported path, S7 MaxV default for the unsupported
path, S5E for is_customized_clean_supported=False) instead of
constructing the trait directly and poking private attributes. Fixed
the enabled=False case never actually being exercised (the mocked
post-write refresh was a static always-enabled fixture regardless of
what was written). Added regression tests for multi-room preservation,
unmodeled-field preservation (including on an untouched room),
concurrent-call serialization (verified to actually fail without the
lock), and the three segment-identity cases above (also verified to
fail against the prior raw-indexing approach).
Addresses review feedback on #984.
* chore: fix codespell typo in customize clean mode tests
---------
Co-authored-by: Allen Porter <allen.porter@gmail.com>1 parent 9d73026 commit e6d5196
4 files changed
Lines changed: 737 additions & 0 deletions
File tree
- roborock
- data/v1
- devices/traits/v1
- tests/devices/traits/v1
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
518 | 568 | | |
519 | 569 | | |
520 | 570 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
| |||
284 | 288 | | |
285 | 289 | | |
286 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
287 | 298 | | |
288 | 299 | | |
289 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
0 commit comments