thomluther / anker-solix-api

Python library for Anker Solix API
MIT License
84 stars 17 forks source link

Add OTA children information to devices #152

Open thomluther opened 1 day ago

thomluther commented 1 day ago

The OTA batch response may contain children information for some devices. The key values should be added to the device details. example for SB2:

      {
        "device_sn": "VZZMLS8FNFZ5MTGG",
        "need_update": false,
        "upgrade_type": 1,
        "lastPackage": {
          "product_code": "A17C1",
          "product_component": "A17C1",
          "version": "v1.0.5.16",
          "is_forced": false,
          "md5": "40913018b3e542c0350e8815951e4a9c",
          "url": "https://public-aiot-fra-prod.s3.dualstack.eu-central-1.amazonaws.com/anker-power/public/ota/2024/09/06/iot-admin/kjBpvBvQClToxSV7/A17C1-A17C3_EUOTA_V1.0.5.16_20240904.bin",
          "size": 694272
        },
        "change_log": "",
        "current_version": "v1.0.5.16",
        "children": [
          {
            "needUpdate": false,
            "device_type": "A17C1_esp32",
            "rom_version_name": "v0.1.5.1",
            "force_upgrade": false,
            "full_package": {
              "file_path": "https://public-aiot-fra-prod.s3.dualstack.eu-central-1.amazonaws.com/anker-power/public/ota/2024/09/06/iot-admin/J7lALfvEQZIiqHyD/A17C1-A17C3_EUOTAWIFI_V0.1.5.1_20240828.bin",
              "file_size": 1270256,
              "file_md5": "578ac26febb55ee55ffe9dc6819b6c4a"
            },
            "change_log": "",
            "sub_current_version": ""
          },
          {
            "needUpdate": false,
            "device_type": "A17C1_mcu",
            "rom_version_name": "v1.0.5.16",
            "force_upgrade": false,
            "full_package": {
              "file_path": "https://public-aiot-fra-prod.s3.dualstack.eu-central-1.amazonaws.com/anker-power/public/ota/2024/09/06/iot-admin/w3ofT0NcpGF3IUcC/A17C1-A17C3_EUOTA_V1.0.5.16_20240904.bin",
              "file_size": 694272,
              "file_md5": "40913018b3e542c0350e8815951e4a9c"
            },
            "change_log": "",
            "sub_current_version": ""
          },
          {
            "needUpdate": false,
            "device_type": "A17C1_100Ah",
            "rom_version_name": "v0.1.9.1",
            "force_upgrade": false,
            "full_package": {
              "file_path": "https://public-aiot-fra-prod.s3.dualstack.eu-central-1.amazonaws.com/anker-power/public/ota/2024/09/06/iot-admin/mmCg3IkHt2YpF8TR/A17C1-A17C3_EUOTA_V0.1.9.1_20240904.bin",
              "file_size": 694272,
              "file_md5": "40913018b3e542c0350e8815951e4a9c"
            },
            "change_log": "",
            "sub_current_version": ""
          }
        ]
      }
thomluther commented 1 day ago

ota_children will be created as list with following information per child:

        "children": [
          {
            "needUpdate": false,
            "device_type": "A17C1_esp32",
            "rom_version_name": "v0.1.5.1",
            "force_upgrade": false,
          },

Furthermore, since only children may need an update but only the parent device is compared and flagged for OTA updates, the children field needUpdate will be merged into the overall device ota_update field. The HA integration can use the children list in the attributes of the ota_update entity to present the whole children list if necessary.