Repository navigation
fix(plugin): resolve string product ids and serve the iOS app plugin - #224
Conversation
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
|
This worked for me. It now resolves my S7 MaxV. |
|
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. |
There was a problem hiding this comment.
Automated review: passed (nits)
Checked against the decompiled Android app:
- a226 → id 199: confirmed. It's 199 in the EU
/api/v5/productlist, 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.
Producthasint idplus@JSONField(name="rriotid") String rrPid. The app matches a device byrrPid, then uses the intid. - The rest matches:
/api/v5/productis a plain GET with no params, and thePluginVersionfields (apilevel,productid,url,version,pluginLevel) are right. - iOS
type: 1vs Androidtype: 2: can't be checked from an Android-only APK, since the/api/v1/appplugincaller isn't in the decompiled sources. It's plausible: python-roborock sendstype: 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:
product_service.pynow 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.data_helpers.model_product_idsassumes everycategoryDetailList/productListentry is a dict. It now runs on every/api/v5/productrequest, so addisinstanceguards to avoid a 500 on a malformed snapshot.- The iOS import sends
apilevel: 10043, but the test uses40740. Is the iOS apilevel intentional? - Two cases have no test: a body with no
type, and anappplugin_ioscatalog 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.
|
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. |
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>
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.
/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.
/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.
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 showedPOST /api/v1/apppluginbut no/plugin/proxy/...download. Two gaps caused it:30uADinyLKa3Qpga60B1Ke), on both the product and the device._plugin_product_ids()only acceptsint(...), so the import never asked for/api/v1/appplugin("error": "no product ids available")./api/v5/productthen answered withstable_int(...) % 1_000_000as the numeric id, which matches no plugin. The cloud has a numeric id for the model: its/api/v5/productreturns{"id": 199, "model": "roborock.vacuum.a226"}.type:1for iOS,2for Android. The import only fetchedtype: 2, and the route answered every request with that. The iOS app cannot load the Android zip.Fix
import_web_inventory_from_cloud.py): fetches the cloud's/api/v5/productintoplugin_catalogs.product. It maps string product ids to their numeric id by model, then fetches/api/v1/apppluginfortype: 2(appplugin, unchanged) andtype: 1(newappplugin_ios)./api/v5/product(product_service.py): for a model without an entry inMODEL_PRODUCT_ID_OVERRIDES, the numericidnow comes from the cloud catalog in the snapshot, before the hash fallback. Numeric ids andrriotidare unchanged./api/v1/appplugin: a request with"type": 1getsappplugin_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 requestsapppluginwithproductids: [199]for bothtype1 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, andrriotidstays the string.tests/test_plugin_routes.py:POST /api/v1/apppluginreturns the iOS zip fortype: 1and the Android zip fortype: 2. A snapshot withoutappplugin_iosfalls back to the existing catalog.Full suite:
uv run pytest -qpasses (459 tests).Live check (Oct 2026), a226 on firmware 02.43.62, iOS app 4.74.02:
_fetch_plugin_catalogsfrom this branch against the real cloud with my imported session. It resolved30uADinyLKa3Qpga60B1Ke→ 199 and returned plugin 6846 with69588500….zipfor type 2 and22598cbf….zipfor type 1.Notes
endpoint_rules.pystill has an older copy of_build_product_responsethat nothing calls. I left it alone, as fix(api): add rriotid, categoryId, category code and agreements to /api/v5/product #207 did.appfeaturepluginandpluginsare still fetched only withtype: 2. I didn't check whether the cloud serves different zips for iOS there too./api/v5/productand the secondappplugin. Like the other catalogs, a failure is stored as anerrorand doesn't stop the import.