mdeweerd / zha-toolkit

🧰 Zigbee Home Assistant Toolkit - service for "rare" Zigbee operations using ZHA on Home Assistant
GNU General Public License v3.0
190 stars 26 forks source link

Make use of zigpy's new "Manufacturer OTA Firmware Update Support" feature (also referred to as "*Generic OTA providers")? #196

Closed Hedda closed 1 year ago

Hedda commented 1 year ago

Re-post/cross-post of the same question asked here in Home Assistant's community forum -> https://community.home-assistant.io/t/zha-toolkit-a-big-set-of-zigbee-commands-on-top-of-zha-zigpy/373346/154

Wondering if you have looked at zha-toolkit using “Manufacturer OTA Firmware Update Support” (also referred to as “Generic OTA providers”) that was added with zigpy 0.56.3 release that was very recently bumped in Home Assistant core version 2023.8.1?

https://github.com/zigpy/zigpy/pull/1165

This new feature in zigpy (and ZHA) allows for new OTA providers to be added to zigpy without extra code, which in turn also allows for users and manufacturers to distribute test feed URLs to customers without deploying them globally.

https://github.com/zigpy/zigpy/wiki/OTA-Information-for-Manufacturers

I believe that this could for example enable users to easier add to for example grab Zigbee OTA firmware files from Koenkk’s Zigbee OTA repo → https://github.com/Koenkk/zigbee-OTA/blob/master/index.json (as requested here → https://github.com/zigpy/zigpy/issues/535)

PS: puddly also added a new feature to the "zigpy-cli" tool that manufacturers can use to produce/generate a skeleton index from a given set of OTA files, and that way makes sure manufacturers OTA files are correctly-structured so that they will be compatible with this new JSON format for zigpy OTA providers out-of-the-box. Check out the README.md for the "zigpy-cli" (zigpy CLI tool) -> https://github.com/zigpy/zigpy-cli/blob/dev/README.md#generate-ota-index-files

mdeweerd commented 1 year ago

The OTA update feature implemented in zha-toolkit fetches ota files references on Koenkk's repository.

Unless zigpy changes imply that zha-toolkit is no longer functional for that, zha-toolkit is still fine.

zha-toolkit is meant to complement zha, so as features appear in zha (/zigpy), there is no need to update/maintain all of them in zha-toolkit.

I leave this issue open because it is worth checking/ensuring that zha-toolkit's ota service also triggers fetching the ota binaries using zigpy's methods.

Hedda commented 1 year ago

zha-toolkit is meant to complement zha, so as features appear in zha (/zigpy), there is no need to update/maintain all of them in zha-toolkit.

I believe it could possibly make parts of zha-toolkit OTA update obsolete, at least the download part for Koenkk's zigbee-OTA repository at https://github.com/Koenkk/zigbee-OTA/ but it requires someone generating + maintaining a compatible index file.

That is, now that PR https://github.com/zigpy/zigpy/pull/1165 has been merged adding support for Generic OTA providers, can the wanted feature be achieved if would generate a JSON index file with zigpy-cli (https://github.com/zigpy/zigpy-cli/blob/dev/README.md#generate-ota-index-files) for the OTA images that are hosted on GitHub in Koenkk's zigbee-OTA repository at https://github.com/Koenkk/zigbee-OTA/ and if so then maybe Koenkk could be convinced to host such an alternative index in the same GitHub repository? An additional index file to https://github.com/Koenkk/zigbee-OTA/blob/master/index.json that instead follow zigpy's new JSON index file format as documented here in zigpy's wiki -> https://github.com/zigpy/zigpy/wiki/OTA-Information-for-Manufacturers

mdeweerd commented 1 year ago

I have now examined the zha-toolkit OTA code.

This confirms that as far as I still understand from the zha/zigpy code, the fact that zha-toolkit forces a refresh of the repositories and zigpy will initiate the download of the binary when it needs to provide an image to the device.

However, I extended the code so that it should trigger image downloads in zigpy explicitly.

This will be in a future release.