Skip to content

Show firmware updates in the official app and install them from its Update button (install is opt-in) - #255

Open
virtitnerd wants to merge 64 commits into
Python-roborock:mainfrom
virtitnerd:pr/firmware-install
Open

virtitnerd wants to merge 64 commits into
Python-roborock:mainfrom
virtitnerd:pr/firmware-install

Conversation

@virtitnerd

@virtitnerd virtitnerd commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #254. This PR now carries both the update check (from #254) and the install.

Depends on: #251 (last-known state) and #253 (plugin catalog refresh, which itself sits on #224). The branch is
built on those and contains both, so until they land the diff also shows their commits. Merge #251 and #253 first;
after that the diff shrinks to this PR's own commits.

Why

A robot paired to the local server never talks to Roborock's cloud, so it never learns about new firmware and the
official app cannot install it. The server also answered the app's firmware calls with a generic success, so the app
could never even see that an update existed. Keeping a robot out of the cloud should not mean never updating it.
People in #158, #150 and #36 describe updating before moving to the local server for this reason.

What

Update check

The routes the app really uses are GET /ota/firmware/<duid>/updatev2, GET /ota/firmware/updatev2?duids=... and
GET /ota/firmware/upgrade/status?duids=... (the path form of the status poll is forwarded too). The server reads the
update information from Roborock's cloud with the login it stored at sign-in and returns it, so the app shows the real
version and release notes. These routes require the app's signature. The four read-only check and status paths accept
a repeated signature (the app sends the check and the progress read with the same timestamp and nonce); the upgrade
routes do not. GET /admin/api/cloud/firmware lists every robot's status on the account for scripts. Without the
stored cloud login the check is reported as unavailable.

Install (off by default)

Turn it on with [ota] enable_install = true or ROBOROCK_SERVER_OTA_ENABLE_INSTALL=true (the variable wins). With
it off, the upgrade call is refused with an error instead of pretending to start.

With it on, the Update button (POST /ota/device/<duid>/upgrade):

  1. checks that the duid is in the server's inventory, and that no other install is starting or running;
  2. asks the cloud for the offered version and the package address for this robot (/user/devices/<duid>/fw?version=...;
    the file name carries the MD5);
  3. downloads the package to the data volume in the background, checks the MD5, and serves it to the robot from a token
    URL that is reusable until it expires (30 minutes) or the install ends;
  4. refuses unless the robot is docked (or asleep on its charger), idle, not cleaning, error free and at 20% battery or
    more, which is the official app's own gate;
  5. sends the robot's own OTA command (miIO.ota, download and install) and follows it through the reboot.

The install counts as successful only when the robot fetched the whole package from this server, went offline and came
back idle, and then reports the target version. Otherwise the status is FAILED with the reason. The live status is
saved to runtime/ota_live.json; after a server restart an install that was running is answered as FAILED, since the
server no longer watches the robot (the install is not resumed).

Other versions (opt-in)

The server keeps a catalog of every firmware package it learns of per model (version, address, MD5, released date,
size), and the admin routes learn-versions and scan-versions add cloud-confirmed versions to it. With
allow_downgrade on, POST /ota/device/<duid>/upgrade/version installs another catalog version. For a version older
than the one the robot reports, the JSON body must be {"version": "<target>", "confirm_downgrade": true} naming the
same version; otherwise the answer is 409 with needs_confirmation: true and nothing starts. The package for another
version is always asked from the cloud for this robot, and refused when its checksum differs from the catalog's or its
hardware folder differs from the running version's. Package addresses must be https on the Roborock package hosts.

Two things that were not obvious and are handled:

  • The robot's downloader only accepts capitalised header names (Content-Length). Starlette lowercases them, so
    packages are served with the names kept as written.
  • The cloud answers the app's status poll with an error when it knows of no update. The official app reads an error
    from that poll as a failed update, and polls it whenever the robot is silent for 90 seconds, which the reboot
    causes. While an install runs the server answers that poll itself from the robot's real state (and IDLE, which
    the app reads as success, only after the robot is back).

Reported version

The robot reports its version (protocol 203) on every connect. The server keeps it in the last-known state store and
uses it for the update check and the device list, because the cloud never learns the new version and would keep
offering the same update.

Security

