-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] OTA Support #154
Comments
Before any of this is actually useful, OTA upgrade files need to be obtained. I've posted my method for IKEA's products until they change things around. A generic solution would be to sniff the traffic, though it would be nicer to reverse engineer the methods used by each manufacturer-specific gateway to check and fetch updates. The only other devices I own are battery powered Xiaomi Aqara sensors and buttons. I've been sniffing both the Zigbee and network traffic of my Aqara gateway but it appears that the gateway does not check for OTA upgrades. Similarly, the Xiaomi cloud only sends back OTA upgrade files for mains-powered devices so I suspect there's little else to be done for the battery powered Xiaomi devices (though there seem to be efforts to create open-source firmware for them). If anybody has a Trådfri hub and is able to capture the firmware upgrade traffic of a RGB bulb (you need to just power cycle the bulb and wait for ~60 seconds) it would be really helpful. You can use Wireshark and the nRF52840 dongle ($10 + shipping from Mouser/Digikey) or the common HUSBZB-1. |
Well, your code inspired me to look into this more closely. Here's my initial approach which would require some cleaning https://github.com/Adminiuga/zigpy/tree/feature/ota And since we're still supporting Python 3.5, I made some changes to run it on py35. For firmware updates you are right, the easiest way is to leech it from the vendor hub, but distributing those firmwares probably wouldn't be welcome. Don't know, maybe baloob would be able to put some weight and make an agreement with some vendors to get access to their firmwares. Not sure how much vendors would be interested. |
That's a much cleaner approach. I do agree that it would be unwise to distribute the firmware upgrades in-tree although I'm not sure if an open HTTP endpoint like IKEA's falls in the same category. Honestly, while the Zigbee spec attempts to promote interoperability, it really has failed here. Everything but the actual firmware upload mechanism is left up to the vendor, which naturally leads to closed hubs. In an ideal world every Zigbee device would have a readable attribute part of its OTA cluster that returns an upgrade URL with a JSON response similar to IKEA's. We could also fork over $7k (or $75k) to join the Zigbee Alliance or nicely ask someone else to petition on our behalf for the inclusion of something this in a future version of the Zigbee spec. Also, SmartThings seems to perform OTA upgrades for IKEA and SYLVANIA bulbs so I guess a few vendors do share this info in the spirit of interoperability. I'm just hoping they will share it with us as well. |
Correct, kudos to IKEA. We're not distributing IKEA's firmware as they are kindly providing an endpoint do download it from.
JSON is not really needed, as all that info is in OTA file header. I need to add parser for that header (shouldn't be complicated with all Zigpy types) and then could add a "plain file" OTAProvider.
Yep, they do. It should be possible to join their network and pretend to be an endpoint and leech the firmware file. IMO manup from deConz did something like this in the past. |
I've added an OTA file parser and a better method for extracting the updates from the IKEA container in my branch that's tracking yours. I'll try to get a few more IKEA devices to test with and hopefully get everything working again in-tree. |
Ok, I'll do my best not to rebase my branch then, which means I may need to merge dev back into it. ATM i'm stuck at writing tests for |
This is so cool, I was worried I was going to have to buy a hub and move them across if I ever needed to update them. Is the samsung OTA a similar process? |
I tried out your branch @puddly , but it seemed to have some errors in it. |
@ryanwinter it's a WIP. I'm out of devices to upgrade and don't have the time right now to dogfood it but will do that when I get some more bulbs or switches. If you have an IKEA hub, capturing the upgrade process would be helpful for the RGB bulbs. |
Thanks @puddly. I don't have an RGB bulb yet, but was planning to buy some next time I visit IKEA. I have a ton of smartthings devices, so I might take a look at those. I have a HUSBZB-1, so I'll investigate how to snoop on the upgrade traffic. |
@puddly do we really need both |
@Adminiuga no, In its current form, What do you think about a new set of |
I've changed it a bit in IKEA firmare prefetch so
It crossed my mind. not a fan of the current sync-to-async triggering, but all cluster commands are currently |
@Adminiuga I'm hesitant to deploy code that sends 16 simultaneous HTTP requests on startup (and on every cache refresh), even for users who don't have Trådfri devices on their network. I'm aiming for a lazy approach that only hits IKEA's servers if a Trådfri device requests a firmware upgrade. For example:
Getting the event bus stuff right is pretty important. I've run into similar issues with my home automation system and have slowly replaced just about every sync method with an async one. I've removed the While changing things I also noticed that OTA clients really deal with two types of image signatures (
I've also reflected this addition to the I'll try to get everything actually running and write some thorough tests soon. |
Agreed.
Hrm, I concur on sync vs async, but not so sure about removing
Do you have reason to believe the
Makes sense. I just was impatient to test IKEA updates and had to have firmware ready. IMO for IKEA it should be perfectly fine, as I see them making a few requests even when getting NO_IMAGE_AVAILABLE response.
|
I'm just seeing what possible additions or modifications will make the most sense as the OTA implementation is finalized. I agree that the final version of the
The probability of that being violated is pretty low but it still makes me a little uneasy. Using
That's true. If I recall, my color temperature bulbs seem to make a series of four or five requests in quick succession after receiving a If nobody with an IKEA hub, a Zigbee sniffer, and some outdated RGB bulbs is available to help out, I'll have to buy an IKEA hub myself. I would rather not waste money on something I'm trying to avoid in the first place, though...
Very true. I was just looking over the Zigbee spec when checking the responses we send during the OTA process and stumbled upon that response type. It seemed useful if the |
Pushed new version to https://github.com/Adminiuga/zigpy/tree/feature/ota Disclaimer
Warning
But a downloaded IKEA OTA image in In this implementation we store only image headers for each provider with expiration (IKEA expires in 12 hours, file based OTA images expire in 24 hours), meaning every 12/24 hours providers will reload its images. OTA Handler itself caches images for 18 hours and extends expiration if there's activity for this particular image, so it does not expire in the middle of an upgrade. ** ToDo: **
|
oh, and BTW it does follow your proposal:
As I've added |
I have a bunch of older firmware bulbs. How do I test this? Do I just install this via pip? |
I see the following messages:
|
No update needed. Version on the bulb same as downloaded one. |
So checking back this morning, I saw a bunch of OTA upgrades which ended in a SUCCESS message. Looking through the bulbs, out of 7, 1 of them is still on an older version. Here is the start of the output of one upgrade. I do notice that the debug messages indicate that is downloading the firmware repeatedly (this message is repeated ~3000 times) I'm hoping this isn't the case, and it's reusing the same download :)
|
yeah, there are going to be tons of messages, cause you have to transfer about 160-200KB of data in 40 bytes chunks, so somewhere between 4096 and 5120 messages. Look for the upgrade end messages. After transfer finishes ( I'd say give some time (30 - 45min) after it finishes the transfer and issues |
for that 1 bulb which is still on the old version, check if you got "upgrade end" report from the bulb. If you did, try powercycling it. If it didn't finish the upgrade, it should check for the update again after a few minutes. |
The |
not really:
So you should see downloading from IKEA, only on the 1st attempt (in 18 hours) of querying the image with this particular manufacturer_id and image_type. In other words, providers will always download/load IMAGES if they are queried, but it shouldn't happen often because OTA holds a local cache for a time period. |
@puddly so for the color bulbs, it queries the image but never attempts to download it, correct? |
@Adminiuga I don't have the color ones any more but from what I recall yes, they send four or five queries but never progress any further. Some deCONZ users on GitHub made it seem like they were able to upgrade their bulbs so maybe mine were just on a really old firmware version. As for the downloads, @ryanwinter's log contains four HTTP requests for the OTA image, even though only bulb |
how many |
@Adminiuga just one. Here's a complete log (~2 minutes) of zigpy/bellows from the time a switch joins the network until I pulled the plug (ha) because too many requests were being sent: I'll try to debug it live later today. |
I have now submitted a PR for current ZHA docs -> home-assistant/home-assistant.io#13621 Mostly just copied @walthowd reddit post but tried to simplify by not mentioning debug steps. @walthowd perhaps you could submit a separate PR for debug steps but under "Troubleshooting"? |
Could it be a good idea to move OTA provider URL source information from zigpy to device quirks? https://github.com/zigpy/zha-device-handlers/ OTA provider URL source information could be seen as a device handlers? As I understand, zigbee-herdsman/zigbee2mqtt handle providers via zigbee-herdsman-converters? https://github.com/Koenkk/zigbee-herdsman-converters/tree/master/ota Thinking that it might be less intimidating for new developers to help with providers if it's in quirks? https://github.com/zigpy/zigpy/tree/dev/zigpy/ota Maybe also break providers out into separate code files for each provider source / manufacturer? |
@walthowd have you tried "source routing" yet?
|
Off-topic, but is explicitly setting |
I don't know, don't think source routing is supported by zigpy-cc module. ATM only bellows/ezsp has test support and there's alpha firmware for ConBee II But atm it does all src routing in firmware |
Would it maybe be a good idea if zha-device-handlers could provide custom 'OTA Provider' (OTAProvider) for Zigbee devices? Could make it easier to submit a new 'OTA Provider' to zha-device-handlers or add custom 'OTA Providers' without updating zigpy? Regardless, might it also be a good idea to split each 'OTA Provider' into a separate code file per manufacturer for readability? https://github.com/zigpy/zigpy/tree/dev/zigpy/ota Please see issue zigpy/zha-device-handlers#750 which raised this question as user posted a request for a new OTA Provider there. PS: I understand why ZHA users could today think that "ZHA Device Handlers" would now also handle 'OTA Providers' for zigpy. |
FYI, I started a new discussion about these specific questions/ideas here -> #654 |
EUROTRONIC Technology GmbH has recently started publishing official OTA firmware image releases on their GitHub repo here: https://github.com/EUROTRONIC-Technology/Spirit-ZigBee/releases So far is only an FW image is for their "Spirit ZigBee" (model "SPZB0001") product which is TVR (Thermostatic Radiator Valve) device: https://eurotronic.org/produkte/zigbee-heizkoerperthermostat/spirit-zigbee/ https://zigbee.blakadder.com/Eurotronic_SPZB0001.html https://www.zigbee2mqtt.io/devices/SPZB0001.html They have also created a wiki there and posted a guide on how to OTA update using deCONZ software from Dresden Elektronik: https://github.com/EUROTRONIC-Technology/Spirit-ZigBee/wiki/OTA-update-guide-via-deCONZ Plus the repos README.md also has a another guide for upgrading via Home Assistant if using their deCONZ integration: https://github.com/EUROTRONIC-Technology/Spirit-ZigBee/blob/main/README.md PS: Upgrading is recommended because "issues" -> https://github.com/EUROTRONIC-Technology/Spirit-ZigBee/issues |
FYI pipiche38 has begun an interesting project that is trying to get OTA firmware URL via info get from Wireshark Zigbee sniffing: |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions. |
This is maybe off topic, but are those parameters still required with the more recent stack ? |
With IKEA controllers and other sleepers its better forcing them using router instead of the coordinator (if having good router) and the sleepers is not losing the network then the coordinator id offline or doing TC things. Was 3 week offline then having holiday in Spain and the laptop was with and all devices was online in one hours the reconnecting it with the network then all router was "holding" the network all the time. Also using EZSP 6.7.8 or 6.10.X and not older or the bad 6.8 and 6.9 for having one stable network. PS: Source routing enabled with very high routers in the EZSP firmware. |
Implementing support for OTA upgrades would practically eliminate the need for unnecessary hubs. Below is the event listener I used to successfully upgrade six IKEA Trådfri 1000lm bulbs (copied from an unrelated issue):
The Trådfri remotes seem to work too. Unfortunately, I was not able to get my RGB bulbs to upgrade despite a newer firmware version being available so I believe further device quirks will need to be handled by https://github.com/dmulcahey/zha-device-handlers. The core OTA functionality, however, should belong in zigpy since it doesn't depend on any specific adapter interface and can basically be a transcription of the process described in the Zigbee specification (see pages 27+).
What do you think?
The text was updated successfully, but these errors were encountered: