thomluther / anker-solix-api

Python library for Anker Solix API
MIT License
76 stars 15 forks source link

Add OTA update batch query to library and cache structure #138

Open thomluther opened 2 hours ago

thomluther commented 2 hours ago

Following query can probably list available firmware updates for a given device list when these are owner devices: await myapi.apisession.request("post", "app/ota/batch/check_update",json={"device_list": [{'device_sn': deviceSn, 'version': ''}]})

It seems the version can be an empty string, not clear what difference it makes to the output if a certain version is provided. Following is the example output for a solarbank 1 device which is on the latest firmware level.

{
  "code": 0,
  "msg": "success!",
  "data": {
    "update_infos": [
      {
        "device_sn": "AXS3B60D12306432",
        "need_update": false,
        "upgrade_type": 0,
        "lastPackage": {
          "product_code": "",
          "product_component": "",
          "version": "",
          "is_forced": false,
          "md5": "",
          "url": "",
          "size": 0
        },
        "change_log": "",
        "current_version": "v1.6.3",
        "children": null
      }
    ]
  },
  "trace_id": "d146e452b3f66c76e57a10c332e0906c"
}

To be tested how the output of this query looks like for multiple devices and when updates for a device is available. Hopefully the update firmware is listed in the lastPackage dictionary, so the version can be extracted. According to the structure, it may be possible the firmware updates can be enforced, so they will be applied independent of the auto-update settings?

thomluther commented 2 hours ago

As a first step, this batch query will be implemented in the refactored export class for v 2.2.0 Next steps include to add a helper method to drive this query for a list of serial numbers (or against the owning devices in the Api cache), and then use this method in the device_details poller method to add relevant fields to the Api device cache.