-
Notifications
You must be signed in to change notification settings - Fork 357
Description
This one is going to be a bit "involved", so, drafting some guidelines, and gathering some feedback beforehand...
Move OTA logic from ZHC to ZH
Most of the code should go in Device.ts.
Helpers can be added separately (request builders, validators & co).
Need to rework the update logic so it can be properly tested (tests were disabled a while back in ZHC, vitest crumbles due to the amount of faked setTimeout or something...). Maybe a stream-like logic would work better?
Move OTA logic from Z2M to ZH
Moving scheduling stuff in ZH would decrease code duplication in Z2M extension and ensure unified logic (+ built-in support for other projects using ZH). Also would add database support.
Support all known OTA file tags
Support spec tags, see 11.4.4 of ZCL spec.
[Manu-spe] Refactor Koenkk/zigbee-herdsman-converters#9984 - 0xf000 should parse as AES tag for Telink per source. No need for custom properties in OTA index.
snippet
/** see https://github.com/telink-semi/telink_zigbee_sdk/blob/d5bc2f7b0c1f8536fe21c8127ca680ea8214bc8e/tl_zigbee_sdk/zigbee/ota/ota.h#L38 */
const TELINK_AES_TAG_ID = 0xf000;
if (tagID === TELINK_AES_TAG_ID) {
// OTA_FLAG_IMAGE_ELEM_INFO1 (1-byte) + OTA_FLAG_IMAGE_ELEM_INFO2 (1-byte)
const tagMeta = buffer.subarray(position + 6, position + 8);
const data = buffer.subarray(position + 8, position + 8 + length);
return [{tagID, length, tagMeta, data}, 8];
}Should also be able to remove suppressElementImageParseFailure property from ZHC. (e.g. LEDVANCE use is Telink AES, same as above).
Cleanup zigbee-OTA customParseLogic.
Firmware release notes in mqtt/frontend
Add releaseNotes property to OTA state payload (if available).
Source feedback in mqtt/frontend (local index vs repo index)
Add source property to OTA state payload.
Updating via custom firmware URL
Passing url as part of update payload would seem the easiest. Can branch out to "use that firmware instead of matching in index".
Can spec-match the image after downloading.
Problem of "no index":
- unable to do off-spec matching for manufacturers that make a mess of the OTA spec (e.g. Tuya, Gledopto, etc.).
- potential for "wrong firmware flashed" increased substentially
- no SHA, no integrity checking possible, can only validate that the image is passing OTA spec format, but cannot ensure it wasn't tampered with
- no release notes (presumably, user is already aware in this scenario)
Must bypass ota: true used in ZHC definition.
Must allow bypassing fileVersion check (to ease cases like Lumi that does not respect fileVersion incrementing...).
Will need UI support in specific device page rather than OTA page (since OTA page is dependent on supports_ota which we want to bypass here).
Updating via custom index URL
Similar to above, but for index. Should help with projects building custom firmware. Provides a middleground between "have to be in zigbee-OTA repo" and "use custom firmware URL" when extra off-spec matching is desired, better safety, and only one URL to share for all devices supported by given project.
Improve downgrading support
Add new buttons tied to proper topics in WindFront.
Need proper feedback of "is upgrade" vs "is downgrade" when a "check" was done and the OTA state has a match.
Better error handling for update
Should clear OTA state as appropriate when errors indicate a problem like "no image available" (could have been detected by a previous, now stale, check). cf https://github.com/Koenkk/zigbee2mqtt/blob/2721b0ea78f4e86e6fe3b5f4831c5787a28585a8/lib/extension/otaUpdate.ts#L366-L371
Improve options
Support disable_automatic_update_check per-device. Due to how Zigbee OTA works, we cannot prevent devices from requesting OTA, but with this option we can always reply "not available".
Post-update changes
Currently only reconfigure is done. This causes problems with some devices, should just full interview.
Tooling
https://nerivec.github.io/zigbee-ota-file-editor/
CC: @romasku @andrei-lazarov @pvvx @slacky1965 @thk-socal @sjorge @burmistrzak