Skip to content

feat: add V1 dock dust collection mode, auto-empty frequency and start/stop - #1036

Merged
Lash-L merged 2 commits into
Python-roborock:mainfrom
infy1995:feat/v1-dust-collection-controls
Nov 25, 2026
Merged

Lash-L merged 2 commits into
Python-roborock:mainfrom
infy1995:feat/v1-dust-collection-controls

Conversation

@infy1995

@infy1995 infy1995 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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

  • DustCollectionModeTrait
    • dust_collection_mode_options: smart, light, balanced, max.
    • set_dust_collection_mode(mode) sends set_dust_collection_mode with {"mode": <code>}. A mode outside the options raises RoborockUnsupportedFeature and sends nothing.
    • RoborockDockDustCollectionModeCode gains strong = 3, so reading that code no longer falls back to unknown. It is not a selectable mode, so the setter rejects it.
  • New DustCollectionTrait (PropertiesApi.dust_collection, same name as the B01 Q10 trait): auto-empty setting and manual dust collection, on every collecting dock
    • Reads get_dust_collection_switch_status; set_frequency(frequency) sends set_dust_collection_switch_status with {"status": <code>}.
    • frequency_options (from get_dust_collection_frequencies(features)): off, balanced, high on devices with is_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() send app_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.
    • New RoborockDockDustCollectionFrequencyCode: off 0, balanced 1, high 2 (unknown = -1 for unexpected firmware codes).
  • docs/V1_API_COMMANDS.md: entries for both setters and get/set_dust_collection_switch_status. docs/V1_DEVICE_FEATURES.md: what the device features gate.
  • V1VacuumSimulator handles the new dust collection commands.

Gating

Trait Requires Why
dust_collection_mode is_collectable and is_collect_dust_mode_supported and is_dust_collection_setting_supported Only these robots have an emptying mode to read or set (not Pearl, robot new feature 33554432).
dust_collection is_collectable Every collecting dock has auto-empty and manual emptying; bit 53 only decides whether high is offered.

The mode trait is created explicitly in discover_features, because _is_supported cannot combine dock and device feature checks. DustCollectionTrait follows the WashTowelModeTrait pattern (dock gating plus the device features trait for its options).

Behaviour change: dust_collection_mode (read-only on main so far) is now None on Pearl products such as the Q Revo, and on devices without is_dust_collection_setting_supported, because those robots have no emptying mode to read or set.

Wire formats

