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
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).
Follow-Up Review (dc4c634, delta from 76cfa08)
Verdict: Passes /review with nits.
The code is ready. It cannot be merged yet for two reasons that have nothing to do with the code: the PR is still a draft, and it conflicts with main. The conflict is only in four syrupy snapshot files (tests/__snapshots__/test_supported_features.ambr, tests/devices/__snapshots__/test_device_manager.ambr, test_file_cache.ambr, test_v1_device.ambr), because #1054 added more DeviceFeatures fields to the same snapshots. Rebasing onto main and running uv run pytest --snapshot-update fixes it. I checked this with a trial merge: after the snapshot update, the full suite passes (3328 passed). Please mark the PR ready for review once it is rebased.
The branch was rebased since the last review (base moved from 7.32.0 to 7.35.0), so I compared the two with git range-diff. The changes are the rename, the new is_carpet_clean_mode_supported gate, the set_mode docstring and docs, and the new first commit, fix(v1): rediscover device features missing from an old cache.
Earlier findings
set_modeleaves carpet boost and deep clean unchanged. Resolved. The docstring atroborock/devices/traits/v1/carpet_clean_mode.py:86anddocs/V1_API_COMMANDS.md:745now say so. I also accept the explanation in the reply. In the current app flow, Avoid, Vac & Mop and Cross each send a single write (the clean mode, or the cross flag) and do not touch boost or deep clean. Those two are written only when the user saves the Vacuum Only settings. So leaving them alone matches the current app.- Naming clash with the boost commands. Resolved. The attribute, module and class are now
carpet_clean_mode/CarpetCleanModeTrait. One small leftover is under nits below. - TanosSLite in the US. Resolved.
carpet_clean_mode_support()(roborock/data/v1/v1_carpet.py:37) gives carpet support with no TanosSLite in regionus, andrequires_feature = "is_carpet_clean_mode_supported"gates the trait. That matches the rule the app uses to hide the carpet settings page. The table-driven test is intests/data/v1/test_v1_carpet.py.
I re-checked the wire contract and found no changes and no problems. get_carpet_clean_mode takes [], and set_carpet_clean_mode takes {"carpet_clean_mode": n} with 0 avoid, 1 self adaption, 2 ignore (Vac & Mop) and 3 dynamic adaption. app_set_cross_carpet_cleaning_status takes {"status": 0|1}. In switch_status, 0x08 is carpet first and 0x20 is cross. The region rules also match. us: dynamic adaption on TopazSV, TopazSC, Ultron, UltronSPlus and Pearl, self adaption on all other models. de: self adaption on TanosS, TanosSPlus, TopazS, TopazSPlus, TopazSPower and TopazSV, otherwise dynamic adaption when carpet deep clean is supported. Any other region: self adaption. The region is read from get_init_status local_info.location, which is the field the app uses.
Cache rediscovery (roborock/devices/traits/v1/device_features.py:108-114)
I looked at this closely and it is correct:
- When it triggers: only when a cached
DeviceFeaturesis missing aboolfield. That happens with a pickledFileCacheentry written before a field was added. Noboolfield onDeviceFeatureshas a class-level default today, sogetattr(..., None)reliably finds the missing ones. A dict-based cache already getsNonefromfrom_dictwhen a required field is missing, so it rediscovers through the existingis Nonepath. - No loop: after rediscovery, the trait is written back to the cache with every field set, because
__init__sets all fields toFalseandrefresh()then fills them in. I simulated this with a stale pickle, a refresh and a pickle round trip. The first start sent oneget_init_status, and the second start sent none.from_feature_flagsnever leaves aboolfield asNone. - Existing caches: a cache that is up to date is used as before. A stale one costs one extra
get_init_statuson the first start after upgrading.
This fix also helps current main. A cache pickled before #1054 has none of the #1054 fields, so today merge_trait_values copies them as None and those features are silently treated as unsupported until the cache is cleared.
Priority 1: Public Trait APIs & Consumer Contracts
- Nit (optional, maintainers' call): the public option enum is still named
CarpetMode(roborock/data/v1/v1_carpet.py:52), exported fromroborock.data.v1. MeanwhileRoborockCommand.GET_CARPET_MODE/SET_CARPET_MODEare the boost commands that #1086 wraps. A name such asCarpetCleanOptionwould finish the rename from the earlier review. This does not block the merge.
Priority 2 / Priority 3
No new findings. CarpetCleanMode is still a RoborockEnum with unknown = -1.
Overlap with #1086
There is no duplication. #1086 (CarpetBoostTrait) uses get_carpet_mode / set_carpet_mode (boost plus motor tuning). This PR uses get/set_carpet_clean_mode and the cross flag. They share no commands or models. The only conflict is the neighbouring trait registration lines in roborock/devices/traits/v1/__init__.py, and whichever PR lands second rebases.
Tests & PR hygiene
- At
dc4c634:pytest2993 passed (168 snapshots), andruff checkandruff format --checkare clean. Locally,mypyreports one error, intests/map/test_b01_q10_render.py:502, a file this PR does not touch. CI is green on the head commit. - The new stale-cache test sits in the mirror suite (
tests/devices/traits/v1/test_device_features.py:118) and asserts on the RPC it sends and on the rewritten cache. That is good. - Optional: the first commit is a standalone fix for upgrades on
main(see above). It could land as its own small PR before this one, or stay here. Either works. - To merge: rebase on
main, regenerate the four snapshots, and mark the PR ready for review.
This is an automated review and can be incorrect, so please reply if any finding looks wrong.
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.