Repository navigation
Conversation
|
Hi @infy1995! Will review this shortly, but consider joining our Roborock contributor discord to stay in touch and have easier access to us! https://discord.gg/8ytF2t5F |
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
Verdict: Passes /review with nits.
Reviewed 76cfa08 (3 commits on main). This is a clean, well-scoped trait. The wire claims match the Roborock app plugin (com.roborock.tanos), tests are table-driven and use the shared fixtures plus V1VacuumSimulator, and the local run is green. None of the points below block the merge.
Checked against the app plugin (RR_API/nonhermes/com.roborock.tanos/output/, and the hermes bundle module_443.js gives the same gate logic):
set_carpet_clean_modeis sent as an object{"carpet_clean_mode": t}, andget_carpet_clean_modetakes[]: confirmed,448.js:1246-1258.app_set_cross_carpet_cleaning_status{"status": t}: confirmed,448.js:296-303.- Codes 0 avoid / 1 self adaption / 2 ignore ("Vac & Mop") / 3 dynamic adaption: confirmed,
461.js:231-236. switch_statusbit 0x08 is carpet first and 0x20 is cross: confirmed,381.js:577-578.is_self_adaption_carpet_supported/is_dynamic_adaption_carpet_supported, which useus=FCC andde=CE, the FCC dynamic list, the CE self list and the deep clean gate: confirmed,402.js:137-171,695-710. Under these rules the two values can never both be true, so the PR choosing "dynamic if supported, else self" for Vacuum Only gives the same result as the app's "self if supported, else dynamic" (2406.js:321-330).- The Cross option is gated on
CarpetCustomClean(bit 49): confirmed,2559.js:1304,1836-1838. After writing 1 or 3, the app turns cross off only when that bit is set: confirmed,2559.js:684-693. - Gating the trait on
is_carpet_supported(robot_new_features & 512): confirmed,402.js:319-322.
Overlap and stacking: #1092 is not stacked on #1054, #1055 or #1064, since none of those heads is an ancestor of it. It does not duplicate #1086: #1086's CarpetBoostTrait uses get_carpet_mode/set_carpet_mode (the boost and motor tuning setting), while this PR uses get/set_carpet_clean_mode and the cross flag, with no shared commands or models. The only conflict is the textual one in roborock/devices/traits/v1/__init__.py, between the neighbouring trait registration lines. The PR merges cleanly into current main.
Priority 1: Public Trait APIs & Consumer Contracts
-
set_modeleaves carpet boost and carpet deep clean on, which the app does not do.roborock/devices/traits/v1/carpet_mode.py:83-107
In the app, choosing Avoid or Vac & Mop (any mode other than 1 or 3) callsresetCarpetOtherSets()(2559.js:684), and turning Cross on callsresetCarpetOtherSets(true)(2559.js:913). Both turn off carpet deep clean and carpet pressurize, which is the #1086 boost sent throughset_carpet_mode(2559.js:1588-1620,492-519). With this PR, a Home Assistant user who picks Avoid keeps boost or deep clean on, a combination the app never leaves. From the bundle I cannot tell whether the firmware ignores those settings in that state or acts on them.
Fix (either works): add a short line to theset_modedocstring saying that boost and deep clean are left as they are, so consumers know to refreshcarpet_boostafter the call (and the docs table records it). Or, once #1086 lands, mirror the app's reset in a follow-up. If you have the Saros 10R at hand, it is worth checking whetherget_carpet_modeenablechanges on its own afterset_carpet_clean_mode 0. -
Question on naming:
PropertiesApi.carpet_mode(roborock/devices/traits/v1/__init__.py:193) wrapscarpet_clean_mode, butRoborockCommand.GET_CARPET_MODE/SET_CARPET_MODEare the boost commands that #1086 wraps ascarpet_boost. Once both land,carpet_modeandget_carpet_modewill refer to different settings. Wouldcarpet_clean_modebe a clearer attribute name? This is the maintainers' call. The current name does match the app's user-facing label.
Priority 2: Data Lifecycle & State Management
- Small gate gap (TanosSLite in the US).
roborock/devices/traits/v1/carpet_mode.py:29
The app hides the carpet settings view for TanosSLite in the FCC region (402.js:173-178,shouldShowCarpetSettingView). This trait is gated only onis_carpet_supported, so a US TanosSLite would still expose it. This is low impact. If you want to match the app, add a check inPropertiesApior fold it into the derived feature computed next to the two adaption fields.
No lifecycle concerns. refresh() returns early on a get_prop failure and keeps the last known flags, as the PR body says. set_mode writes and then refreshes, matching sibling traits. The two new required DeviceFeatures fields make an older dict cache come back as None from from_dict, which triggers rediscovery (I checked this locally). The PR body already covers the pickled-cache case.
Priority 3: Wire Protocols, Codecs & Resilient Enums
No findings. CarpetCleanMode is a RoborockEnum with unknown = -1, so an unexpected code gives mode = None and does not raise.
Tests & PR hygiene
- Tests sit in the mirror paths (
tests/devices/traits/v1/test_carpet_mode.py,tests/data/v1/test_v1_carpet.py). They use@pytest.mark.parametrize, the sharedmock_rpc_channeland device fixtures, and a simulator round trip, and they assert on public properties and the emitted commands. - Local run at
76cfa08:pytest2861 passed (168 snapshots), andruff checkis clean.mypyreported 3 errors, all from the local environment (missingyaml/protobufstubs and an existing error in a test file this PR does not change), none in the changed files. CI lint and tests are green. - The commit messages follow Conventional Commits, and the PR body lists conflicts with the other open PRs accurately.
This is an automated review and can be incorrect, so please reply if any finding looks wrong.
76cfa08 to
1c68fea
Compare
|
Thanks for the review. All three points are addressed in the updated branch:
Also added a small |
1c68fea to
dc4c634
Compare
Part of #738.
What changes
Adds a V1
carpet_clean_modetrait for the global carpet setting that the Roborock app offers: Avoid, Vac & Mop, Vacuum Only and Cross.CarpetCleanModeTraitreadsget_carpet_clean_modeplus the carpet first and cross flags fromget_prop ["get_status"], and exposesmode,optionsandset_mode(). Options are gated by the device features, so a robot only offers what it supports.vacuum_only_settings_availabletells callers whether the robot currently accepts the Vacuum Only extras.is_carpet_clean_mode_supportedgates the trait: it is off for a TanosSLite in the US region (covered by tests only, no such device here).DeviceFeaturesfields (is_self_adaption_carpet_supported,is_dynamic_adaption_carpet_supported) decide whether Vacuum Only is offered and which value it writes. They depend on the robot's region and product, sofrom_feature_flagstakes an optionallocation. These derived fields are left out of theSUPPORTED_FEATURES.mdtable, since the CLI has no region to compute them.set_modewrites only the mode and the cross flag (carpet boost and deep clean are left as they are), then refreshes. Avoid and Vac & Mop send only the mode. Vacuum Only sends mode 3 (or 1 without dynamic adaption) and then turns cross off. Cross sends only the cross flag. A mode the robot does not offer raisesRoborockUnsupportedFeatureand sends nothing.V1VacuumSimulatorgets the four handlers and clears cross on Avoid and Vac & Mop like the robot does.docs/V1_API_COMMANDS.mdanddocs/V1_DEVICE_FEATURES.md.The first commit is a separate fix: cached device features written by an older version are read from the robot again. Without it, a pickled cache would make feature discovery raise for the new gate field.
Why
Carpet mode is the first global carpet setting for Home Assistant. A single select needs one trait that knows which options to show and how to write them without leaving the cross flag in a stale state.
App cross-check
The options, the gate rules and the command sequences were compared with the Roborock app plugin.
Tested on a device
Roborock Saros 10R, with the robot docked and its state restored afterwards:
get_carpet_clean_mode,set_carpet_clean_mode,app_set_cross_carpet_cleaning_statusandget_prop ["get_status"].set_moderead back correctly for all four modes.Behavior notes
get_propread fails, the clean mode is still updated and the known carpet first and cross flags are kept.carpet_clean_modegivesmode = Noneand no exception.Conflicts with open PRs
Checked with
git merge-treeagainst each open PR touching the same files. All are textual conflicts; whoever merges second rebases.roborock/devices/traits/v1/__init__.py(neighbouring trait registration lines).tests/test_supported_features.py, file cache snapshot.tests/test_supported_features.py.Checks
uv run pytest(2993 passed) anduv run pre-commit run --all-files(ruff, mypy, codespell) pass.