krahabb / meross_lan

Home Assistant integration for Meross devices
MIT License
455 stars 47 forks source link

Sensors for firmware versions #180

Closed uvjim closed 1 year ago

uvjim commented 2 years ago

I'm really not sure if this is possible but thought I'd ask anyway. Is it possible to expose sensors for the current firmware on a device and the latest available for the device. This would coincide with a binary sensor denoting that an update is available.

Doing this would could notify of update using an automation similar to what is possible with the sensors offered by the Supervisor integration.

I believe the current firmware should be accessible because that is currently tagged against the device. I'm just not sure if there's a way of getting that an update is required and what version it is.

Thanks in advance.

krahabb commented 2 years ago

Hello @uvjim , Exposing and checking the actual fw version would be easily achieved but I don't know any method to retrieve if any update is available from merosss cloud services. Even if this could be achieved, we would then have to understand how to trigger the update on the device itself (this too could be done maybe, I admit I've never investigated it) But in the end, since the meross app already consistently manages these updates, I prefer not to get into it since it might be 'destructive' if anything goes wrong without the right knowledge.

uvjim commented 2 years ago

@krahabb thanks for thinking about this. To be clear, I wasn't intending to actually carry out the update on the device, merely provide an insight that there was an update available.

I appreciate understanding an update available night be tricky though as that may not be possible to retrieve.

Thanks.

timnolte commented 2 years ago

I will chime in that in the case of a migration from Meros Cloud to Local Only, meaning I no longer have those devices in the App. It would be great if there was a way to update the firmware when in a Local Only mode. I do acknowledge though that without clear official documentation on doing this it could be destructive to the point of bricking devices. I can totally understand not wanting to be held responsible for that. If there were to be any official documentation for it then it would be an amazing option. I know with Zigbee2MQTT there is provision for managing firmware updates on devices. Having that capability with the Meross devices would be amazing.

krahabb commented 2 years ago

Beside any possible reasoning about the opportunity to update the devices I don't really know any source of information about the process..If I read something in the past I've completely forgot the process on how to get informations about latest firmware releases available and how to instruct the device in order to download and install these. If you (or anyone) could point me to a good source of informations that would 'jumpstart' me out of the recent lazyness ;)

lkubb commented 2 years ago

For the record, the iOS app seems to issue an authenticated POST request to the Meross API at /v1/Device/latestVersion with empty params. The server responds with

{
    "apiStatus": 0,
    "data": [
        {
            "alias": "",
            "description": "<changelog>",
            "mcu": [],
            "md5": "<md5 sum of firmware release>",
            "subType": "<eg region for smart plugs>",
            "type": "<device model>",
            "upgradeType": "02",
            "url": "http://static-file.meross.com/staticfile/<long decimal number>/<shorter decimal number>.bin",
            "version": "<firmware version>"
        }
    ],
    "info": "Success",
    "sysStatus": 0,
    "timeStamp": <timestamp>
}

There's also the Appliance.Control.Upgrade message that takes md5 and url as parameters.

I'm not sure how to get the latest firmware versions and their download URL for devices not paired with the Meross cloud though.

krahabb commented 2 years ago

This is very interesting..I'll try to investigate th eapi a bit and see if it can be used for the purpose

krahabb commented 2 years ago

Quick update: at the moment, I haven't found any solution for devices not paired with the meross cloud. As @lkubb pointed out, the HTTP api just works but only for paired devices. In my opinion it would be a waste trying to add firmware update features into HA that are already covered by the official meross app for paired devices. I doubt there would be any available api or browsable source of firmware binaries ready to be used for any (unpaired) device but I'll leave this open right now