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 can read and toggle carpet boost. 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).

  • CarpetBoostTrait is a RoborockSwitchBase. The public state is just the switch (enabled: bool | None / is_on). After a write, the state is updated optimistically, the same as in ChildLockTrait.
  • New models in v1_containers.py: CarpetBoost (public state) and CarpetBoostSettings (the full wire payload). Both are RoborockBase.
  • An empty, non-dict or incomplete reply raises RoborockParsingException, and the previously read values are kept.

Gating

New DeviceFeatures.is_carpet_boost_supported field with model_blacklist: [RUBYPLUS]. This matches the app, which shows Carpet Boost on every V1 model except RubyPlus (shouldHideCarpetPressurize()). Bit 512 (is_carpet_supported) only decides which settings page the switch appears on. Models such as the S5 Max (s5e) and S6 MaxV (a10), which clear bit 512, now get the trait.

Write payload

This follows the app, per device feature:

  • Robots reporting is_no_need_carpet_press_set_supported are sent only [{"enable": n}]. No read is needed before the first write. infy1995 confirmed this on a Saros 10R: the four tuning values stay unchanged.
  • Other robots need the motor tuning values (current_integral, current_high, current_low, stall_time) with every write. Those are kept privately from the last read and sent back unchanged, so callers can't change motor tuning by accident. If nothing has been read yet, the first write reads get_carpet_mode first. If that read fails, the error propagates and nothing is written.

The trait takes DeviceFeaturesTrait in its constructor for this, and is built in discover_features the same way as WashTowelModeTrait.

I haven't tested the full-payload replay on hardware. The Qrevo 2 Pro I captured from reports is_no_need_carpet_press_set_supported, so it takes the flag-only path. Replaying the last-read values follows infy1995's reading of the app's generic path. The earlier automated review noted that the app uses fixed default tuning for some model families (getCarpetPressDfSet). If someone with a robot that lacks the flag can confirm, that can be refined in a follow-up.

Depends on #1100

This adds a DeviceFeatures field that gates a trait. Without #1100, upgrading with an existing FileCache would make discovery raise on the missing field. Merge #1100 first.

Testing

  • tests/devices/traits/v1/test_carpet_boost.py, using the shared device / discover_features_fixture / mock_rpc_channel fixtures:
    • The trait is present on the Saros 10R, S7 MaxV, and S5 Max (bit 512 cleared).
    • Refresh, with the tuning values kept out of the public state.
    • enable() / disable() send the flag alone (Saros 10R) or replay the tuning values (S7 MaxV), with and without a prior refresh.
    • Malformed replies keep the prior values, and a failed initial read sends no write.
  • tests/test_supported_features.py: test_carpet_boost_support_from_model checks that RubyPlus is excluded. There's no RubyPlus fixture. DeviceFeatures snapshots updated; the only change is the new field.
  • Rebased onto 7.38.0 as a single commit. ruff check, ruff format --check, and pytest pass (3314 passed, 45 xfailed). mypy reports only the existing tests/map/test_b01_q10_render.py:502 error, also on main.
  • Unit tests only, against a mocked RPC channel.

🤖 Generated with Claude Code

@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.

@allenporter allenporter 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.

Marking as changes requested given the feedback below.

Add CarpetBoostTrait for get_carpet_mode/set_carpet_mode. It is gated on
a new is_carpet_boost_supported DeviceFeatures field that matches the app:
every V1 model except RubyPlus, independent of robot_new_features bit 512.

Robots with is_no_need_carpet_press_set_supported are written with the
enable flag alone, as the app does. Other robots get their motor tuning
values from the last read sent back unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hCoureau

hCoureau commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

@allenporter @infy1995 Sorry for the slow turnaround on these change requests. Both points are addressed:

  • Gate: new DeviceFeatures.is_carpet_boost_supported (model_blacklist: [RUBYPLUS]), matching the app. The S5 Max and other models that clear bit 512 now get the switch, and a unit test covers RubyPlus being excluded.
  • Write payload: robots with is_no_need_carpet_press_set_supported are sent only [{"enable": n}], as the app does (thanks for testing that on the Saros 10R). Other robots still get their last-read tuning values sent back. I haven't tested that path on hardware, and the description says so.

enabled is now bool | None, in line with the DND feedback on #1087. I rebased onto 7.38.0 and resolved the conflict.

This depends on #1100, which fixes discovery when an older pickled feature cache lacks the new field. Please merge that first.

@codecov

codecov Bot commented Dec 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.20280% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
roborock/devices/traits/v1/carpet_boost.py 94.64% 1 Missing and 2 partials ⚠️
roborock/devices/traits/v1/__init__.py 83.33% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
roborock/data/v1/v1_containers.py 95.85% <100.00%> (+0.05%) ⬆️
roborock/device_features.py 98.10% <100.00%> (+<0.01%) ⬆️
tests/devices/traits/v1/test_carpet_boost.py 100.00% <100.00%> (ø)
tests/test_supported_features.py 100.00% <100.00%> (ø)
roborock/devices/traits/v1/__init__.py 91.85% <83.33%> (-0.24%) ⬇️
roborock/devices/traits/v1/carpet_boost.py 94.64% <94.64%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

4 participants