aioshelly icon indicating copy to clipboard operation
aioshelly copied to clipboard

Get firmware info from Shelly update server

Open chemelli74 opened this issue 1 year ago • 10 comments

Retrieve the firmware version ( es. "20231219-133948/1.1.0-g34b5d4f") from the official URLs verified with Shelly.

This info will be used only to inform the users that a new version is available. Code doesn't retrieve any URL so no action can be performed on the device.

chemelli74 avatar Jan 15 '24 19:01 chemelli74

I am also against having this functionality in aioshelly. Albeit rare, devices may require specific upgrade paths for some older versions. If the wrong firmware is flashed on a device it may brick. Our update server gets identifying bits from the devices when they ask for new versions and takes the necessary steps for flashing intermediate versions.

We are discussing adding a public repository with stable and previous stable releases, but what you have now is not it.

kzyapkov avatar Jan 17 '24 09:01 kzyapkov

Albeit rare, devices may require specific upgrade paths for some older versions. If the wrong firmware is flashed on a device it may brick. Our update server gets identifying bits from the devices when they ask for new versions and takes the necessary steps for flashing intermediate versions.

@kzyapkov , this PR is not about flashing the firmware, but only retrieve the information of the latest available (thus the title). Is in charge to the user to flash it.

On the other hand, take care that we have a update firmware button in HA that will flash latest. This functionality is there since ages. So far, AFAIK, we didn't had a single report of a issue.

We are discussing adding a public repository with stable and previous stable releases, but what you have now is not it.

Nice! Thx.

chemelli74 avatar Jan 17 '24 10:01 chemelli74

On the other hand, take care that we have a update firmware button in HA that will flash latest. This functionality is there since ages. So far, AFAIK, we didn't had a single report of a issue.

As I already tried to explain on discord (which you try to ignore) when we ask the device to trigger an update we are not providing the firmware URL. We just trigger update to latest which is the same as the update button on the device web, the firmware URL is reported to the device based on multiple factors as @kzyapkov explained above.

I still insist we shouldn't provide any URL to the user, a simple example is Shelly RGBW2 which if uses the URL provided by this design will flash an incorrect firmware to the device (I can explain you the specific logic for this devices, but I don't know what is the logic in all devices), this is just one example and I am not sure how this will work for the entire install base and if there are other devices that can break.

thecode avatar Jan 17 '24 10:01 thecode

You could let devices fetch update info -- call Shelly.CheckForUpdate

kzyapkov avatar Jan 17 '24 11:01 kzyapkov

@thecode, please check the code. It DOESN'T fetch any url at all. It just retrieve the firmware build string, nothing else.

chemelli74 avatar Jan 17 '24 15:01 chemelli74

You could let devices fetch update info -- call Shelly.CheckForUpdate

The issue is linked to misconfigured devices that don't have internet access and don't notify the user of a new available firmware. The idea is just to make them aware a new version exist. But no action at all will ever be performed.

chemelli74 avatar Jan 17 '24 15:01 chemelli74

@thecode, @kzyapkov, sorry for the imprecision: I just noticed that I wrote "button" instead of "service".

What I wanted to focus is that we have a service in HA that can be used to flash device providing a URL to the OTA endpoint. If this can brick the device, we should that avoid the possibility to use custom URLs.

chemelli74 avatar Jan 17 '24 17:01 chemelli74

What I wanted to focus is that we have a service in HA that can be used to flash device providing a URL to the OTA endpoint.

There is url parameter in aioshelly for gen1 devices but we don't use it in the integration. So we only run the API methods to start an OTA update.

https://github.com/home-assistant/core/blob/83e0a7528d8052005c338530ceb430e52e3ce08a/homeassistant/components/shelly/update.py#L212

https://github.com/home-assistant/core/blob/83e0a7528d8052005c338530ceb430e52e3ce08a/homeassistant/components/shelly/update.py#L297

bieniu avatar Jan 18 '24 11:01 bieniu

What I wanted to focus is that we have a service in HA that can be used to flash device providing a URL to the OTA endpoint.

There is url parameter in aioshelly for gen1 devices but we don't use it in the integration. So we only run the API methods to start an OTA update.

Yes, if you look at the trigger_ota_update(), but the service itself allows the url parameter in its call. This means that a user can specify a custom url for update.

As this can in rare cases be a issue as @kzyapkov wrote, I just wanted to point it out.

chemelli74 avatar Jan 18 '24 11:01 chemelli74

but the service itself allows the url parameter in its call

Which service?

bieniu avatar Jan 18 '24 14:01 bieniu

I still think this simple notification (no action at all) could be very useful for all users that are not notified of a new firmware for whatever reason.

But Team decided not to go this way, so I close this PR.

chemelli74 avatar May 18 '24 10:05 chemelli74