Repository navigation
feat(q7): add CLI vacuum commands for B01 Q7 devices - #1075
saruk-vedant wants to merge 4 commits into
Conversation
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).
Scope & CI
- Files:
roborock/cli.py(+165),roborock/const.py(+2),tests/test_cli.py(+251/-3). Well-scoped to Q7 CLI commands,status, rawcommand, andROBOROCK_Q7_TF_PLUSregistration (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 toroborock/const.pyandSUPPORTED_VACUUMS.
Priority 2: Data Lifecycle, State & CLI UX
- Lifecycle & Teardown:
query_values()performs a liveprop.getrequest (no stale cached state), and@async_commandhandlescontext.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--segmentshelp text and docstring direct users to theroomscommand, butrooms(roborock/cli.py:950-966) has nob01_q7_propertiesbranch and printsFeature not supported by deviceon Q7 devices. See inline comment.
Priority 3: Wire Protocols & Codecs
- Medium — Raw
commanddefault params (roborock/cli.py:1054): PassingNonewhen--paramsis omitted causesQ7RequestMessage.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--paramsto{}aligns the raw CLI command (including theservice.find_deviceexample) with Q7 wire conventions. See inline comment.
Tests & Fixtures
- Clean: 12 well-structured tests colocated in
tests/test_cli.py, reusingFakeQ7Channelandcreate_q7_api, using@pytest.mark.parametrize, and asserting public behavior (published_commandsand CLI output) rather than private state.
| 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) |
There was a problem hiding this comment.
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 '[]'):
| 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 {}) |
| @click.option( | ||
| "--segments", | ||
| required=True, | ||
| help="Comma-separated room/segment ids to clean (see the `rooms` command), e.g. 9,2", |
There was a problem hiding this comment.
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()).
…ter from q7-clean-segments
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 (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
commanddefault params (roborock/cli.py:1054). An omitted--paramsnow sends{}instead ofNone(whichQ7RequestMessage.to_dps_value()turned into[]). This matches the app:service.find_device,service.start_rechargeand the other no-argument Q7 methods take{}(RR_APIhermes/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:
roomspointer inq7-clean-segments(roborock/cli.py:1864, docstring). Neither the help text nor the docstring mentionsroomsany 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_APIhermes/update_manifest.json:447, listed as "Roborock Q7 Series") and the model id in a Q7 flash dump'scertificate.bin.
Priority 2: Lifecycle, State & CLI UX
- No findings. The commands go through the existing
Q7PropertiesApimethods and@async_commandteardown, the same way the Q10 session commands do.
Priority 3: Wire Protocols & Codecs
- The wire calls match the app bundle:
service.set_room_cleanwithclean_type/ctrl_value/room_ids,service.start_rechargewith{}, andprop.get. All 11 properties thatstatusqueries are in the app'sgetDeviceProp/getSettingPropbatches (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'sSCDeviceCleanParam/SCSetRoomCleanParamhas a fourth value,{'stop': 0, 'start': 1, 'pause': 2, 'puaseFalse': 3}(output.js:289468,246487).3may 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 unconfirmedpuaseFalse= 3)".
Tests & PR hygiene
- Blocking: merge conflict with
mainintests/test_cli.py. Since this branch was cut,mainhas gained #1046 and #1033, which changed theroborock.cli/roborock.dataimport block at the top of the file (it now importsRoborockProductNicknameandDeviceFeatures). The conflict is only in the imports: rebase ontomainand keep both sets. - At
d53d0d4:pytest2602 passed, 47 xfailed (15 Q7 CLI tests pass).ruff checkandruff format --checkare clean.mypyshows only the existingtypes-protobufstub error, whichmainalso 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
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 (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
mainintests/test_cli.py.fc15e7amergesmainatcfa413e(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, ...) andmain'sfields,RoborockProductNicknameandDeviceFeatures. Inroborock/cli.py, the merge keepsmain'sDeviceVersionimport next to the PR'sQ7PropertiesApiimport.git merge-treeagainst the currentorigin/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'sSCDeviceCleanParam/SCSetRoomCleanParamis{'stop': 0, 'start': 1, 'pause': 2, 'puaseFalse': 3}(RR_APIhermes/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 unconfirmedpuaseFalse= 3)". The PR body has the same wording. - Fixed earlier and still fixed: raw
commanddefaults omitted--paramsto{}, andq7-clean-segmentsno longer points users torooms.
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_rechargewith{}), as the last review checked. - Out of scope, for a later PR: on the live device,
statusshowed"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_2105inroborock/data/b01_q7/b01_q7_code_mappings.py:354could get a charging-related name and a comment, the same wayF_2103got 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 statusworked 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-dockandq7-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 checkandruff format --checkare 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).releasewas skipped.
This is an automated review and can be incorrect, so please reply if any finding looks wrong.
Summary
A Q7 TF+ (
roborock.vacuum.sc05,pv=B01) is recognised as a B01/Q7 device by the device manager, andQ7PropertiesApialready 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",homefailed with "Device does not support V1 protocol", and the rawcommandsilently did nothing for Q7 devices.This adds the missing CLI surface for Q7 devices, mirroring the existing Q10 commands:
q7-vacuum-start,q7-vacuum-pause,q7-vacuum-stop,q7-vacuum-dockandq7-clean-segments, calling theQ7PropertiesApimethods directly (the Q7 API exposes its cleaning commands on the API itself, there is no separate vacuum trait as on the Q10).statusnow works for Q7 devices viaprop.get, reporting status, fault, battery (quantity), work mode, station state, charge state, cleaning time/area, fan, water and mode.commandaccepts B01 Q7 method names (e.g.service.find_device) and prints the device reply; unknown method names are rejected withInvalid command <cmd> for B01_Q7 devicebefore anything is sent. Omitted--paramssends{}(the library's no-arg form).roborock.vacuum.sc05is registered asROBOROCK_Q7_TF_PLUSand added toSUPPORTED_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 withq7-vacuum-start.homeis 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, thenq7-vacuum-start --device_id <duid>starts a whole-home clean on a Q7 device;q7-vacuum-pause,q7-vacuum-stopandq7-vacuum-dockpause, stop and return it to the dock.q7-clean-segments --device_id <duid> --segments 9,2starts 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_devicesends a raw Q7 method; an unknown method name is rejected with an error and nothing is sent.Verification
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?",statusqueriesprop.getand prints the properties, and the raw command sends a named method and rejects unknown ones. Fix round: omitted--paramsnow sends{}(wasNone, serialized as[]); explicit--params '[]'and dict values pass through unchanged;q7-clean-segmentshelp no longer references theroomscommand.main(cfa413e, 7.33.0) to resolve the merge conflict intests/test_cli.py: the import block now keeps both the newRoborockProductNickname/DeviceFeaturesimports 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 unconfirmedpuaseFalse= 3).pytest --ignore=tests/e2e --ignore=tests/mqtt: 2823 passed, 46 xfailed (basemainat the same commit: 2807 passed, 46 xfailed; the 16 extra passing tests are the new Q7 CLI tests).tests/test_cli.pyalone: 35 passed. No Q10 or V1 code paths were changed; the new branches are only reached whenb01_q7_propertiesis set.ruff checkandruff format --checkare clean.mypy roborock testsreports the same 3 pre-existing errors as unmodifiedmain(missingtypes-protobufandtypes-PyYAMLstubs, plus one return-type error intests/map/test_b01_q10_render.py; no new errors).pre-commit run --fileson the three changed files passes, andcodespellon those files is clean (one pre-existing codespell hit sits in an unrelatedtests/e2esnapshot).roborock.vacuum.sc05device. The reporter of Add support for roborock.vacuum.sc05 (Q7 TF+) #1070 offered to test patches.Fixes #1070