thomluther / anker-solix-api

Python library for Anker Solix API
MIT License
36 stars 9 forks source link

Add support for smartmeter device #106

Open thomluther opened 1 week ago

thomluther commented 1 week ago

This is a new device, but it must be validated how the API structure look like for the smartmeter . Is it included in the scene info response for the site? Does it need separate endpoints to get the values?

System export examples are needed with smartmeter devices included in the power system.

thealkly commented 6 days ago

first Values from the scene json. Unfortunatenly i can't login into my app. I'm not sure how to get the total grid consumption. Didn't find any matching value. But i will check again.

"home_load_power": "669" is the corrent power consumption from the grid. The value is displayed in the app. 
{
  "code": 0,
  "msg": "success!",
  "data": {
    "home_info": {
      "home_name": "Home",
      "home_img": "",
      "charging_power": "0.00",
      "power_unit": "W"
    },
    "solar_list": [],
    "pps_info": {
      "pps_list": [],
      "total_charging_power": "0.00",
      "power_unit": "W",
      "total_battery_power": "0.00",
      "updated_time": "",
      "pps_status": 0
    },
    "statistics": [
      {
        "type": "1",
        "total": "7.17",
        "unit": "kWh"
      },
      {
        "type": "2",
        "total": "7.15",
        "unit": "kg"
      },
      {
        "type": "3",
        "total": "2.87",
        "unit": "\u20ac"
      }
    ],
    "topology_type": "1",
    "solarbank_info": {
      "solarbank_list": [
        {
          "device_pn": "p",
          "device_sn": "SN",
          "device_name": "Solarbank 2 E1600 Pro",
          "device_img": "https://public-aiot-fra-prod.s3.dualstack.eu-central-1.amazonaws.com/anker-power/public/product/2024/05/24/iot-admin/5iJoq1dk63i47HuR/picl_A17C1_normal%281%29.png",
          "battery_power": "37",
          "bind_site_status": "",
          "charging_power": "0",
          "power_unit": "W",
          "charging_status": "6",
          "status": "1",
          "wireless_type": "1",
          "main_version": "",
          "photovoltaic_power": "0",
          "output_power": "0",
          "create_time": 1718626540,
          "set_load_power": "",
          "sub_package_num": 1,
          "output_cutoff_data": 10,
          "is_display": true
        }
      ],
      "total_charging_power": "0",
      "power_unit": "W",
      "charging_status": "0",
      "total_battery_power": "0.37",
      "updated_time": "2024-06-26 21:26:26",
      "total_photovoltaic_power": "0",
      "total_output_power": "0.00",
      "display_set_power": false,
      "battery_discharge_power": "0",
      "ac_power": "0",
      "to_home_load": "0",
      "is_display_data": true,
      "solar_power_1": "0",
      "solar_power_2": "0",
      "solar_power_3": "0",
      "solar_power_4": "0"
    },
    "retain_load": "200W",
    "scene_mode": 1,
    "home_load_power": "669",
    "updated_time": "01-01-0001 00:00:00",
    "power_site_type": 5,
    "site_id": "9b8e5636-f604-4249-844c-44c11cc110ad",
    "powerpanel_list": [],
    "grid_info": {
      "grid_list": [
        {
          "device_pn": "p",
          "device_sn": "SN",
          "device_name": "Smart Meter",
          "device_img": "",
          "create_time": 1718626744,
          "status": "1",
          "bind_site_status": "",
          "wireless_type": ""
        }
      ],
      "photovoltaic_to_grid_power": "0",
      "grid_to_home_power": "669",
      "grid_status": 0,
      "has_history_data": true
    },
    "is_downgrade": false,
    "error_code": 0,
    "smart_plug_info": null,
    "feature_switch": null
  },
  "trace_id": "ID"
}
thomluther commented 6 days ago

possible Interpretation:

"grid_info": {
"grid_list": [
{
"device_pn": "pn",
"device_sn": "SN",
"device_name": "Smart Meter",
"device_img": "",
"create_time": 1718626744,
"status": "1", => same cloud connection coding as for other devices (0/1)
"bind_site_status": "",
"wireless_type": "" => Missing, typically indicates the connected network type in relation to wifi list response
}
],
"photovoltaic_to_grid_power": "0", => grid export in W
"grid_to_home_power": "669", => grid import in W
"grid_status": 0, => translation table needed
"has_history_data": true => App indicator field to display extra tab for grid statistics?
},

A translation table for the grid_status is needed with possible codes seen and their actual meaning to the smart meter or grid, e.g. outage, connection loss, AI mode activation etc.