Installs are opt-in, and downgrades need a second opt-in plus a confirmation in the request. Only a duid in the
inventory can be installed to. The server holds one account, so any signed app session can still start an upgrade to
the offered version when installs are enabled. The package is checked against the MD5 in the address the cloud returns.
I could not verify that the robot checks the package signature itself. The latest-stable call stays refused.

Testing

  • Full suite on this branch: 713 passed (this includes Keep each robot's last-known state and serve it at /user/devices/{duid}/last_known #251 and Refresh the plugin catalogs on demand with the stored cloud login #253).
  • tests/test_ota_firmware.py, tests/test_ota_install.py, tests/test_ota_install_safety.py and tests/test_ota_install_state.py cover both URL styles,
    the signature requirement and the replay case with a fake cloud, the one-install-at-a-time claim, the success rule,
    the per-robot package checks, the downgrade confirmation, the host allowlist and the saved status.
  • The iOS app shows the real version for a Qrevo Pro and a Qrevo Curv 2 Flow.
  • On hardware, only one model has been tried: a Qrevo Curv 2 Flow. It went from 02.33.48 to 02.35.52 through the iOS
    app's Update button (283 MB downloaded in 1m24s, installed in 2m15s, offline for 52s, robot reported 02.35.52 on
    reconnect, app showed success). After the hardening, the flow was run again end to end on the same robot through the
    server: a downgrade from 02.35.52 to 02.33.48 and the upgrade back, each about 4 minutes. An earlier install of a
    Qrevo Pro's current package confirmed the delivery path. Other models are untested.

Not included

The admin debug endpoints that drove the robot's OTA command by hand and the cloud path explorer are not part of this
PR. ota_dry_run.py does ship, since it is the download and watch engine the installer runs. See
docs/firmware_updates.md.

Related

#158, #150, #36 (context). There is no open issue for firmware updates; happy to open one if you prefer.

@Hoeze

Hoeze commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Hey @virtitnerd, is there a way to downgrade the robot firmware if needed?

virtitnerd added a commit to virtitnerd/local_roborock_server that referenced this pull request Nov 14, 2026
ROBOROCK_SERVER_OTA_ENABLE_INSTALL already updates the key in an existing
config.toml; a freshly generated file now carries the [ota] section too,
off unless the variable turns it on. The installation guide lists the
variable with the other commonly set ones. The section is read by the
firmware install change (Python-roborock#255); without that change the key is ignored.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@virtitnerd virtitnerd changed the title Install firmware from the official app's Update button (opt-in) Show firmware updates in the official app and install them from its Update button (install is opt-in) Nov 15, 2026
@virtitnerd
virtitnerd marked this pull request as ready for review November 15, 2026 15:22
@Lash-L Lash-L added blocked Waiting on an explicit dependency or maintainer hold; record the blocker. feature PR adding capability; under this two-type scheme also covers additive documentation. labels Nov 15, 2026
@virtitnerd

Copy link
Copy Markdown
Contributor Author

Good question, so I tested it. The robot does accept an older firmware as long as it is a real signed Roborock package.

On a Qrevo Curv 2 Flow (a245) I installed 02.33.48 over 02.35.52 through the server. The cloud still hands out the package for an older release if you ask for that exact version (user/devices/<duid>/fw?version=02.33.48 returns its URL; a version that was never released returns null). The robot downloaded it from the server, installed it, rebooted and came back on 02.33.48 in about 4 minutes. Maps, rooms and settings were all unchanged, and the official app now shows 02.33.48 with the update offered again.

The catch is that there is no cloud route that lists old versions, so you have to already know the version number. I'm adding to this PR a record the server keeps of every firmware it sees per model (version, package URL and md5, never pruned), so a user can pick an earlier version to reinstall later. Downgrading will be opt-in and off by default.

So far this was tested on one robot model only.

@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: changes requested

This review covers the 11 commits unique to this PR (47243da727 to a06f6d7af6); #251 and #253 have their own reviews. The design matches the app and installs are opt-in, but two reproduced bugs affect how an install's result is reported, and the downgrade path needs tighter guards. 598 tests pass.

Confirmed:

  • Endpoints match IotApi.java: GET ota/firmware/{duid}/updatev2, GET ota/firmware/{duid}/upgrade/status and POST ota/device/{duid}/upgrade. The personal_center bundle uses updatev2?lang&duids and /upgrade/latest-stable.
  • The check response matches OtaInfoBean (currentVersion, desc, releaseTime, updatable, version). There's no url or md5, and you only override currentVersion and updatable.
  • The install RPC matches the bundle's otaMiIot: miIO.ota {app_url, file_md5, proc, mode, install}. The package URL comes from user/devices/{duid}/fw?version=, as in the app.
  • Opt-in and safeguards:
    • enable_install defaults to false (returning 501), and downgrade also needs allow_downgrade.
    • The package is downloaded from the cloud, MD5-checked and served unmodified.
    • It only installs when the robot is docked, idle, error-free and at 80% battery or more.

Unverifiable: that the robot verifies the package signature itself (our firmware dump only shows the Q7's boot-time check), and protocol 203's mqttOtaFirmwareVersion.

Blocking:

  1. Two presses both start an install (ota_install.py start()/_launch, ~215).
    • _running is set only after waiting on the cloud and a download of up to 30 minutes. Two concurrent start() calls both returned started: True.
    • The second task then sets the app's status to FAILED while the real install runs.
    • With two robots, clean_package_cache deletes the other robot's package mid-download, and the single OtaDryRun._active slot makes the first robot's URL return 404.
    • Fix: take a lock, or set a "starting" marker before the first await.
  2. A brief disconnect counts as success (ota_install.py:284). The states idle, idle, offline, idle were reported as success with file_fetched=False. Require that the package was fully fetched and that the reported version equals the target.
  3. The downgrade path skips the per-robot checks. start_version passes known_url and so skips the version gate (ota_dry_run.py:359). The catalog is keyed only by model, so a URL learned from another robot of the same model is sent without asking the cloud for this robot. There's no hardware or region check.
  4. Any app session can install, including downgrades. Any Hawk-signed session can POST /upgrade and /upgrade/version for any duid, with no ownership check. Make downgrade admin-only, or require a confirmation.

Should fix:

  • allow_replay drops nonce checks for all firmware GETs (protocol_auth.py:618).
  • The "one-time" URL is reusable until its TTL, so the docs need correcting.
  • The path-form status poll isn't forwarded to the cloud.
  • There's no host allowlist in package_md5.
  • Install state is lost on a mid-install restart.
  • Please update the PR body: it says 550 tests and that the dry-run tools aren't included, but there are 598 and ota_dry_run.py ships.
  • Rebase once #251 and #253 are reworked: the branch currently merges #251 without its last commit.

I've converted this PR to draft while these are addressed. Mark it ready for review again once they're fixed and it will go through another review.


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 failing auto review Automated review requested changes before merge label Nov 21, 2026
@Lash-L
Lash-L marked this pull request as draft November 21, 2026 16:26
virtitnerd and others added 13 commits November 21, 2026 19:13
The snapshot keeps the cloud login and the plugin catalogs fetched at sign-in, and the
plugin routes serve those. Newer robots can need newer plugins than the snapshot holds, so
CloudImportManager.refresh_plugin_catalogs asks the cloud again with the stored login and
replaces only the catalogs. The sign-in now also stores the device identifier the cloud
ties the login to. A rejected login or an empty answer leaves the snapshot as it was.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The last status, battery and error a robot sent, its last position and the map it was on,
and when it last spoke or went offline, written under device_snapshots/ so it survives a
restart. A robot that dies or loses Wi-Fi stops answering; this is what is left to say
where it was.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
POST /admin/api/cloud/refresh-plugins re-reads them with the stored login, taking an
optional platform type. GET /admin/api/cloud/plugins shows what is stored without a cloud
request. Both return each plugin's version, API level and download URL.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Robot-originated frames update the store: status pushes (dps 120/121/122), get_status
answers, and the map reply, which is decrypted with the nonce of whichever client's
request asked for it. A closing robot connection marks the device offline at once.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Returns status, position, last_seen_at and offline_at; ?map=1 adds the last map the robot
sent so a client can draw it while the robot cannot be asked.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A robot that went quiet before the store existed still has its last status, battery and map
in the decoded MQTT log. On startup, in a background thread, devices the store has no snapshot
for are filled in from that log: last time heard, last status, and the last map decoded with
the nonce of the request that asked for it. Devices that already have a snapshot are left alone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…h it

The snapshot had the last map but not which segment is which room, so an
offline map could only show generic labels. The proxy now records each
get_room_mapping answer, the startup seed reads it from the MQTT log, and
/last_known adds each room's name from the home data.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both calls return the same status object, so either one now updates the stored state.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… safely

A refresh where one catalog errored replaced the good stored entry with the
error, and the fallback then served iOS the Android zips. Merge catalog by
catalog and keep the previous entry wherever the new one has an error.

The snapshot holds the only stored login and is read on every request, so
write it with atomic_write_inventory (also in submit_code). The refresh now
re-reads the snapshot under a lock after the cloud wait, so a sign-in that
finished meanwhile is not reverted; if the login changed, the refresh stops
and asks to run again. The result gains kept_previous when entries were kept.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Every exception was reported as a rejected login with advice to sign in
again, including timeouts, an unreachable cloud and RoborockRateLimit, which
made users re-run the rate-limited code login. Only RoborockInvalidCredentials
and RoborockAccountDoesNotExist now say to sign in again; rate limit, timeout
and connection errors get their own text, and anything else says the stored
catalogs were kept. The home-data helper now chains its RuntimeError to the
last error so the original type is visible to the classifier.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…fline

The regex needed endpoint before nonce and an all-word endpoint, but endpoints are
base64 (they can hold + and /) and the app may send the keys in either order, so
those robots never got maps or positions. Read the JSON instead.

Robots rebuilt from the MQTT log now get offline_at set to when they last spoke,
since nothing is connected right after a start; a long-dead robot no longer shows
as online. Flushes write files after releasing the store lock.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… the trace worker

Any rr/d/i publish used to count as the robot speaking, but app and bootstrap logins
can publish on any topic; use the connection's device topic binding. The offline mark
moves into the trace worker's close handler so queued packets cannot call mark_seen
after mark_offline, and a close is ignored when the robot has already spoken on a
newer connection. Mower pushes are skipped because their dps 121/122 are not
state and battery.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
virtitnerd and others added 10 commits November 22, 2026 11:15
The seed trusted any rr/d/i/ client-to-broker line. It now requires the topic's username to be the one the device with that id logs in with. The log does not record which login sent a frame, so this is weaker than the live bound-topic check, and the docs say so.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
package_family only read /rriotpkg/<hw>/, so an address without that folder skipped the hardware check. Both addresses must now name a hardware folder (also the regional <hw>/ form) and a file-name prefix, and both must match. The catalog test fixtures use the real address shape.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…kage

If _RoutineMqttClient raised, the finally that releases the package was never reached and the package stayed pinned against clean-up.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
stop() waits only 2 seconds for the worker, and updates traced while it drained came after the server's own shutdown flush. The proxy now flushes after the join.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Plain == and != treated 2.35.52 and 02.35.52 as different in the version list, the previous-version hint, the pre-install learn step and the post-install memory.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A robot that reconnected but had not published yet showed offline until its first message. Its own-credential login now clears the offline mark and registers the connection, so closing it marks the robot offline again.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The status was written before the fetch and the app reads a status older than 30 minutes as FAILED, while the fetch itself may take up to 30 minutes. A slow fetch could show FAILED just as the install was starting. A fetch that really times out still ends as FAILED.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolves the conflicts left by the squash merges of Python-roborock#251 and Python-roborock#253:
keeps the firmware routes, store and admin endpoints from this branch,
keeps main's schedule create/update/delete routes, and checks the OTA
routes before the schedule update in the HTTP handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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) (re-review at 904965a)

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

#251 and #253 were squash-merged into main on 2026-11-22, and this branch now has main merged in. git diff origin/main... shows only this PR's own changes (33 files, about 4,100 lines), and it merges cleanly. The commits that came from those branches (stored-login refresh message, plugin catalog age, B01 status, own-topic seeding, snapshot flush, online on own login) are already in main through #251/#253. This review covers the commits unique to this PR: b69eee5, 89e7a2d, 2715366, 70cfd88, plus the protocol 203 hook and the firmware routes.

Since the last review (c61c1fa → 904965a)

Earlier item Status
Should fix: the hardware check fails open (ota_install.py:252) Fixed in b69eee5. ota_install.py:253-256 now refuses unless both addresses name a hardware folder and a file-name prefix, and both have to match. package_family returns "" for unknown path shapes (ota_dry_run.py:408-413), so these cases fail closed. Tests cover the folder-less and mismatched cases (tests/test_ota_install_safety.py:237-241).
Minor: the MQTT client was built outside the try Fixed in 89e7a2d (ota_install.py:432-447). The package is now released if building the client raises.
Minor: == where firmware_versions.same should be used Mostly fixed in 2715366 (ota_install.py:217, 267-274, 292, 464). One is left, see the nits.
Minor: a slow download used up the 30-minute status window Fixed in 70cfd88. ota_install.py:295 resets START once the fetch finishes.

Rechecked

  • Wrong-firmware risk.
    • The offered-update path (start) only installs the package address the cloud gives for this duid (/user/devices/<duid>/fw?version=, ota_dry_run.py:468). Its MD5 has to match the file name, and the host has to be on the allowlist, including every redirect hop.
    • The other-version path (start_version) does the same per-robot lookup. It also requires the catalog MD5 and the hardware folder and file-name prefix of the running package to match.
  • Reported version. It is taken from protocol 203 only when the robot publishes on its own device topic, and never from B01 (mqtt_tls_proxy_server/server.py:653-663). An app session cannot fake the version that drives the downgrade decision.
  • Concurrency. _claim is set before the first await (ota_install.py:146-152, 187-193), installs run one at a time, and packages in use are pinned.
  • Auth.
    • /ota/firmware/* and /ota/device/* need Hawk. The replay allowance covers only the four read-only GETs (server.py, allow_replay=).
    • Both upgrade routes check that the duid is in the inventory.
    • A downgrade needs confirm_downgrade with the same version in the signed body.
  • B01 and older robots. _RoutineMqttClient speaks V1 only. A B01 robot does not answer get_status, so _refusal stops with "Could not read the robot's status" before miIO.ota is sent (ota_dry_run.py:239-243). This fails closed.

Nits

  • ota_dry_run.py:467 still compares current != version and offered == version with plain string equality. If the cloud and the robot pad the version differently, the update is refused. That is safe but confusing. Use firmware_versions.same.
  • For B01 and other non-V1 robots, an explicit refusal before the cloud lookup and package download (for example on the inventory's pv) would give a clearer reason. It would also avoid downloading a package of a few hundred MB that can never be installed.

Unverifiable: whether the robot checks the package signature itself, the protocol 203 mqttOtaFirmwareVersion report, and the robot-side OTA download. These are not in the decompiled sources. The two package-address shapes the hardware check expects (/rriotpkg/<hw>/ and rrpkg-*/<hw>/) come from the author's hardware testing and do not appear in the references. If the real addresses differ, installs will be refused rather than mis-flashed.

Checks: 947 passed (full suite on 904965a), and it merges cleanly with main.


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 removed the blocked Waiting on an explicit dependency or maintainer hold; record the blocker. label Nov 25, 2026
…same

The gate used plain string equality, so a cloud that says 2.35.52 and a robot that
reports 02.35.52 made the update refuse. The other version comparisons in ota_install
already use same().

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
virtitnerd added a commit to virtitnerd/local_roborock_server that referenced this pull request Nov 25, 2026
ROBOROCK_SERVER_OTA_ENABLE_INSTALL already updates the key in an existing
config.toml; a freshly generated file now carries the [ota] section too,
off unless the variable turns it on. The installation guide lists the
variable with the other commonly set ones. The section is read by the
firmware install change (Python-roborock#255); without that change the key is ignored.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nload

A B01 (or A01/L01) robot cannot be installed on by this code, which speaks the V1
protocol, but it only failed later with 'Could not read the robot's status' after the
package of a few hundred MB had been fetched. The inventory already holds each robot's
pv from the account's home data; carry it into the vacuum rows and refuse when it is
set and not 1.0. A missing pv is treated as V1, so existing behaviour is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@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 (re-review at 5e5def3)

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

This re-review covers the two commits added since the last review at 904965a: 927fffb and 5e5def3. Together they change 5 files (+81/−1). #251 and #253 (which sat on #224) are all merged into main, so git diff origin/main... still contains only this PR's own work (34 files, about 4,200 lines). It merges cleanly with main.

Since the last review

Earlier nit Status
ota_dry_run.py:467 compared versions as plain strings Fixed in 927fffb. Both the current-version check and the offered-version check now use firmware_versions.same (ota_dry_run.py:467). Two new tests cover the cloud and the robot writing a version with different padding (tests/test_ota_package_dry_run.py:233-245).
Non-V1 robots should be refused before any cloud call or download Fixed in 5e5def3. The inventory now keeps pv (inventory.py:78, 184, 220). _unsupported_protocol (ota_install.py:180-186) refuses any robot whose pv is not 1.0. Both _start and _start_version call it right after the inventory lookup, which comes before firmware_update_info, resolve_package or any download (ota_install.py:159, 216).

Rechecked

  • pv values: confirmed. python-roborock's DeviceVersion uses V1 = "1.0", A01 and B01 (python-roborock/roborock/devices/device_manager.py:48-54), and it reads them from the home-data device's pv (roborock/data/containers.py:312). So checking for "1.0" is correct.
  • Claim release: confirmed. The new early returns sit inside the try/finally that sets and clears _claim (ota_install.py:148-152, 200-204). A refused robot therefore never blocks the next install. The test test_a_non_v1_robot_is_refused_before_any_cloud_call checks that no cloud call is made and no live status is left behind, for B01, A01 and L01.
  • Fail-safe when pv is missing. If a robot has no pv (for example a local inventory without home data), the new check lets it through. The existing get_status refusal still stops it before miIO.ota (ota_dry_run.py:239-243), so it still fails closed. The only cost is a wasted download.
  • Nothing else changed. The opt-in gates, the MD5, host and hardware checks, Hawk auth, the inventory ownership check, the downgrade confirmation and the protocol-203 own-topic rule are the same as at 904965a. The findings from the last review still apply.

Nit (optional): A robot with an empty pv could be refused too once home data is known. That would save the download. It is not a safety issue.

Merge interactions: #261 merges cleanly with this branch. #252 conflicts in config.example.toml, mkdocs.yml, config.py and server.py. #176 conflicts in config.py and server.py. Both merge cleanly with main on their own, so whichever lands second will need a rebase. The conflicts look like neighbouring config and route additions.

Unverifiable: whether the robot checks the package signature itself, the robot-side OTA download (fwapi), protocol 203 mqttOtaFirmwareVersion, iOS behaviour, and the /api/v1/appplugin caller. None of these appear in the decompiled sources or the firmware dump. Only one model (a245) has been tested on hardware.

Checks: 954 passed (full suite at 5e5def3, up from 947), and the branch merges cleanly with main.


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.

@virtitnerd

Copy link
Copy Markdown
Contributor Author

Two new commits on pr/firmware-install, on top of the merge from main (no history rewritten).

Review items

  1. Plain string equality on versions in resolve_package: fixed in 927fffb. Both comparisons (current against version, offered against version) now use firmware_versions.same, so 2.35.52 and 02.35.52 are the same version. I grepped ota_dry_run.py and ota_install.py for other version equality; every other comparison already used same or at_least. The one remaining != on a value in ota_install.py compares package checksums, not versions. Tests added for a padded current, a padded reported, and a padded offered version with allow_update.

  2. B01 and other non-V1 robots downloading a package that can never be installed: fixed in 5e5def3. The inventory already stores each robot's pv (from the account's home data), but it was dropped when the vacuum rows were built. The rows now carry it, and both start and start_version refuse before the cloud lookup and before any download when pv is set and is not 1.0. The reason names the protocol, for example "This robot uses protocol B01; firmware install only supports V1 (1.0) robots, so nothing was downloaded". A missing pv is treated as V1 so existing setups behave as before. Tests: B01, A01 and L01 are refused with zero cloud calls on both entry points and no status is written; a pv of 1.0 still installs end to end; the inventory rows carry pv.

