Deduplicate firmware_image_type and migrate renumbered devices over OTA - #474
Deduplicate firmware_image_type and migrate renumbered devices over OTA#474eakorolev wants to merge 2 commits into
firmware_image_type and migrate renumbered devices over OTA#474Conversation
ba60ffa to
cc1786d
Compare
firmware_image_typefirmware_image_type and migrate renumbered devices over OTA
|
Thanks for your work! If they have the same chip, they run the same firmware. Only the default config string is different. So the current approach is very inefficient.. 🙂 We need a big refactor for the project in this regard. I would like to merge the image types instead, maybe into: Telink router, Telink end-device, Silabs router, Silabs end-device. Also not sure how the migration would take place? The migration index would have the initial problem where the types are duplicated? I'm dreaming of a big refactor like this: GitHub action publishes the standard firmware (few image types) -> it works as an update for all devices. |
|
Thanks @andrei-lazarov, and I like the bigger direction — merging image types, plus a web-tool for migration and stock-flashing, sounds good. To be honest about where this came from: I started while trying to fix OTA updates on my own devices. After digging in, I found the duplicate image types were not my problem at all. My real issue was the indexes: I have a mix of devices — Telink routers, Silabs routers, and Silabs battery end-devices — so I'd loaded both the router and the end_device index at once, without realizing that puts each device into both, and zigpy then sees it twice and ignores both. So this PR doesn't actually fix my original pain; that part is on the index side, and I'll think about it separately. Looking at the duplicates themselves, they all seem accidental: two people add a device in separate PRs at about the same time, both correctly pick a free id, and the collision only appears once both are merged. Nobody did anything wrong. I opened the PR mostly to bring the repo in line with what it already says — The part I'd keep no matter which way image types go: the migration mechanism — a new On your question — "the migration index would have duplicated types" — that part is fine, and I checked it. Both zigpy (2.0.0) and Zigbee2MQTT / zigbee-herdsman (10.7.0) use the entry's |
|
That's true. I allowed duplicates because it was too much work to explain to everybody.. and make sure they still receive updates after the correction. So I left them as is. It doesn't hurt to add the check, but it's not really needed. |
Problem
firmware_image_typeis meant to be unique per device, but 27 ids are each shared by two or more devices. OTA matchers (zigpy / Home Assistant ZHA and Zigbee2MQTT) normally tell such devices apart bymanufacturerName, so most of these collisions are currently masked — but the guarantee is fragile: where two colliding devices also share a manufacturer name (the twoBOARD__MHCOZY_TS0004variants both report_TZ3210_imaccztn) the match breaks and neither device is offered an update, and any index entry left without amanufacturerNamematches the wrong device.Fix
Renumber the later-registered device in each collision to a free id (
47116–47147), restoring one id per device. A CI check (helper_scripts/check_image_types.py) keeps it that way: on pull requests it validates only the entries changed against the base branch, onmainit validates the whole db.Renumbering on its own would strand already-flashed units — they keep reporting the old id, for which no image exists anymore. To avoid a manual re-flash, each renumbered device also builds a migration OTA: its new firmware wrapped in an OTA header carrying the old id. A deployed unit still reporting the old id matches it, updates once over the air, and afterwards reports the new id. This is driven by a new
migration_from_image_typefield indevice_db.yaml;board.mkemits one migration image per old id into the normal index. Confirmed safe on zigpy 2.0.0 and zigbee-herdsman 10.7.0 — both enforcemanufacturerName, so the migration image and the keeper's image at the same old id never collide or cross-flash.Renumbered devices