Skip to content

fix(plugin): resolve string product ids and serve the iOS app plugin - #224

Merged
Lash-L merged 1 commit into
Python-roborock:mainfrom
AlexanderBabel:fix/string-product-id-plugins
Nov 21, 2026
Merged

Lash-L merged 1 commit into
Python-roborock:mainfrom
AlexanderBabel:fix/string-product-id-plugins

Conversation

@AlexanderBabel

Copy link
Copy Markdown
Contributor

Fixes #221.

Problem

On a Qrevo Curv/Edge 2 Pro (roborock.vacuum.a226), the official iOS app (4.74.02) showed "Device initialization failed" against the local server. The server log showed POST /api/v1/appplugin but no /plugin/proxy/... download. Two gaps caused it:

  1. String product ids. Cloud home data lists this model with a string product id (30uADinyLKa3Qpga60B1Ke), on both the product and the device. _plugin_product_ids() only accepts int(...), so the import never asked for /api/v1/appplugin ("error": "no product ids available"). /api/v5/product then answered with stable_int(...) % 1_000_000 as the numeric id, which matches no plugin. The cloud has a numeric id for the model: its /api/v5/product returns {"id": 199, "model": "roborock.vacuum.a226"}.
  2. One zip for both platforms. The cloud serves a different zip for the same plugin version per request type: 1 for iOS, 2 for Android. The import only fetched type: 2, and the route answered every request with that. The iOS app cannot load the Android zip.

Fix

  • Import (import_web_inventory_from_cloud.py): fetches the cloud's /api/v5/product into plugin_catalogs.product. It maps string product ids to their numeric id by model, then fetches /api/v1/appplugin for type: 2 (appplugin, unchanged) and type: 1 (new appplugin_ios).
  • /api/v5/product (product_service.py): for a model without an entry in MODEL_PRODUCT_ID_OVERRIDES, the numeric id now comes from the cloud catalog in the snapshot, before the hash fallback. Numeric ids and rriotid are unchanged.
  • /api/v1/appplugin: a request with "type": 1 gets appplugin_ios. If that catalog is missing (snapshots imported before this change), it falls back to the current list, so existing setups behave as before. A GET without a body is unchanged.
  • shared/data_helpers.model_product_ids() holds the model → id walk that both sides use.

Nothing is hardcoded for the a226. Every id and URL comes from the cloud import.

Tests

  • tests/test_cloud_plugin_catalogs.py: with home data that uses a string product id, the import requests appplugin with productids: [199] for both type 1 and 2, and stores the product catalog and both plugin catalogs.
  • tests/test_product_response.py: a string product id gets the cloud's numeric id for its model, and rriotid stays the string.
  • tests/test_plugin_routes.py: POST /api/v1/appplugin returns the iOS zip for type: 1 and the Android zip for type: 2. A snapshot without appplugin_ios falls back to the existing catalog.

Full suite: uv run pytest -q passes (459 tests).

Live check (Oct 2026), a226 on firmware 02.43.62, iOS app 4.74.02:

  • I ran _fetch_plugin_catalogs from this branch against the real cloud with my imported session. It resolved 30uADinyLKa3Qpga60B1Ke → 199 and returned plugin 6846 with 69588500….zip for type 2 and 22598cbf….zip for type 1.
  • With the same ids and URLs served by the local server, which I patched locally before writing this PR, the iPhone app opens the device, and remote view and live video work.

Notes

  • endpoint_rules.py still has an older copy of _build_product_response that nothing calls. I left it alone, as fix(api): add rriotid, categoryId, category code and agreements to /api/v5/product #207 did.
  • appfeatureplugin and plugins are still fetched only with type: 2. I didn't check whether the cloud serves different zips for iOS there too.
  • The import makes two more cloud calls: /api/v5/product and the second appplugin. Like the other catalogs, a failure is stored as an error and doesn't stop the import.

The cloud lists newer models (e.g. roborock.vacuum.a226) under a string
product id, so the import never fetched their app plugin and /api/v5/product
answered with a hashed id that matches no plugin. The app then fails with
"device initialization failed".

The import now fetches the cloud's /api/v5/product to map models to their
numeric id, and fetches /api/v1/appplugin for both type 2 (Android) and
type 1 (iOS), which get different zips. The appplugin route answers iOS
requests from the iOS catalog, falling back to the existing one.

Fixes Python-roborock#221
Copilot AI balanced review requested due to automatic review settings October 30, 2026 20:17

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.

@AlexanderBabel
AlexanderBabel requested a balanced review from Copilot October 30, 2026 20:20

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.

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.

🟢 Approval recommended