Setting Read / write Codes
Dust collection mode get/set_dust_collection_mode, {"mode": n} 0 smart, 1 light, 2 balanced, 3 strong (not selectable), 4 max
Auto-empty frequency get/set_dust_collection_switch_status, {"status": n} 0 off, 1 balanced, 2 high; without bit 53 only 0 off and 1 on (same value as auto_dust_collection in get_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_mode select should take its options from dust_collection_mode_options instead of RoborockDockDustCollectionModeCode.keys(). Otherwise it lists the new strong member, which is not selectable and has no translation. set_dust_collection_mode() validates against the same list.

Conflicts with open PRs

Testing

  • uv run pre-commit run --all-files: all hooks pass.
  • uv run pytest: 2922 passed.
  • New tests in tests/devices/traits/v1/test_dust_collection_mode.py and test_dust_collection.py: option lists per device, setter commands, rejection of unoffered values without sending (including high without 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.
  • Saros 10R:
    • Read: mode 4 (max), frequency 2 (high); frequency_options off, balanced, high.
    • Write: frequency off and balanced, mode light, smart and balanced, each set through the library and confirmed in the Roborock app; then restored to max / high.
    • Actions: after start_dust_collection() the robot state went from charging to emptying_the_bin; after stop_dust_collection() 5 s later it went to docking and then back to charging.

@Lash-L Lash-L added Feature New feature V1 V1 platform labels Nov 15, 2026
@infy1995 infy1995 changed the title feat: add V1 dust collection controls feat: add V1 dock dust collection mode, auto-empty frequency and start/stop Nov 17, 2026

@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 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:
    • DustCollectionModeTrait and DustCollectionFrequencyTrait cleanly subclass RoborockBase containers (DustCollectionMode, DustCollectionFrequency), use concrete enum types with no Any on public boundaries, and validate selectable options before sending commands (raising RoborockUnsupportedFeature).
    • DustCollectionModeTrait gating (is_collectable + is_collect_dust_mode_supported + is_dust_collection_setting_supported) matches the app's gating for get/set_dust_collection_mode, and dust_collection_mode_options (0 smart, 1 light, 2 balanced, 4 max; omitting 3 strong) matches the app.
    • Two gating findings (see inline comments): DustCollectionFrequencyTrait should gate on is_auto_collection_2_supported rather than is_collect_dust_mode_supported, and placing start_dust_collection / stop_dust_collection on DustCollectionModeTrait hides manual dust collection from Pearl / non-DCS collecting docks.
  • Priority 2 — Data Lifecycle & State Management:
    • PropertiesApi.discover_features wires both traits cleanly without side-effecting helpers, and optimistic updates (self.mode = mode, self.status = frequency) only occur after send_command succeeds.
  • 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 (RoborockDockDustCollectionModeCode including strong = 3, RoborockDockDustCollectionFrequencyCode with unknown = -1) all match the Roborock app.
  • Tests & Verification:
    • Colocated tests in tests/devices/traits/v1/test_dust_collection_mode.py and test_dust_collection_frequency.py follow repository conventions. All 576 V1 trait tests, conformance tests (536 passed, 53 xfailed), ruff check, and mypy on the changed files pass.

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

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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:

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 Lash-L added the /review run Code review skill (/review) has been run label Nov 18, 2026

@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 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 on dock_features.is_collectable rather than is_collect_dust_mode_supported, with frequency_options (get_dust_collection_frequencies) exposing [off, balanced, high] when is_auto_collection_2_supported (new feature string bit 53) is set and [off, balanced] otherwise, rejecting high without bit 53 via RoborockUnsupportedFeature. Verified against the Roborock V1 app (NewFeatureStrBit.AutoCollection2 bit 53 toggles between the 3-way frequency selector and binary on/off auto-emptying switch on get/set_dust_collection_switch_status).
  • Manual dust collection (start_dust_collection / stop_dust_collection): Moved to DustCollectionTrait, so all collecting docks—including Pearl models (e.g. Q Revo) and docks without is_dust_collection_setting_supported—retain app_start_collect_dust / app_stop_collect_dust.
  • Lifecycle, Docs & Tests: PropertiesApi.discover_features wires DustCollectionTrait cleanly following the WashTowelModeTrait pattern, docs/V1_API_COMMANDS.md and docs/V1_DEVICE_FEATURES.md accurately reflect the updated gating, colocated tests in tests/devices/traits/v1/test_dust_collection.py cover the bit-53 option gating, rejection of high without bit 53, and Pearl manual dust collection, and all CI checks pass on 4f7f77c.

Verdict: Clean — passes /review and looks ready to merge.

@Lash-L Lash-L added the Passed /review Passed the /review skill check label Nov 21, 2026
@Lash-L

Lash-L commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

This PR passed /review, but it now has merge conflicts with main. Please rebase onto current main and resolve the conflicts so it can move on to a human review and merge.

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.
@infy1995
infy1995 force-pushed the feat/v1-dust-collection-controls branch from 4f7f77c to 4f3dccf Compare November 25, 2026 07:57
@infy1995

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and resolved the conflicts. The history is now two commits; the review fixes are folded in, and V1VacuumSimulator handles the new commands.

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

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: DustCollectionTrait is still gated on is_collectable only, and get_dust_collection_frequencies still offers high only with is_auto_collection_2_supported (new feature string bit 53).
  • Manual dust collection: start_dust_collection / stop_dust_collection are still on DustCollectionTrait, so Pearl products and docks without is_dust_collection_setting_supported keep them.
  • The DustCollectionModeTrait gating (is_collectable and is_collect_dust_mode_supported and is_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__.py now adds DustCollectionModeTrait to the skip tuple next to CollisionAvoidanceTrait (which came from #1089 on main). The conflict was resolved correctly: both traits are still created explicitly and skipped in the generic loop.
  • Simulator (new): roborock/testing/v1_simulator.py handles get/set_dust_collection_mode, get/set_dust_collection_switch_status (backed by status.auto_dust_collection), and app_start/stop_collect_dust (they set the state to emptying_the_bin / charging). tests/testing/test_v1_simulator.py adds round-trip tests for both traits through the real V1Channel.
  • Docs: docs/V1_API_COMMANDS.md adds Saros 10R entries for app_start_collect_dust / app_stop_collect_dust, plus a get_dust_collection_mode return 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:425 uses the magic number 33554432 for is_dust_collection_setting_supported. A named constant, or a comment naming the feature (as roborock/device_features.py:305 does), would make the test easier to read.
  • Nit (optional): roborock/devices/traits/v1/dust_collection.py:35 and docs/V1_API_COMMANDS.md:1397, :1417, :1439 list only the Saros 10R. You could add the Qrevo MaxV 2 (a87) as a supported device for set_dust_collection_mode and get/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-tree against current origin/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 with RoborockUnsupportedFeature before anything was sent.
  • Auto-empty: set 1 (balanced/on), then 0 (off), then restored 1. All ok. high was 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.
  • mypy on 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. release was skipped.

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

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

Tested on my vac and working 100%. Double checked some logic and everything looks good to me, thank you!

@Lash-L
Lash-L merged commit 9f9a65e into Python-roborock:main Nov 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature Passed /review Passed the /review skill check /review run Code review skill (/review) has been run V1 V1 platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants