Skip to content

feat(v1): add carpet boost switch - #1086

Open
hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/feat/carpet-boost-settings
Open

hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/feat/carpet-boost-settings

Conversation

@hCoureau

@hCoureau hCoureau commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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_mode had 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_mode needs the motor tuning values (current_integral, current_high, current_low, stall_time) along with the enable flag, so a plain on/off command isn't enough.

  • CarpetBoostTrait is a RoborockSwitchBase registered in PropertiesApi. The public state is just the switch (enabled / is_on). The tuning values from the last read are kept privately and sent back unchanged by enable() / disable(), so callers can't change motor tuning by accident. After a write, the state is updated optimistically, the same as in ChildLockTrait.
  • If nothing has been read yet, the first enable() / disable() reads get_carpet_mode and then writes. If that read fails, the error propagates and nothing is written.
  • An empty, non-dict or incomplete reply raises RoborockParsingException, and the previously read values are kept.
  • New models in v1_containers.py: CarpetBoost (public state) and CarpetBoostSettings (the full wire payload). Both are RoborockBase.

Gating

Protocol V1 only. The trait is created only when the device reports is_carpet_supported (robot_new_features bit 512). Devices without the flag get carpet_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.yaml for the S5 Max (s5e) and S6 MaxV (a10) doesn't set bit 512, so those models won't get the trait. No other DeviceFeatures field 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.yaml has 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

Testing

  • New tests/devices/traits/v1/test_carpet_boost.py uses the shared device / discover_features_fixture / mock_rpc_channel fixtures. It covers:
    • the trait is absent when bit 512 is cleared (on a Saros 10R fixture with only that bit cleared)
    • refresh, and that the tuning values are not in the public state
    • malformed replies (missing field, null field, empty list) keep the prior values
    • enable() / disable() send back the retained tuning values
    • the first write before any refresh reads and then writes
    • a failed initial read (timeout or malformed reply) sends no write
  • ruff check, ruff format --check and pytest pass (2828 passed, 46 xfailed). mypy reports one error, in tests/map/test_b01_q10_render.py:502, which is already on main and unrelated.
  • Unit tests only, against a mocked RPC channel. I haven't verified this against a real device.

🤖 Generated with Claude Code

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 <[email protected]>
@hCoureau
hCoureau force-pushed the submit/feat/carpet-boost-settings branch from 2c3d32d to 90caf4f Compare November 23, 2026 23:35

@infy1995 infy1995 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md has empty get_carpet_mode / set_carpet_mode entries and this PR doesn't touch them. Params are a one-element list holding enable (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.py and traits/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 of v1_containers.py; whoever merges second rebases. The branch is also on an older main.


command = RoborockCommand.GET_CARPET_MODE
converter = _CONVERTER
requires_feature = "is_carpet_supported"

@infy1995 infy1995 Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)])

@infy1995 infy1995 Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Lash-L left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 just DM.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_high 625, current_integral 550, current_low 500.
  • TanosSL/SLite, TanosSC and TanosSE get fixed values: current_high 280 (300 on TanosSE), current_integral 450, current_low 250.
  • UltronLite, UltronE and UltronSE get fixed values: current_high 375, current_integral 1000, current_low 1000.
  • 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_integral and current_low back. The defaults are 500/450/400 if nothing was read.
  • Whenever tuning values are sent, stall_time is always 10. 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 reports CONFLICTING. git merge-tree shows a content conflict at the end of roborock/data/v1/v1_containers.py, where main has since added CollisionAvoidStatus. The branch is based on 7.31.0 and needs a rebase. PropertiesApi on main also has new collision_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 adds CarpetModeTrait on get_carpet_clean_mode / set_carpet_clean_mode / app_set_cross_carpet_cleaning_status (carpet clean mode: Avoid / Vac & Mop / Vacuum Only / Cross). This PR adds CarpetBoostTrait on get_carpet_mode / set_carpet_mode (the suction boost switch). These are separate settings in the app, and naming this one carpet_boost keeps them apart. Merging the two gives one textual conflict, in the traits/v1/__init__.py import / __all__ blocks (carpet_boost and carpet_mode both go right after camera), and whoever merges second has to resolve it. If the P1 fix goes in, both PRs will also touch roborock/device_features.py and tests/__snapshots__/test_supported_features.ambr.
  • Docs (nit). docs/V1_API_COMMANDS.md still has an empty set_carpet_mode entry. Params are [{"enable": 0|1, "current_integral", "current_high", "current_low", "stall_time"}], or [{"enable": 0|1}] on robots with NoNeedCarpetPressSet.
  • Tests are in the mirror path and use the shared device / discover_features_fixture / mock_rpc_channel fixtures. They assert on the commands the trait sends and on its public state. Locally on 90caf4f: pytest 2828 passed, 46 xfailed. ruff check and ruff format --check are clean. mypy shows 3 errors, none in files this PR touches (missing stubs, and tests/map/test_b01_q10_render.py:502, which is already on main). CI is green.

This is an automated review and can be incorrect, so please reply if any finding looks wrong.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

/review run Code review skill (/review) has been run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants