Skip to content

feat(q7): add CLI vacuum commands for B01 Q7 devices - #1075

Open
saruk-vedant wants to merge 4 commits into
Python-roborock:mainfrom
saruk-vedant:roborock-1070-q7-vacuum-commands
Open

saruk-vedant wants to merge 4 commits into
Python-roborock:mainfrom
saruk-vedant:roborock-1070-q7-vacuum-commands

Conversation

@saruk-vedant

@saruk-vedant saruk-vedant commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A Q7 TF+ (roborock.vacuum.sc05, pv=B01) is recognised as a B01/Q7 device by the device manager, and Q7PropertiesApi already exposes cleaning commands, but the CLI had no Q7 branch at all. Every vacuum command fell through to the V1 path and reported "Feature not supported by device", home failed with "Device does not support V1 protocol", and the raw command silently did nothing for Q7 devices.

This adds the missing CLI surface for Q7 devices, mirroring the existing Q10 commands:

  • New session commands q7-vacuum-start, q7-vacuum-pause, q7-vacuum-stop, q7-vacuum-dock and q7-clean-segments, calling the Q7PropertiesApi methods directly (the Q7 API exposes its cleaning commands on the API itself, there is no separate vacuum trait as on the Q10).
  • status now works for Q7 devices via prop.get, reporting status, fault, battery (quantity), work mode, station state, charge state, cleaning time/area, fan, water and mode.
  • The raw command accepts B01 Q7 method names (e.g. service.find_device) and prints the device reply; unknown method names are rejected with Invalid command <cmd> for B01_Q7 device before anything is sent. Omitted --params sends {} (the library's no-arg form).
  • roborock.vacuum.sc05 is registered as ROBOROCK_Q7_TF_PLUS and added to SUPPORTED_VACUUMS.

There is intentionally no resume or spot command: the library does not map a resume value yet (the app defines an unconfirmed puaseFalse = 3) and no spot clean task type, so a paused clean is restarted with q7-vacuum-start. home is unchanged on purpose: home discovery is V1-only by design (the same error applies to Q10 devices), and Q7 maps are exposed through the map trait instead.

How to test

  • roborock session, then q7-vacuum-start --device_id <duid> starts a whole-home clean on a Q7 device; q7-vacuum-pause, q7-vacuum-stop and q7-vacuum-dock pause, stop and return it to the dock. q7-clean-segments --device_id <duid> --segments 9,2 starts a room clean of rooms 9 and 2.
  • status --device_id <duid> on a Q7 device prints the queried properties as JSON.
  • roborock command --device_id <duid> --cmd service.find_device sends a raw Q7 method; an unknown method name is rejected with an error and nothing is sent.

Verification

  • New CLI tests in tests/test_cli.py (16 tests): each vacuum command sends the expected B01 Q7 command and payload through a fake Q7 channel, segment input is validated before anything is sent (non-integer and empty input), a device without a Q7 API reports "Device does not support B01 Q7 protocol. Is it a Q7?", status queries prop.get and prints the properties, and the raw command sends a named method and rejects unknown ones. Fix round: omitted --params now sends {} (was None, serialized as []); explicit --params '[]' and dict values pass through unchanged; q7-clean-segments help no longer references the rooms command.
  • Updated with latest main (cfa413e, 7.33.0) to resolve the merge conflict in tests/test_cli.py: the import block now keeps both the new RoborockProductNickname/DeviceFeatures imports from main and the Q7 imports from this PR. The resume comment is reworded: the library does not map a resume value yet (the app defines an unconfirmed puaseFalse = 3).
  • pytest --ignore=tests/e2e --ignore=tests/mqtt: 2823 passed, 46 xfailed (base main at the same commit: 2807 passed, 46 xfailed; the 16 extra passing tests are the new Q7 CLI tests). tests/test_cli.py alone: 35 passed. No Q10 or V1 code paths were changed; the new branches are only reached when b01_q7_properties is set.
  • ruff check and ruff format --check are clean. mypy roborock tests reports the same 3 pre-existing errors as unmodified main (missing types-protobuf and types-PyYAML stubs, plus one return-type error in tests/map/test_b01_q10_render.py; no new errors). pre-commit run --files on the three changed files passes, and codespell on those files is clean (one pre-existing codespell hit sits in an unrelated tests/e2e snapshot).
  • Not verified: no physical Q7 TF+ hardware was available, so the commands were verified against the fake Q7 channel only, not against a live roborock.vacuum.sc05 device. The reporter of Add support for roborock.vacuum.sc05 (Q7 TF+) #1070 offered to test patches.

Fixes #1070

Copilot AI balanced review requested due to automatic review settings November 22, 2026 13:22

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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

Scope & CI

  • Files: roborock/cli.py (+165), roborock/const.py (+2), tests/test_cli.py (+251/-3). Well-scoped to Q7 CLI commands, status, raw command, and ROBOROCK_Q7_TF_PLUS registration (roborock.vacuum.sc05).
  • CI: All checks passing (commitlint, lint, pytest 3.11/3.14, test-mqtt 3.11/3.14, build).

Summary by Architectural Layer

Priority 1: Public Trait APIs & Consumer Contracts

  • Clean: No trait APIs modified; all calls against Q7PropertiesApi (query_values, start_clean, pause_clean, stop_clean, return_to_dock, clean_segments, send) match method signatures and return types. ROBOROCK_Q7_TF_PLUS = "roborock.vacuum.sc05" is cleanly added to roborock/const.py and SUPPORTED_VACUUMS.

Priority 2: Data Lifecycle, State & CLI UX

  • Lifecycle & Teardown: query_values() performs a live prop.get request (no stale cached state), and @async_command handles context.cleanup() -> device.close() -> b01_q7_properties.close() teardown in CLI mode. Session commands mirror the Q10 session command pattern.
  • Minor UX gap (roborock/cli.py:1864): q7-clean-segments --segments help text and docstring direct users to the rooms command, but rooms (roborock/cli.py:950-966) has no b01_q7_properties branch and prints Feature not supported by device on Q7 devices. See inline comment.

Priority 3: Wire Protocols & Codecs

  • Medium — Raw command default params (roborock/cli.py:1054): Passing None when --params is omitted causes Q7RequestMessage.to_dps_value() to serialize "params": [], whereas all no-argument B01 Q7 methods in the library (service.find_device, service.start_recharge, service.get_map_list, service.get_record_list) send "params": {}. Defaulting omitted --params to {} aligns the raw CLI command (including the service.find_device example) with Q7 wire conventions. See inline comment.

Tests & Fixtures

  • Clean: 12 well-structured tests colocated in tests/test_cli.py, reusing FakeQ7Channel and create_q7_api, using @pytest.mark.parametrize, and asserting public behavior (published_commands and CLI output) rather than private state.

Comment thread roborock/cli.py Outdated
except ValueError as err:
raise RoborockException(f"Invalid command {cmd} for B01_Q7 device") from err
properties = device.b01_q7_properties
result = await properties.send(method, json.loads(params) if params is not None else 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.

Priority 3 — Wire Protocol Convention (params={} vs params=[])

When --params is omitted, params is None, which Q7RequestMessage.to_dps_value() (roborock/protocols/b01_q7_protocol.py:47-50) serializes as "params": []. However, every no-argument B01 Q7 method in this library — including service.find_device (Q7PropertiesApi.find_me), service.start_recharge (return_to_dock), service.get_map_list, and service.get_record_list — sends an empty JSON object {} instead of [].

Defaulting omitted --params to {} ensures roborock command --device_id <duid> --cmd service.find_device sends the expected {} payload on the wire (callers who explicitly need [] can still pass --params '[]'):

Suggested change
result = await properties.send(method, json.loads(params) if params is not None else None)
result = await properties.send(method, json.loads(params) if params is not None else {})

Comment thread roborock/cli.py Outdated
@click.option(
"--segments",
required=True,
help="Comma-separated room/segment ids to clean (see the `rooms` command), e.g. 9,2",

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.

Priority 2 — Misleading CLI Help (rooms not supported on Q7)

Both the --segments help text here and the docstring below direct users to the rooms command, but rooms (roborock/cli.py:950-966) currently only handles b01_q10_properties and V1 devices — running it on a Q7 device prints Feature not supported by device.

Consider either removing the (see the rooms command) reference from the Q7 help/docstring or adding a b01_q7_properties branch to rooms (via b01_q7_properties.map_content.refresh()).

@Lash-L Lash-L added /review run Code review skill (/review) has been run Q7 B01 Q7 platform labels Nov 22, 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 Claude Opus 5.5 in Claude Code using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).

Follow-Up Review (d53d0d4, delta from 87138ed)

Verdict: Does not pass /review.

Both findings from the previous review are fixed and the code itself is clean. The only blocker is that the branch no longer merges cleanly with main: it needs a rebase.

Earlier findings

  • Fixed: raw command default params (roborock/cli.py:1054). An omitted --params now sends {} instead of None (which Q7RequestMessage.to_dps_value() turned into []). This matches the app: service.find_device, service.start_recharge and the other no-argument Q7 methods take {} (RR_API hermes/b01/Roborock Q7 Series/reverse_engineered_docs/B01_Q7_COMMANDS.md:103-115). The new tests cover the omitted, explicit '[]' and explicit dict cases.
  • Fixed: rooms pointer in q7-clean-segments (roborock/cli.py:1864, docstring). Neither the help text nor the docstring mentions rooms any more, and a test guards this.

Priority 1: Public Trait APIs & Consumer Contracts

  • No findings. No trait APIs changed. ROBOROCK_Q7_TF_PLUS = "roborock.vacuum.sc05" matches the app's model list (RR_API hermes/update_manifest.json:447, listed as "Roborock Q7 Series") and the model id in a Q7 flash dump's certificate.bin.

Priority 2: Lifecycle, State & CLI UX

  • No findings. The commands go through the existing Q7PropertiesApi methods and @async_command teardown, the same way the Q10 session commands do.

Priority 3: Wire Protocols & Codecs

  • The wire calls match the app bundle: service.set_room_clean with clean_type / ctrl_value / room_ids, service.start_recharge with {}, and prop.get. All 11 properties that status queries are in the app's getDeviceProp / getSettingProp batches (output.js:289480-289482).
  • Nit (roborock/cli.py:1785-1788, and the PR body): the comment says the Q7 firmware "has no resume control value (SCDeviceCleanParam only defines start, pause and stop)". That holds for the library's enum, but the app's SCDeviceCleanParam / SCSetRoomCleanParam has a fourth value, {'stop': 0, 'start': 1, 'pause': 2, 'puaseFalse': 3} (output.js:289468, 246487). 3 may well be resume (un-pause). Its meaning isn't confirmed, so leaving out a resume command is fine, but please reword the comment so it doesn't claim the firmware has no such value. For example: "the library does not map a resume value yet (the app defines an unconfirmed puaseFalse = 3)".

Tests & PR hygiene

  • Blocking: merge conflict with main in tests/test_cli.py. Since this branch was cut, main has gained #1046 and #1033, which changed the roborock.cli / roborock.data import block at the top of the file (it now imports RoborockProductNickname and DeviceFeatures). The conflict is only in the imports: rebase onto main and keep both sets.
  • At d53d0d4: pytest 2602 passed, 47 xfailed (15 Q7 CLI tests pass). ruff check and ruff format --check are clean. mypy shows only the existing types-protobuf stub error, which main also has.
  • Live hardware is still untested, and the PR body says so.

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.

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 (fc15e7a, delta from d53d0d4)

Verdict: Passes /review with nits.

The merge conflict is gone and the merge is correct. Unit tests, ruff and CI all pass. status works on a real Q7 M5+. One earlier nit, a code comment, is still open and does not block the PR.

Earlier findings

  • Fixed: merge conflict with main in tests/test_cli.py. fc15e7a merges main at cfa413e (7.33.0). The import block now keeps both sides. It has this PR's Q7 imports (q7_* commands, session, status, HomeDataDevice, CleanTaskTypeMapping, SCDeviceCleanParam, Q7PropertiesApi, FakeQ7Channel, ...) and main's fields, RoborockProductNickname and DeviceFeatures. In roborock/cli.py, the merge keeps main's DeviceVersion import next to the PR's Q7PropertiesApi import. git merge-tree against the current origin/main (2a051f2, two commits newer: #1050 and #1091) merges cleanly. Neither of those commits touches the PR's files.
  • Still open, nit: the "no resume control value" comment (roborock/cli.py:1791-1794). This is unchanged from the last review. The app's SCDeviceCleanParam / SCSetRoomCleanParam is {'stop': 0, 'start': 1, 'pause': 2, 'puaseFalse': 3} (RR_API hermes/b01/Roborock Q7 Series/output.js:246487, 289468), so the firmware probably does have a fourth value, likely resume. Leaving out a resume command is fine. Please reword the comment to something like "the library does not map a resume value yet (the app defines an unconfirmed puaseFalse = 3)". The PR body has the same wording.
  • Fixed earlier and still fixed: raw command defaults omitted --params to {}, and q7-clean-segments no longer points users to rooms.

New in this delta

  • Only the merge commit. A line-by-line diff shows the PR's own changes are the same before the merge (8551bd8..d53d0d4) and after it (cfa413e..fc15e7a). Nothing else changed.

Priority 1: Public Trait APIs & Consumer Contracts

  • No findings.

Priority 2: Lifecycle, State & CLI UX

  • No findings.

Priority 3: Wire Protocols & Codecs

  • No new findings. The wire calls still match the app (prop.get, service.set_room_clean, service.start_recharge with {}), as the last review checked.
  • Out of scope, for a later PR: on the live device, status showed "fault": "fault_2105" while it was charging. The app does not treat 2105 as an error. It checks for it together with its charging toasts (home_charge_charging, output.js:184730-184745). F_2105 in roborock/data/b01_q7/b01_q7_code_mappings.py:354 could get a charging-related name and a comment, the same way F_2103 got one. This PR doesn't need to do that.

Live test on a Q7 M5+

roborock.vacuum.sc05, protocol B01, firmware 03.01.80, real US cloud, at fc15e7a:

  • roborock status worked and printed all 11 properties: status: charging, fault: fault_2105, wind: max_plus, water: medium, mode: vacuum, quantity: 100, cleaningTime: 26, cleaningArea: 1465, workMode: idle, stationAct: 0, chargeState: 1. The values match a docked robot that is charging.
  • Not run on the device, because they move the robot: q7-vacuum-start, q7-vacuum-pause, q7-vacuum-stop, q7-vacuum-dock and q7-clean-segments. Unit tests cover them.

Local results at fc15e7a

  • pytest: 2856 passed, 46 xfailed, 11 deselected. The 16 Q7 / status / raw-command CLI tests pass.
  • ruff check and ruff format --check are clean.
  • CI (gh pr checks): every check passes (Build Package, Lint Commit Messages, Test Semantic Release, lint, test 3.11/3.14, test-mqtt 3.11/3.14). release was skipped.

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

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

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

Passed /review Passed the /review skill check Q7 B01 Q7 platform /review run Code review skill (/review) has been run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for roborock.vacuum.sc05 (Q7 TF+)

3 participants