feat: improve OTA
Design changes
- https://github.com/Koenkk/zigbee-herdsman/issues/1608
- requires https://github.com/Koenkk/zigbee-herdsman/pull/1612/
- Update API to match new features
- Merge Zigbee/MQTT triggered
updatelogic into single function for consistency - Rework OTA support check (from definition) to allow custom file/URL to always go through (
check/update/schedule) - Add from/to file versions to
updateresponse payload to avoid weirdness with swBuildId/dateCode often unavailable - Add
latest_source(URL/filesystem),latest_release_notesto OTA state payload - Allow passing data settings (timings/sizes) per request to override settings
- Tweak the published OTA state based on return of
update(clearavailableifupdatereturned "no image") - Add ability to
schedulewith custom URL/filesystem - Add ability to send hex-formatted image to Z2M which will be automatically written to data dir (for use with
updateorschedule)- Should allow using plain file over MQTT/WS assuming properly formatted upstream (e.g. frontend)
- With limitation that MQTT/WS must allow payloads of sufficient size (though most cases should be <1MB)
Due to MQTT request payloads still allowing simple string for OTA, it duplicates the code a bit for now (marked deprecated for 3.0).
@Koenkk
- I'm thinking with this one, we might want to bump the settings version so we can trigger a migration to remove all cached OTA states?
- How do you prefer to deal with
nullsource/release_notes in#getEntityPublishPayload? I'm hesitating betweennullor undefined so it's taken out on stringify.
TODO:
- [x] remove
restartrequired from OTA data settings in schema - [ ] change hex writes to
otasubdir of data dir - [ ] new tests for full coverage
- [ ] ZHC: cleanup
- [ ] docs for new features / MQTT API additions
I'm thinking with this one, we might want to bump the settings version so we can trigger a migration to remove all cached OTA states?
Agree
How do you prefer to deal with null source/release_notes in #getEntityPublishPayload? I'm hesitating between null or undefined so it's taken out on stringify.
I would propose to go for null (such that the attribute is always in the published payload)
@Koenkk can you take a closer look now that it's fully tested? In particular:
- Left a few TODOs, not all quite related to this specifically.
- I modified
reInterview(previously only used if triggered by bridge request) to behave more like if it had been triggered from ZH Controller. Should provide better feedback and align the logic? - Image files as hex written to
otasubdir of data dir, should be a bit cleaner. Files are auto-removed onunschedule, but not sure if we should also auto-remove on update end (tracing?)?
Note: we'll have to rebuild the all-settings page in docs for this one.
- Left a few TODOs, not all quite related to this specifically.
Replied!
- I modified
reInterview(previously only used if triggered by bridge request) to behave more like if it had been triggered from ZH Controller. Should provide better feedback and align the logic?
Look good
- Image files as hex written to
otasubdir of data dir, should be a bit cleaner. Files are auto-removed onunschedule, but not sure if we should also auto-remove on update end (tracing?)?
Let's keep them for now, these OTAs are fairly small so shouldn't be a problem.
Thank you so much! Now it is easier to update custom firmware such as ZigbeeTlc @pvvx, etc.