The full suite passes (954 passed). I will add the early refusal and the padding-tolerant version check to the description.

@Lash-L

Lash-L commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Okay @virtitnerd - this one needs the conflicts fixed as well!

virtitnerd added a commit to virtitnerd/local_roborock_server that referenced this pull request Nov 30, 2026
ROBOROCK_SERVER_OTA_ENABLE_INSTALL already updates the key in an existing
config.toml; a freshly generated file now carries the [ota] section too,
off unless the variable turns it on. The installation guide lists the
variable with the other commonly set ones. The section is read by the
firmware install change (Python-roborock#255); without that change the key is ignored.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
virtitnerd added a commit to virtitnerd/local_roborock_server that referenced this pull request Nov 30, 2026
@AlexanderBabel

AlexanderBabel commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Tested on a second model: Qrevo Edge 2 Pro (a226), EU region, 02.43.62 → 02.45.78, iOS app Update button, head b683974 on a k8s deployment. The robot installed and came back on 02.45.78 (about 4 minutes, 292 MB). Three things needed attention along the way:

  1. EU package host missing. The EU cloud hands out https://cdn.awsde0.fds.api.mi-img.com/rriotpkg/a226/rpkg_vivian_spro_4578_fullos.<md5>.signed.pkg. cdn.awsde0.fds.api.mi-img.com is not in PACKAGE_HOSTS, so the install stopped with "The cloud's package address is not in the expected form". Adding it to the set fixed it. (The EU plugin zips come from the same host.)

  2. A FAILED status from an attempt that never started blocks the next one in the app. After (1), ota_live.json kept that FAILED entry, /ota/firmware/upgrade/status (ota_firmware_status_local) kept returning it, and the iOS app showed "network unavailable" on the firmware page instead of letting me retry. Clearing the entry and restarting the server fixed it. Maybe a failure before the robot was told anything shouldn't be answered from local state, or should be cleared once the check offers the update again?

  3. The a226 skips a few bytes, so a successful install is reported as FAILED. The robot fetched the package in three ranges: bytes=0-4095, bytes=4096-54715079, bytes=54718464-291835495. It never requested 54715080-54718463 (3384 bytes). The robot then went offline, came back idle and reported 02.45.78 (protocol 203), but the status ended FAILED: "The robot never downloaded the whole package from this server" (package_fully_fetched). The reported version reaching the target may be the better success signal, or the coverage check could allow small gaps.

Smaller: during the install the app's progress jumps between 0 % and the real value. The server's own get_ota_progress / get_ota_state polls get bridged to the app's rr/m/o topic too, which might explain it.

Update: fixes for all three, with tests, are in virtitnerd/local_roborock_server#2 against pr/firmware-install.

…version

Found installing 02.45.78 on a Qrevo Edge 2 Pro (a226, EU region):

- The EU cloud serves packages from cdn.awsde0.fds.api.mi-img.com, which was
  not in PACKAGE_HOSTS, so the install stopped with "The cloud's package
  address is not in the expected form".
- A refusal before the robot was told anything stayed in the live status for
  30 minutes and across restarts. The app's status poll got it back on every
  visit to the firmware page, showed "network unavailable" and offered no
  Update button. Such a refusal is now answered for 60 seconds only.
- The a226 fetches the package in ranges and skips 3384 bytes
  (0-4095, 4096-54715079, 54718464-291835495), then installs it and reports
  the new version, yet the install was recorded as FAILED. The success rule
  now needs the robot to have fetched the package from this server at all;
  the version it reports afterwards already decides whether it installed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@virtitnerd

Copy link
Copy Markdown
Contributor Author

Thanks @AlexanderBabel, this was a very useful test on a second model. I reviewed your PR and merged it into this branch (29e9d53, your commit is kept as a parent). It covers the three things you found:

  • The EU package host cdn.awsde0.fds.api.mi-img.com is accepted. It is an exact host match, so lookalike hosts are still refused.
  • A refusal before the robot is told anything is now shown for 60 seconds instead of 30 minutes, so it no longer blocks the next attempt and the app's firmware page recovers.
  • Success no longer needs the robot to fetch every byte. The robot has to fetch from this server, go offline, come back idle and report exactly the target version, so the a226's skipped 3384 bytes no longer give a false FAILED.

One trade-off: a robot that fetches a single range and then reports the target version after rebooting now counts as success. The exact-version and offline-then-idle checks are what guard that.

I have not looked at the progress jumping between 0% and the real value yet.

@Lash-L the conflicts are fixed, and the branch merges cleanly with current main.

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

feature PR adding capability; under this two-type scheme also covers additive documentation. passed auto review Automated review found no blocking issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants