thomluther / anker-solix-api

Python library for Anker Solix API
MIT License
38 stars 12 forks source link

Need helper function to change the home load #19

Closed thomluther closed 3 months ago

thomluther commented 4 months ago

A helper function is needed (also for Home Assistant integration) to simplify change of the set home load. Points to clarify and validate before this can be provided:

The help function should provide option switches for:

thomluther commented 4 months ago

The method also need to ensure to update the internal device dictionarie with the modified schedule for each solarbank device. This is important that changes are immediately reflected in the api data structures and not delay until next device details update cycle.

thomluther commented 4 months ago

The schedule slots are also different for single and dual bank setups which must be considered for the helper. Schedule slot with Single Solarbank in system

        {
          "id": 0,
          "start_time": "20:00",
          "end_time": "24:00",
          "turn_on": true,
          "appliance_loads": [
            {
              "id": 0,
              "name": "Benutzerdefiniert",
              "power": 100,
              "number": 1
            }
          ],
          "charge_priority": 80,
          "power_setting_mode": 1,
          "device_power_loads": [
            {
              "device_sn": "25MFU7OHZJTFGFSH",
              "power": 50
            }
          ]
        }

Schedule slot with Dual Solarbank in system

        {
          "id": 0,
          "start_time": "17:30",
          "end_time": "24:00",
          "turn_on": false,
          "appliance_loads": [
            {
              "id": 0,
              "name": "Benutzerdefiniert",
              "power": 170,
              "number": 1
            }
          ],
          "charge_priority": 80,
          "power_setting_mode": 1,
          "device_power_loads": [
            {
              "device_sn": "VQQDB61DTTZEPSVX",
              "power": 85
            },
            {
              "device_sn": "DG34YZMOHGOTW6W2",
              "power": 85
            }
          ]
        }
thomluther commented 4 months ago

First tests showed that the set_device_load endpoint accepts the new schedule without error, but it doesn't seem to get applied. Schedule modifications are only applied via the set_device_parm method. The parameter must always be the full schedule. Missing slots will automatically extended to complete a full day with the provided slots. The Power settings must only be applied to the appliance load dict. This will automatically be devided for the individual device power loads. They don't have to be provided for schedule modifications.

Important and modifyable parameters for a slot: "start_time": "17:30", "end_time": "24:00", "turn_on": false, "appliance_loads": [ { "power": 170, } ], "charge_priority": 80,

p4i1ipp commented 4 months ago

Maybe you can have a look in the npm module ankersolixe1600 - there is setting the homeload (or turning home feeding off) implemented.

thomluther commented 3 months ago

The mechanism for appliance load setting is understood and implemented in a helper function. App version 2.2.1 implemented new capabilities for dual solarbank setup to modify the load sharing. Default so far was 50% of appliance load. The new mechanism is not understood yet and I can't test it. It can be added at a later point when this is clear. I assume this is why the set_device_load endpoint was implemented. Maybe this works only for dual bank setups, and does nothing for single bank setup...