Repository navigation
feat(api): enable scene tiles via productTags and category cardSpec - #208
SmarthomeElektroniker wants to merge 4 commits into
Conversation
1f574a5 to
89b2186
Compare
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: passed (nits)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.
All tests pass (461). It merges cleanly with main. Against #224 the only conflict is that both PRs append tests to tests/test_product_response.py, so keep both.
Confirmed from the APK:
ProductTaghas exactlyname,forceShow(defaults to true),pluginLevelandrequirePlugin, andPRODUCT_NAME_SCENE = "scene_2.0"(sdk/bean/ProductTag.java).Product.sceneProduct()returnsproductTagsMap.get("scene_2.0"), built from theproductTagsJSON list (sdk/bean/Product.java). So the tag you add matches what the app reads.pluginLevel: 0is harmless: it's only read on click.
Unverifiable locally:
- The gate you describe (
supportScene(): forceShow, isRoborock, feature bit 0x21, a non-null category cardSpec) isn't in our decompiled sources.RRDeviceBeanV2,CategoryEntityandCardSpecV2are missing. assets/cardSpec/robot.vacuum.cleaner.jsonisn't in our resources either, so the state codes and dps (121/122/128/135) couldn't be checked.- We have no captured
/api/v5/productresponse with these fields. Our APK is 4.64.06, and your live test was on 4.60.06.
Nits:
- The real cloud seems to send the card spec differently. The
Productbean has@JSONField(name="cardspec") Stringon the product, and python-roborock parsesRoborockProduct.cardspecas a JSON string with a{"data": …}wrapper (roborock/data/containers.py:555-561). This PR sends a dict on the category, under two spellings, with no wrapper (product_service.py:33-39). It may be right for the newerCategoryEntity, but please note it in the PR, or also sendproduct.cardspecas a string. - All vacuums share one category spec. B01 models (Q7/Q10) use different state codes, so their status label may be wrong. That's untested; the live check was on an a38.
- Tests only check that keys are present. Comparing values against a real fixture, and testing a non-vacuum category alongside a vacuum, would be stronger.
This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.
|
I have a capture of the EU cloud's Place and format of the card spec: the cloud sends This PR sends the inner object as a dict, without the wrapper, under both The vacuum category (
The other categories: the wet-dry vacuums ( Product tags of the Saros 20 Flow (a307) in the cloud: [
{"name": "scene_2.0", "requirePlugin": true, "pluginLevel": 3000, "forceShow": true},
{"name": "StatusShow", "requirePlugin": false, "pluginLevel": 0, "forceShow": false},
{"name": "OfflineMap", "requirePlugin": true, "pluginLevel": 3001, "forceShow": false}
]This PR sends For nit 3, I can send the cloud's vacuum spec as a test fixture, if you want one. |
|
Tested on a second model: the scene tiles show on my Saros 20 Flow ( |
|
Thank you very much for the capture and the detailed, objective comparison – that is really helpful, and it's great to hear the scene tiles also work on your Saros 20 Flow. About state 26: our test device is a Q7 Max, which has no mop washing – it simply drives back to the dock in that state, which is where "Return to the dock" came from. Since the original Roborock app shows "Going to wash the mop" as well (e.g. on the S8 Ultra), I'll switch the label to the cloud's wording. I'll also go through the other points (cardspec as a string with the We'd be very happy if this can be taken over in this form – thanks again for your support! |
The Android app hides a device's scene quick-start tiles unless
RRDeviceBeanV2.supportScene() is true:
product.sceneProduct().forceShow && isRoborock() && hasFeature(0x21)
&& category.cardSpec != null
isRoborock() and feature bit 33 (from featureSet in home data) were already
satisfied. Missing were:
- productTags with a "scene_2.0" entry (forceShow=true); sceneProduct() looks
up exactly this tag in productTagsMap, which the app builds from the list.
- a cardSpec on the category (CardSpecV2: state/extra/battery/offline data
points, no "data" wrapper). Both spellings declared by CategoryEntity
("cardspec" and "cardSpec") are sent.
Labels are English only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow the EU cloud's /api/v5/product answer:
- category "cardspec" as a JSON string with the spec in {"data": ...}
(decoded by the app as CardSpecV2Data); no extra "cardSpec" dict
- vacuum spec: add offpeak (dps 133), cloud wording for states 6, 9,
15, 26 and offline code 1
- scene_2.0 tag with requirePlugin true, pluginLevel 3000
- tests check the string format, the labels and a non-vacuum category
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3f76c06 to
657d95a
Compare
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: passed (re-review at 657d95aa)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it. It's still a draft, so mark it ready when you're done.
Earlier nits:
| Nit | Status |
|---|---|
| Card spec format and location | Fixed. The category now gets cardspec only, as a JSON string {"data": spec}, matching your EU cloud capture and python-roborock (containers.py:555-561). The refreshed Saros 20 Flow bundle also defaults the category cardspec to '', with productTags on the product. |
| One spec for all vacuums, B01 differs | Resolved by your capture: all 56 vacuum models share one cloud spec, sc01/sc05 included. |
| Tests only checked keys | Mostly fixed. The tests now check values, labels, the state set and the string format, plus a non-vacuum category. |
Suggestion, not blocking: every product gets scene_2.0 with requirePlugin: True, pluginLevel: 3000, mowers and washers included. Those values come from a single a307 capture, and what the app does with pluginLevel on click is unverifiable. Since #224, snapshot_plugin_catalog_data(ctx, "product") holds the cloud's own /api/v5/product payload. Using its productTags and category cardspec when present, with the hard-coded values as a fallback, would also bring in the cloud's 22 languages.
Checks: it merges cleanly with main alongside #224's changes, and 506 tests pass on the merged tree. #292 conflicts in product_service.py; keep both sides.
This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles, refreshed 2026-11-21), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.
|
Here is the fixture. It is the
|
Since Python-roborock#224 the snapshot holds the cloud's own /api/v5/product answer. Use it when present: - productTags per product (by model) are passed through as the cloud sends them, including an empty list (no scene_2.0 then) - the category cardspec is taken from the cloud (all 22 languages); an empty string counts as missing The built-in values stay as the fallback when there is no snapshot or no entry. The fallback scene_2.0 tag (requirePlugin, pluginLevel 3000, forceShow) is now only added to robot.vacuum.cleaner: the tiles also need a category cardspec, which we only have for vacuums, and the tag values were only seen on a vacuum. Mowers, washers etc. get the tag only when the cloud sends it. Tests: snapshot values and languages win, a listed model without a scene tag stays without one, missing entry/empty cardspec falls back, non-vacuum categories with and without snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add tests/fixtures/cloud_vacuum_cardspec_eu.json: the decoded cardspec of the robot.vacuum.cleaner category from the EU cloud's /api/v5/product answer (2026-11-21, provided by @Hoeze in Python-roborock#208). The fallback spec is checked against it: same data points and dps, the cloud's English label for every code the cloud maps. The only extras are the state and offline codes of the app's bundled template, listed and explained in the test. A second test passes the fixture through the snapshot and checks all 22 languages arrive. Replaces the hand-written label checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the re-review, and thanks @Hoeze for the cloud fixture! I took up the suggestion: Hoeze's capture is now in the tests as #292 isn't merged yet; when it is, I'll rebase and keep both sides in Could you take another look? |
Add tests/fixtures/cloud_vacuum_cardspec_eu.json: the decoded cardspec of the robot.vacuum.cleaner category from the EU cloud's /api/v5/product answer (2026-11-21, provided by @Hoeze in Python-roborock#208). The fallback spec is checked against it: same data points and dps, the cloud's English label for every code the cloud maps. The only extras are the state and offline codes of the app's bundled template, listed and explained in the test. A second test passes the fixture through the snapshot and checks all 22 languages arrive. Replaces the hand-written label checks.
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: passed (nits)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.
Since the last review (657d95a → c82660f)
| Earlier item | Status |
|---|---|
Suggestion: take productTags and the category cardspec from the cloud snapshot, keep the hard-coded values as a fallback |
Done. _cloud_product_details (product_service.py:42-65) reads both from snapshot_plugin_catalog_data(ctx, "product"). An empty productTags list from the cloud is kept as it is, and an empty cardspec falls back. |
Suggestion: don't give scene_2.0 (pluginLevel: 3000) to mowers and washers |
Done. The fallback tag is now only added to robot.vacuum.cleaner (product_service.py:28, :68-71). Other categories get a tag only when the cloud sends one. |
| Tests only checked hand-written labels | Done. The fallback spec is now compared with Hoeze's EU fixture: same data points, same dps, and the cloud's English label for every code the cloud maps. The extra codes from the bundled template are listed with the reason. |
What I checked in the delta
- No snapshot / model not in the snapshot: vacuums get the same
scene_2.0tag and Englishcardspecas at657d95a. Non-vacuums getproductTags: []and nocardspec, which is the behaviour from before this PR. The tests cover both cases. - Secrets: none. The fixture only holds data points and labels. The
/api/v5/productsnapshot is the product catalog and carries no account or device data, and nothing new is logged. - Mowers: the capture lists mowers and mower base stations with
StatusShow/DeviceInvisibleonly, so they still get no scene tiles. That matches the cloud.
Nits (not blocking)
- The fallback tags B01 vacuums the cloud doesn't tag (
product_service.py:68-71,:138). In the EU capture,roborock.vacuum.sc01,sc05,ss07andss09have onlyStatusShow+SilentOta, with noscene_2.0. With a snapshot they now correctly get no tag. Without one they fall into the vacuum fallback and getscene_2.0, which is a change from what the cloud does. The tiles still need feature bit 33, so the effect is probably small. Whether those models report the bit, and what the scene entry would open for a B01 plugin, can't be checked from the decompiled sources. Fix: leave the B01 models out of the fallback (for example with a small set of model prefixes or models), or add a comment saying the difference is known. - Every cloud tag now reaches the app, not only
scene_2.0(product_service.py:64):SilentOta,DeviceInvisible,OfflineMap,5GHz_WiFi. This is the same as the cloud, so it's fine. In the 4.64.06 APK,Product.statusProduct()/silentOtaProduct()/offlineMapProduct()(com/roborock/smart/sdk/bean/Product.java:404-514) have no callers in the decompiled Java, so I can't tell what effect they have. Worth a quick look in the app on a device the cloud tagsSilentOta.
Unverifiable: how supportScene() and the cardSpec models behave at runtime is outside the decompiled sources. Your live tests (a38, a307) were done before the snapshot path was added. The format now matches the cloud's.
Checks: it merges cleanly with current main (c836f4f, which includes #251, #253 and #288), and 795 tests pass on the merged tree. #292 still conflicts in product_service.py. Keep both sides when you rebase.
This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.
|
@SmarthomeElektroniker #292 is merged |
What does this PR do?
The official app shows the saved scenes ("routines") as quick-start tiles on the device card. With the local server the tiles never appeared, although
/user/scene/home/{id}returned the scenes correctly. In the Android app the condition isRRDeviceBeanV2.supportScene():isRoborock()and the feature bit were already satisfied. Two things were missing from/api/v5/product, and this PR adds them in the format of the cloud's answer (EU/api/v5/productcapture from 2026-11-21, thanks to @Hoeze):productTagson each product with ascene_2.0entry, as the cloud sends it:{"name": "scene_2.0", "requirePlugin": true, "pluginLevel": 3000, "forceShow": true}.ProductEntity.sceneProduct()looks up exactly this key; the app buildsproductTagsMapfrom the list itself.cardspecon the categoryrobot.vacuum.cleaner(newroutes/api/card_spec.py): lower-case name, the value is a JSON string with the spec wrapped in{"data": {...}}. In the APK,CategoryEntityhas@SerialName("cardspec") Stringand decodes it with theCardSpecV2Dataserializer (thedatawrapper) into the transientcardSpecthatsupportScene()checks.The vacuum spec: state dps 121, battery 122, extra 128, offline 135, offpeak 133. The labels use the cloud's wording (e.g. 6/15 "Returning to Dock", 9 "Charging Error", 26 "Going to wash the mop", offline 1 "Powered Off Manually").
Changed after the review and the cloud capture:
cardspecis now the cloud's string with thedatawrapper; the extracardSpecdict is gone (review nit 1).offpeak(dps 133) added, labels aligned to the cloud.scene_2.0now hasrequirePlugin: true,pluginLevel: 3000. From the 4.60.06 bytecode: the tiles themselves only depend onforceShow.requirePlugin/pluginLevelare read when a scene entry opens the device plugin (SmartCommandListpage): withrequirePlugin: falsethat path ends in the "device initialize failed" toast, withtrueit opens the plugin.pluginLevelonly matters when the installed plugin's version is below 2000; the device plugins inAPPPLUGIN_LISThave version ≥ 5208 and level 3001.main(2069fc7); fix(api): add rriotid, categoryId, category code and agreements to /api/v5/product #207 is merged, so the branch no longer contains its commits.Kept on purpose:
assets/cardSpec/robot.vacuum.cleaner.json, 4.60.06) maps exactly these codes, so they only add labels and change nothing for the cloud's codes.robot.vacuum.cleanergets a spec. Other categories (wet-dry vacuums, washers, mowers) get none, as before.The tiles still need feature bit 33 from the device, so a device that does not support scenes will not suddenly show them.
Before you open this PR (optional, but very helpful)
PRs I reviewed:
Proof that it works
Tests (
tests/test_product_response.py, review nit 3):scene_2.0tag with the cloud's valuescardspecis a string, decodes to{"data": {...}}with state/extra/battery/offline/offpeak and the dps above; nocardSpecFull suite on the rebased branch:
uv run pytest -q→ 506 passed.A test fixture with the cloud's full vacuum spec (offered by @Hoeze) can replace the hand-written value checks once it is available.
Tested on:
roborock.vacuum.a38); second model by @Hoeze: Saros 20 Flow (roborock.vacuum.a307, firmware 02.17.50)main(Oct 2026); @Hoeze: on top ofmain2069fc7What I did and what happened:
Android app 4.60.06, device list view: after the change the home screen showed the device state from the card spec and the scene quick-start tiles; @Hoeze saw the tiles on the a307 as well. These live checks were done with the first version of this PR (card spec as a dict under
cardspec/cardSpec,scene_2.0withpluginLevel: 0). The current version sends the cloud's format, which the app decodes throughCategoryEntity.cardspec→CardSpecV2Data; it has not been re-checked live yet.In 4.60.06 the scene bar sits in the small card layout (
item_home_card_small_scene_v2.xml). I did not check whether the large single-device card shows it.Screenshots (required for any UI change)
No web UI / add-on / onboarding changes. The visible effect is in the Roborock app (scene tiles on the device card).
🤖 Generated with Claude Code