Regression tests cover product resolution, catalog imports, and platform-specific routing, providing evidence for the implemented behavior.

No open issues 🎉

Review effort: Lite

@NicolasBonduel

Copy link
Copy Markdown
Contributor

This worked for me. It now resolves my S7 MaxV.

@quentinrsl

Copy link
Copy Markdown

I have a Saros 10R and the patched andoid app kept giving me a "Device initialization failed 21020" when I tried to load the robot.
This fixed it for me thanks

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

Automated review: passed (nits)

Checked against the decompiled Android app:

  • a226 → id 199: confirmed. It's 199 in the EU /api/v5/product list, and ids differ by region (a199 is 199 in the US and 185 in the EU). So taking the id from the account's own cloud import is right, and hardcoding would be wrong.
  • String rriot pid vs numeric id: confirmed. Product has int id plus @JSONField(name="rriotid") String rrPid. The app matches a device by rrPid, then uses the int id.
  • The rest matches: /api/v5/product is a plain GET with no params, and the PluginVersion fields (apilevel, productid, url, version, pluginLevel) are right.
  • iOS type: 1 vs Android type: 2: can't be checked from an Android-only APK, since the /api/v1/appplugin caller isn't in the decompiled sources. It's plausible: python-roborock sends type: 2, and your live test got two different zips. The zip proxy cache is keyed by URL, so the two don't collide.

All tests pass on this head.

Nits:

  1. product_service.py now prefers the cloud id even when home data has a numeric id, while the import (_plugin_product_ids) prefers the home-data int. They agree in practice, but the order and the description ("numeric ids unchanged") should match.
  2. data_helpers.model_product_ids assumes every categoryDetailList / productList entry is a dict. It now runs on every /api/v5/product request, so add isinstance guards to avoid a 500 on a malformed snapshot.
  3. The iOS import sends apilevel: 10043, but the test uses 40740. Is the iOS apilevel intentional?
  4. Two cases have no test: a body with no type, and an appplugin_ios catalog stored with an error. Both fall back to Android correctly by reading the code.

Note: #288 also edits appplugin.build, so it'll need a rebase after this lands.


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.

@Lash-L Lash-L added the passed auto review Automated review found no blocking issues label Nov 21, 2026
@Lash-L

Lash-L commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Now that this has passed the automated review above, I'll do a human review and then either request changes or merge it.


The review above was automated and can be incorrect, so please reply if any finding looks wrong.

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

Looks good, thank you!

@Lash-L
Lash-L merged commit 292b646 into Python-roborock:main Nov 21, 2026
3 checks passed
SmarthomeElektroniker pushed a commit to SmarthomeElektroniker/local_roborock_server that referenced this pull request Nov 22, 2026
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>
Hoeze pushed a commit to Hoeze/local_roborock_server that referenced this pull request Nov 22, 2026
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.
Hoeze added a commit to Hoeze/local_roborock_server that referenced this pull request Nov 24, 2026
/api/v1/appplugin matches a snapshot plugin record by its product id alone. If the record's device has left the inventory or has not paired, no model holds that id. Another model then got the id as its built-in id, and the app installed the record's plugin for it. For example, a US import stored the a199 plugin at 199. The EU catalog gives 199 to the a226, so an a226 got 199 and the a199 plugin.

This happens if the import has no product list. Imports before Python-roborock#224 stored none, and neither does an import whose product list request failed. Such an import fetched the records by the numeric home data ids.

The record now holds its id for the model that the snapshot's home data names, else for an unknown model. A paired device of the named model keeps the id and the record. The iOS test fixture gets the product list of a current import, because a real import never writes records without home data.
Hoeze added a commit to Hoeze/local_roborock_server that referenced this pull request Nov 24, 2026
/api/v1/appplugin matches a snapshot plugin record by its product id alone. If the record's device has left the inventory or has not paired, no model holds that id. Another model then got the id as its built-in id, and the app installed the record's plugin for it. For example, a US import stored the a199 plugin at 199. The EU catalog gives 199 to the a226, so an a226 got 199 and the a199 plugin.

This happens if the import has no product list. Imports before Python-roborock#224 stored none, and neither does an import whose product list request failed. Such an import fetched the records by the numeric home data ids.

The record now holds its id for the model that the snapshot's home data names, else for an unknown model. A paired device of the named model keeps the id and the record. The iOS test fixture gets the product list of a current import, because a real import never writes records without home data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: official-app Official Roborock Android/iOS apps, login and plugins. bug Something isn't working passed auto review Automated review found no blocking issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App: "device initialization failed" for models with a string cloud product id (a226), and iOS gets the Android plugin

5 participants