Repository navigation
feat: add V1 dock dust collection mode, auto-empty frequency and start/stop - #1036
Conversation
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Hydrogen in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary by Architectural Layer
- Priority 1 — Public Trait APIs & Consumer Contracts:
DustCollectionModeTraitandDustCollectionFrequencyTraitcleanly subclassRoborockBasecontainers (DustCollectionMode,DustCollectionFrequency), use concrete enum types with noAnyon public boundaries, and validate selectable options before sending commands (raisingRoborockUnsupportedFeature).DustCollectionModeTraitgating (is_collectable+is_collect_dust_mode_supported+is_dust_collection_setting_supported) matches the app's gating forget/set_dust_collection_mode, anddust_collection_mode_options(0smart,1light,2balanced,4max; omitting3strong) matches the app.- Two gating findings (see inline comments):
DustCollectionFrequencyTraitshould gate onis_auto_collection_2_supportedrather thanis_collect_dust_mode_supported, and placingstart_dust_collection/stop_dust_collectiononDustCollectionModeTraithides manual dust collection from Pearl / non-DCS collecting docks.
- Priority 2 — Data Lifecycle & State Management:
PropertiesApi.discover_featureswires both traits cleanly without side-effecting helpers, and optimistic updates (self.mode = mode,self.status = frequency) only occur aftersend_commandsucceeds.
- Priority 3 — Wire Protocols & Enums:
- Command names (
get/set_dust_collection_mode,get/set_dust_collection_switch_status,app_start_collect_dust,app_stop_collect_dust), payload shapes ({"mode": n},{"status": n}, no params for start/stop), and enum codes (RoborockDockDustCollectionModeCodeincludingstrong = 3,RoborockDockDustCollectionFrequencyCodewithunknown = -1) all match the Roborock app.
- Command names (
- Tests & Verification:
- Colocated tests in
tests/devices/traits/v1/test_dust_collection_mode.pyandtest_dust_collection_frequency.pyfollow repository conventions. All 576 V1 trait tests, conformance tests (536 passed, 53 xfailed),ruff check, andmypyon the changed files pass.
- Colocated tests in
| The app shows the dock's dust collection page only for a collecting dock on a | ||
| product that supports it (``isCollectDustModeSupported``, not Pearl). | ||
| """ | ||
| return dock_features.is_collectable and device_features.is_collect_dust_mode_supported |
There was a problem hiding this comment.
Capability gating mismatch with the app (is_auto_collection_2_supported vs is_collect_dust_mode_supported)
In the Roborock app, the 3-way Auto-Empty Frequency selector (0 off, 1 balanced, 2 high) is gated on dock_features.is_collectable and NewFeatureStrBit.AUTO_COLLECTION_2 (device_features.is_auto_collection_2_supported, bit 53)—it does not check is_collect_dust_mode_supported (which only gates the Empty Mode entry).
On collecting docks without is_auto_collection_2_supported (e.g., S7 MaxV Ultra, Q5 Max+), the app only shows a binary on/off Auto Emptying switch (0/1) and never offers 2 (high).
Suggested fix:
def supports_dust_collection_frequency(device_features: DeviceFeatures, dock_features: RoborockDockFeatures) -> bool:
"""Return whether the app shows the auto-empty frequency for this device."""
return dock_features.is_collectable and bool(device_features.is_auto_collection_2_supported)(Or, if you want the trait present on all collecting docks to read/toggle 0/1, gate frequency_options to [off, balanced] when not device_features.is_auto_collection_2_supported.) Please also update docs/V1_DEVICE_FEATURES.md if you change this.
There was a problem hiding this comment.
Thanks, addressed in 4f7f77c. The auto-empty setting is now available on every collecting dock (is_collectable) and no longer gated by is_collect_dust_mode_supported. frequency_options offers off/balanced/high with is_auto_collection_2_supported (bit 53), and only off/balanced (on/off) without it; set_frequency rejects high there. Since the trait now covers more than the frequency, it is renamed to DustCollectionTrait / PropertiesApi.dust_collection, matching the B01 Q10 trait. docs/V1_DEVICE_FEATURES.md is updated. The on/off case without bit 53 is not tested on a real device.
| # Optimistic update to avoid an extra refresh | ||
| self.mode = mode | ||
|
|
||
| async def start_dust_collection(self) -> None: |
There was a problem hiding this comment.
start_dust_collection / stop_dust_collection are unavailable on Pearl and non-DCS collecting docks
Narrowing DustCollectionModeTrait to is_collectable and is_collect_dust_mode_supported and is_dust_collection_setting_supported matches the app's gating for get_dust_collection_mode / set_dust_collection_mode.
However, app_start_collect_dust and app_stop_collect_dust are supported on collecting docks regardless of is_collect_dust_mode_supported (Pearl, e.g. Q Revo) or is_dust_collection_setting_supported (older collecting docks without bit 25). Because these methods live on DustCollectionModeTrait, consumers have no way to trigger manual dust collection when dust_collection_mode is None.
Suggested fix:
Consider exposing start_dust_collection / stop_dust_collection on a trait gated solely by dock_features.is_collectable (or a dedicated dock-action trait) so manual dust collection remains available on all collecting docks.
There was a problem hiding this comment.
Thanks, addressed in 4f7f77c: start_dust_collection / stop_dust_collection moved from DustCollectionModeTrait to DustCollectionTrait, which every collecting dock has, so Pearl and docks without is_dust_collection_setting_supported keep manual dust collection. Covered by tests on the Saros 10R and Q Revo fixtures.
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Neon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Follow-Up Review on 4f7f77c (delta from 360e096)
All prior review findings from 360e096 have been cleanly resolved with no new issues found:
- Auto-empty gating & options (
DustCollectionTrait/PropertiesApi.dust_collection): Gated ondock_features.is_collectablerather thanis_collect_dust_mode_supported, withfrequency_options(get_dust_collection_frequencies) exposing[off, balanced, high]whenis_auto_collection_2_supported(new feature string bit 53) is set and[off, balanced]otherwise, rejectinghighwithout bit 53 viaRoborockUnsupportedFeature. Verified against the Roborock V1 app (NewFeatureStrBit.AutoCollection2bit 53 toggles between the 3-way frequency selector and binary on/off auto-emptying switch onget/set_dust_collection_switch_status). - Manual dust collection (
start_dust_collection/stop_dust_collection): Moved toDustCollectionTrait, so all collecting docks—including Pearl models (e.g. Q Revo) and docks withoutis_dust_collection_setting_supported—retainapp_start_collect_dust/app_stop_collect_dust. - Lifecycle, Docs & Tests:
PropertiesApi.discover_featureswiresDustCollectionTraitcleanly following theWashTowelModeTraitpattern,docs/V1_API_COMMANDS.mdanddocs/V1_DEVICE_FEATURES.mdaccurately reflect the updated gating, colocated tests intests/devices/traits/v1/test_dust_collection.pycover the bit-53 option gating, rejection ofhighwithout bit 53, and Pearl manual dust collection, and all CI checks pass on4f7f77c.
Verdict: Clean — passes /review and looks ready to merge.
|
This PR passed |
Add dust_collection_mode_options (smart, light, balanced, max) and a set_dust_collection_mode setter that rejects any other mode before sending. RoborockDockDustCollectionModeCode gains strong (3), so reading it no longer falls back to unknown. The trait now requires a collecting dock, is_collect_dust_mode_supported and is_dust_collection_setting_supported, because only those robots have a mode to read or set. On other devices dust_collection_mode is now None.
Add DustCollectionTrait (PropertiesApi.dust_collection) for every collecting dock: the auto-empty setting (get/set_dust_collection_switch_status) and manual collection with start_dust_collection / stop_dust_collection. frequency_options is off, balanced and high with is_auto_collection_2_supported. Other collecting docks only switch auto-empty off or on, so they get off and balanced, and set_frequency rejects high.
4f7f77c to
4f3dccf
Compare
|
Rebased onto current |
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 (4f3dccf, delta from 4f7f77c)
Verdict: Passes /review with nits.
Nothing blocking. The nits below are optional and do not need another review round.
Earlier findings
Both findings from the 360e096 review were fixed by 4f7f77c and are still fixed after the rebase:
- Auto-empty gating:
DustCollectionTraitis still gated onis_collectableonly, andget_dust_collection_frequenciesstill offershighonly withis_auto_collection_2_supported(new feature string bit 53). - Manual dust collection:
start_dust_collection/stop_dust_collectionare still onDustCollectionTrait, so Pearl products and docks withoutis_dust_collection_setting_supportedkeep them. - The
DustCollectionModeTraitgating (is_collectableandis_collect_dust_mode_supportedandis_dust_collection_setting_supported) and the options[0, 1, 2, 4]are unchanged. They still match the app.
What changed in this delta
The branch was rebased onto main (cfa413e, 7.33.0) and squashed into two commits (be27295, 4f3dccf). I compared each PR file at 4f7f77c with the same file at 4f3dccf and took out the changes that came from main. What's left:
- Trait and gating code: unchanged. The only edits are shorter docstrings in
roborock/devices/traits/v1/dust_collection.py, plus a new note that the commands were verified on the Saros 10R. - Discovery:
roborock/devices/traits/v1/__init__.pynow addsDustCollectionModeTraitto the skip tuple next toCollisionAvoidanceTrait(which came from #1089 onmain). The conflict was resolved correctly: both traits are still created explicitly and skipped in the generic loop. - Simulator (new):
roborock/testing/v1_simulator.pyhandlesget/set_dust_collection_mode,get/set_dust_collection_switch_status(backed bystatus.auto_dust_collection), andapp_start/stop_collect_dust(they set the state toemptying_the_bin/charging).tests/testing/test_v1_simulator.pyadds round-trip tests for both traits through the realV1Channel. - Docs:
docs/V1_API_COMMANDS.mdadds Saros 10R entries forapp_start_collect_dust/app_stop_collect_dust, plus aget_dust_collection_modereturn example.
Priority 1: Public trait APIs
No findings. The public surface is the same as at 4f7f77c (dust_collection_mode_options, set_dust_collection_mode, dust_collection.frequency_options, set_frequency, start_dust_collection, stop_dust_collection). It uses concrete RoborockEnum types and has no Any.
Priority 2: Lifecycle and state
No findings. Optimistic updates still happen only after send_command succeeds.
Nit (optional): roborock/testing/v1_simulator.py:364-366. _handle_app_stop_collect_dust always sets the state to charging, even if the simulated robot was not emptying the bin. This is fine for the current test. A guard would stop later simulator tests from flipping a cleaning robot to charging:
def _handle_app_stop_collect_dust(self, params: Any) -> str:
if self.status.state == RoborockStateCode.emptying_the_bin:
self.status.state = RoborockStateCode.charging
return "ok"Priority 3: Wire protocol and enums
No findings. The command names, the {"mode": n} / {"status": n} payloads and the enum codes did not change in this delta. The live test below confirms the read-back on a second model.
Tests and docs
- Nit (optional):
tests/testing/test_v1_simulator.py:425uses the magic number33554432foris_dust_collection_setting_supported. A named constant, or a comment naming the feature (asroborock/device_features.py:305does), would make the test easier to read. - Nit (optional):
roborock/devices/traits/v1/dust_collection.py:35anddocs/V1_API_COMMANDS.md:1397,:1417,:1439list only the Saros 10R. You could add the Qrevo MaxV 2 (a87) as a supported device forset_dust_collection_modeandget/set_dust_collection_switch_status, based on the live test below. - The tests are in the matching mirror paths and use
fake_channel/ the simulator. They check public behaviour.
Stacking and merge state
git merge-treeagainst currentorigin/main(2a051f2) merges cleanly.- #1045 is built on top of this PR and contains the same two commits (
be27295,4f3dccf), so it is in sync with this head.
Live test on a Qrevo MaxV 2
The library at 4f3dccf was run against a real Qrevo MaxV 2 (a87, firmware 02.34.04, US):
- Dust collection mode: set 4 (max), then 2 (balanced), then restored 4. The device read back each value. Setting
strong(3, which the app does not offer) was refused withRoborockUnsupportedFeaturebefore anything was sent. - Auto-empty: set 1 (balanced/on), then 0 (off), then restored 1. All ok.
highwas refused because this device lacks feature bit 53, which matches the 2-option on/off switch the app shows for it. - Not tested live:
start_dust_collection/stop_dust_collection, because they run the dock. They are covered by unit and simulator tests, and the Saros 10R entries in the docs.
Local results
pytest tests: 2922 passed, 46 xfailed (11 deselected).ruff check .: all checks passed.ruff format --check .: 286 files already formatted.mypyon the changed trait, simulator and test files: no issues.- CI (
gh pr checks 1036): Build Package, Lint Commit Messages, Test Semantic Release, lint, test (3.11), test (3.14), test-mqtt (3.11) and test-mqtt (3.14) all pass.releasewas skipped.
This is an automated review and can be incorrect, so please reply if any finding looks wrong.
Lash-L
left a comment
There was a problem hiding this comment.
Tested on my vac and working 100%. Double checked some logic and everything looks good to me, thank you!
Part of the "Dock controls" item in #738: V1 dock dust collection settings and actions, so consumers can change the emptying mode and the auto-empty setting, and start or stop emptying the bin.
Changes
DustCollectionModeTraitdust_collection_mode_options: smart, light, balanced, max.set_dust_collection_mode(mode)sendsset_dust_collection_modewith{"mode": <code>}. A mode outside the options raisesRoborockUnsupportedFeatureand sends nothing.RoborockDockDustCollectionModeCodegainsstrong = 3, so reading that code no longer falls back tounknown. It is not a selectable mode, so the setter rejects it.DustCollectionTrait(PropertiesApi.dust_collection, same name as the B01 Q10 trait): auto-empty setting and manual dust collection, on every collecting dockget_dust_collection_switch_status;set_frequency(frequency)sendsset_dust_collection_switch_statuswith{"status": <code>}.frequency_options(fromget_dust_collection_frequencies(features)): off, balanced, high on devices withis_auto_collection_2_supported(new feature string bit 53); only off and balanced (code 1, meaning on) on other collecting docks, which only have an auto-empty on/off switch.start_dust_collection()/stop_dust_collection()sendapp_start_collect_dust/app_stop_collect_dust. They live here, not on the mode trait, so collecting docks without an emptying mode (e.g. Pearl products) can still empty the bin manually.RoborockDockDustCollectionFrequencyCode: off 0, balanced 1, high 2 (unknown = -1for unexpected firmware codes).docs/V1_API_COMMANDS.md: entries for both setters andget/set_dust_collection_switch_status.docs/V1_DEVICE_FEATURES.md: what the device features gate.V1VacuumSimulatorhandles the new dust collection commands.Gating
dust_collection_modeis_collectableandis_collect_dust_mode_supportedandis_dust_collection_setting_supporteddust_collectionis_collectablehighis offered.The mode trait is created explicitly in
discover_features, because_is_supportedcannot combine dock and device feature checks.DustCollectionTraitfollows theWashTowelModeTraitpattern (dock gating plus the device features trait for its options).Behaviour change:
dust_collection_mode(read-only on main so far) is nowNoneon Pearl products such as the Q Revo, and on devices withoutis_dust_collection_setting_supported, because those robots have no emptying mode to read or set.Wire formats
get/set_dust_collection_mode,{"mode": n}get/set_dust_collection_switch_status,{"status": n}auto_dust_collectioninget_status)The option lists, codes and gating were compared with the Roborock app's V1 device plugin. They were confirmed on a Saros 10R (
roborock.vacuum.a144, dock type 16). The on/off case without bit 53 was not tested on a device.Home Assistant
When Home Assistant bumps to this version, the
dust_collection_modeselect should take its options fromdust_collection_mode_optionsinstead ofRoborockDockDustCollectionModeCode.keys(). Otherwise it lists the newstrongmember, which is not selectable and has no translation.set_dust_collection_mode()validates against the same list.Conflicts with open PRs
v1_code_mappings.py,v1_containers.pyandtraits/v1/__init__.py; it rebases after this one.traits/v1/__init__.py(it also conflicts with main there); whichever merges second rebases.v1_containers.py(it also conflicts with main there); its branch needs a rebase either way.Testing
uv run pre-commit run --all-files: all hooks pass.uv run pytest: 2922 passed.tests/devices/traits/v1/test_dust_collection_mode.pyandtest_dust_collection.py: option lists per device, setter commands, rejection of unoffered values without sending (includinghighwithout bit 53), state unchanged after a failed command, unknown firmware codes, trait availability per dock type, mode gating (Saros 10R has it, a fixture without the dust collection setting bit and the Q Revo (Pearl) do not), and manual dust collection on the Saros 10R and the Q Revo.frequency_optionsoff, balanced, high.start_dust_collection()the robot state went fromchargingtoemptying_the_bin; afterstop_dust_collection()5 s later it went todockingand then back tocharging.