Repository navigation
Conversation
get/set_carpet_mode had no trait. The setter needs the motor tuning values (current_integral, current_high, current_low, stall_time) along with the enable flag, so a plain on/off command is not enough. Add CarpetBoostTrait (device.v1_properties.carpet_boost), gated on is_carpet_supported. Named "carpet boost" to keep it apart from the separate carpet clean mode. Only the on/off state is public; the tuning values from the last read are kept privately and sent back unchanged on enable() and disable(). A write before any refresh reads them first. Empty or incomplete replies raise a parsing error and keep the previously read values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2c3d32d to
90caf4f
Compare
infy1995
left a comment
There was a problem hiding this comment.
Thanks for this, the trait is small and reads well. The switch and optimistic update match ChildLockTrait, the tuning values stay private, and the failure paths (empty, non-dict, incomplete reply, failed first read) are all covered by tests.
Two inline comments (the gate, which answers the question in the description, and the write payload).
Also:
- Docs:
docs/V1_API_COMMANDS.mdhas emptyget_carpet_mode/set_carpet_modeentries and this PR doesn't touch them. Params are a one-element list holdingenable(0/1) plus the four tuning values; the reply is a one-element list with the same five keys. Only list a model under "Supported devices" after a real read or write. - Other open PRs touching the same files: #1089, #1062, #1045 and #1036 (
v1_containers.pyandtraits/v1/__init__.py), #1087, #1024, #959 (v1_containers.py), #1065 (traits/v1/__init__.py). I saw no symbol clashes, only adjacent-hunk conflicts in the import/__all__blocks and the end ofv1_containers.py; whoever merges second rebases. The branch is also on an oldermain.
|
|
||
| command = RoborockCommand.GET_CARPET_MODE | ||
| converter = _CONVERTER | ||
| requires_feature = "is_carpet_supported" |
There was a problem hiding this comment.
Answering the open question in the description: bit 512 looks too narrow as the only gate.
The S5 Max (s5e, tests/testdata/home_data_device_s5e.json) and S6 MaxV (a10, device_info.yaml) both have bit 512 cleared, so they would get no carpet_boost trait, although they are the models you named as having the feature. Bit 512 describes carpet detection; compared with the Roborock app plugin, the boost switch is offered on every model except RubyPlus (short models t4, s4), which is a model exclusion rather than a feature bit. On a Saros 10R (bit 512 set) the read side behaves as this PR expects.
DeviceFeatures already expresses "everything except this model" with model_blacklist (is_custom_mode_supported, is_collect_dust_mode_supported):
# roborock/device_features.py
is_carpet_boost_supported: bool = field(metadata={"model_blacklist": [RoborockProductNickname.RUBYPLUS]})# this file
requires_feature = "is_carpet_boost_supported"That keeps the switch hidden where it does not exist, which was the concern about exposing a broken switch. Test follow-ups: test_unsupported_without_carpet_feature (bit 512 cleared) would become "present", so its "absent" case should use RubyPlus (a DeviceFeatures unit test is enough, there is no RubyPlus fixture); and the DeviceFeatures snapshot in tests/__snapshots__/test_supported_features.ambr needs updating.
| async def _set_enable(self, enable: int) -> None: | ||
| current = self._settings if self._settings is not None else await self._read_settings() | ||
| settings = replace(current, enable=enable) | ||
| await self.rpc_channel.send_command(RoborockCommand.SET_CARPET_MODE, params=[asdict(settings)]) |
There was a problem hiding this comment.
Question on the write payload: this always sends all five fields (enable, current_integral, current_high, current_low, stall_time).
What I found on a Saros 10R: get_carpet_mode returns [{"enable": 1, "current_integral": 1000, "current_high": 500, "current_low": 1000, "stall_time": 10}], so the five fields this PR models are right for reading. That robot sets is_no_need_carpet_press_set_supported, and compared with the Roborock app plugin, the app sends only {"enable": n} for robots with that flag (generic models replay the read values). I tried exactly that: set_carpet_mode [{"enable": 0}] was accepted, get_carpet_mode then read enable 0 with the four tuning values unchanged, and the value stayed after changing the carpet mode and back. I did not try the five-field form, so I cannot say whether it is accepted there.
So sending only enable when is_no_need_carpet_press_set_supported is set (and replaying the full read otherwise) is known to work on that robot and avoids writing back stale thresholds. Alternatively, keep the replay and note in the PR which robot a full-payload write was tried on.
The single read before the first write is fine under AGENTS.md (lazy init when the cache is None).
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Claude Opus 5.5 in Claude Code using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary
Reviewed 90caf4f. The trait is small and follows ChildLockTrait. The RPC names, the [ {...} ] param shape and the five read fields all match the Roborock app. Two things need changing before merge. First, the feature gate is narrower than the app's, and the app answers the open question in the description. Second, the branch conflicts with main. The write payload also differs from the app for two groups of models (see Priority 2).
Verdict: Does not pass /review.
Checked against the Roborock app (RR_API)
| Claim | Result | Where |
|---|---|---|
RPC names get_carpet_mode / set_carpet_mode |
Confirmed | hermes/com.roborock.tanos/output/module_1616.js:68 |
set_carpet_mode params are a one-element list holding the dict |
Confirmed (r1 = new Array(1); r1[0] = a0) |
hermes/com.roborock.tanos/output/module_441.js:2502-2509 |
Read reply is [{enable, current_integral, current_high, current_low, stall_time}] and the app reads result[0] |
Confirmed | nonhermes/com.roborock.tanos/output/2406.js:284 |
| The app calls this setting "Carpet Boost" | Confirmed (setting_carpet_mode_title) |
nonhermes/com.roborock.tanos/output/2559.js:1348, 2459.js:1461 |
Gate on is_carpet_supported (bit 512) |
Contradicted (see P1) | nonhermes/com.roborock.tanos/output/402.js:319-322, 620-623; 2459.js:1469; 2559.js:1353 |
| Write sends back all five read values | Partly contradicted (see P2) | getCarpetPressDfSet in nonhermes/com.roborock.tanos/index.android.bundle, and hermes/com.roborock.tanos/output/module_2201.js:10705-10840 |
Priority 1: Public trait API and gating
roborock/devices/traits/v1/carpet_boost.py:40: requires_feature = "is_carpet_supported" hides the switch on models that have it.
The app shows Carpet Boost on every V1 model except RubyPlus. Bit 512 only decides which page it appears on:
- On the robot settings page, the switch is shown when
!shouldHideCarpetPressurize() && !isCarpetSupported(), so it is shown on robots without bit 512 (2459.js:1469). - On the carpet settings page, it is shown when
!shouldHideCarpetPressurize()(2559.js:1353). shouldHideCarpetPressurize()is justDM.is(PD.RubyPlus)(402.js:620-623).
With this gate, the S5 Max (s5e) and S6 MaxV (a10) from the description get carpet_boost = None, although the app offers the switch on both. The fix is to use a model blacklist, as is_custom_mode_supported and is_collect_dust_mode_supported already do:
# roborock/device_features.py
is_carpet_boost_supported: bool = field(metadata={"model_blacklist": [RoborockProductNickname.RUBYPLUS]})
# roborock/devices/traits/v1/carpet_boost.py
requires_feature = "is_carpet_boost_supported"This also changes some tests. test_unsupported_without_carpet_feature (bit 512 cleared) should now expect the trait to be present. The "absent" case should use RubyPlus (t4 / s4). A DeviceFeatures.from_feature_flags unit test is enough for that, since there is no RubyPlus fixture. tests/__snapshots__/test_supported_features.ambr also needs updating. The same point was raised in the earlier inline review, and the app code above confirms it.
Priority 2: Write payload
carpet_boost.py:77-84 (_set_enable): the app does not always send back the read values.
getCarpetPressDfSet(enable, readValues) builds the payload like this:
- RubySC, RubySE and RubySLite (
isCarpetPressurizeSwitchUseNewPara) get fixed values:current_high625,current_integral550,current_low500. - TanosSL/SLite, TanosSC and TanosSE get fixed values:
current_high280 (300 on TanosSE),current_integral450,current_low250. - UltronLite, UltronE and UltronSE get fixed values:
current_high375,current_integral1000,current_low1000. - Robots with
NoNeedCarpetPressSet(new_feature_str bit 57,is_no_need_carpet_press_set_supported) get only{"enable": n}. - All other robots get the read
current_high,current_integralandcurrent_lowback. The defaults are 500/450/400 if nothing was read. - Whenever tuning values are sent,
stall_timeis always10. The read value is not used.
For the generic group, the PR does what the app does. For the other groups it sends payloads the app never sends. The likeliest problem is on robots with is_no_need_carpet_press_set_supported (Saros 10R and other new models). There, the earlier review found that [{"enable": 0}] works, and the five-field form has not been tried. The smallest change that matches the app is to build the payload declaratively:
async def _set_enable(self, enable: int) -> None:
if self._device_features.is_no_need_carpet_press_set_supported:
params = {"enable": enable}
else:
current = self._settings if self._settings is not None else await self._read_settings()
params = {**asdict(current), "enable": enable, "stall_time": 10}
await self.rpc_channel.send_command(RoborockCommand.SET_CARPET_MODE, params=[params])
...This needs the trait to receive DeviceFeaturesTrait, like WashTowelModeTrait / CustomizeCleanModeTrait, so it would be registered in the special-argument block of discover_features. The fixed per-model values could be added the same way. If you prefer to keep plain replay, please say in the PR which robot a five-field write was tested on.
Priority 3: Wire / parsing
No findings. The converter raises ValueError on an empty, non-dict or incomplete reply, _read_settings wraps that in RoborockParsingException with context, and the cached settings are left unchanged.
Tests & PR hygiene
- Merge conflict with
main(blocking). GitHub reportsCONFLICTING.git merge-treeshows a content conflict at the end ofroborock/data/v1/v1_containers.py, wheremainhas since addedCollisionAvoidStatus. The branch is based on7.31.0and needs a rebase.PropertiesApionmainalso has newcollision_avoidance*fields next to the one this PR adds. - Overlap with #1092 (
feat(v1): add carpet mode). There are no duplicate traits or commands. #1092 addsCarpetModeTraitonget_carpet_clean_mode/set_carpet_clean_mode/app_set_cross_carpet_cleaning_status(carpet clean mode: Avoid / Vac & Mop / Vacuum Only / Cross). This PR addsCarpetBoostTraitonget_carpet_mode/set_carpet_mode(the suction boost switch). These are separate settings in the app, and naming this onecarpet_boostkeeps them apart. Merging the two gives one textual conflict, in thetraits/v1/__init__.pyimport /__all__blocks (carpet_boostandcarpet_modeboth go right aftercamera), and whoever merges second has to resolve it. If the P1 fix goes in, both PRs will also touchroborock/device_features.pyandtests/__snapshots__/test_supported_features.ambr. - Docs (nit).
docs/V1_API_COMMANDS.mdstill has an emptyset_carpet_modeentry. Params are[{"enable": 0|1, "current_integral", "current_high", "current_low", "stall_time"}], or[{"enable": 0|1}]on robots withNoNeedCarpetPressSet. - Tests are in the mirror path and use the shared
device/discover_features_fixture/mock_rpc_channelfixtures. They assert on the commands the trait sends and on its public state. Locally on90caf4f:pytest2828 passed, 46 xfailed.ruff checkandruff format --checkare clean.mypyshows 3 errors, none in files this PR touches (missing stubs, andtests/map/test_b01_q10_render.py:502, which is already onmain). CI is green.
This is an automated review and can be incorrect, so please reply if any finding looks wrong.
Summary
Adds
CarpetBoostTrait(device.v1_properties.carpet_boost) so V1 vacuums that support carpet boost can read and toggle it.get_carpet_mode/set_carpet_modehad no trait before. It is named "carpet boost" (the Roborock app's name for it) to keep it apart from the separate carpet clean mode (get_carpet_clean_mode).set_carpet_modeneeds the motor tuning values (current_integral,current_high,current_low,stall_time) along with theenableflag, so a plain on/off command isn't enough.CarpetBoostTraitis aRoborockSwitchBaseregistered inPropertiesApi. The public state is just the switch (enabled/is_on). The tuning values from the last read are kept privately and sent back unchanged byenable()/disable(), so callers can't change motor tuning by accident. After a write, the state is updated optimistically, the same as inChildLockTrait.enable()/disable()readsget_carpet_modeand then writes. If that read fails, the error propagates and nothing is written.RoborockParsingException, and the previously read values are kept.v1_containers.py:CarpetBoost(public state) andCarpetBoostSettings(the full wire payload). Both areRoborockBase.Gating
Protocol V1 only. The trait is created only when the device reports
is_carpet_supported(robot_new_featuresbit 512). Devices without the flag getcarpet_boost = None.Open question: the gate may be too narrow for older models. Valetudo registers carpet mode by model for the S5, S5 Max, S6, S6 Pure, S6 MaxV, M1S and all Gen4 models (everything except the S4). But the feature info recorded in
device_info.yamlfor the S5 Max (s5e) and S6 MaxV (a10) doesn't set bit 512, so those models won't get the trait. No otherDeviceFeaturesfield signals carpet boost, and an ungated trait would surface a broken switch on models without it. This PR therefore keeps the feature gate, which can only hide the switch, never expose it where unsupported. A model-based fallback can follow if those models are confirmed. (device_info.yamlhas no feature data for the S7 MaxV (a27), and the S7 MaxV test fixture's feature string is partial, so neither says anything either way about that model.)Overlap with other open PRs
roborock/devices/traits/b01/q7/,RoborockB01Props.CARPET_TURBO/CARPET_AVOID). It shares no files, names, or registrations with this V1 trait.v1_containers.pyand the import/__all__lists intraits/v1/__init__.py. Expect adjacent-hunk merge conflicts, but no symbol clashes.Testing
tests/devices/traits/v1/test_carpet_boost.pyuses the shareddevice/discover_features_fixture/mock_rpc_channelfixtures. It covers:enable()/disable()send back the retained tuning valuesruff check,ruff format --checkandpytestpass (2828 passed, 46 xfailed).mypyreports one error, intests/map/test_b01_q10_render.py:502, which is already onmainand unrelated.🤖 Generated with Claude Code