thomluther / hacs-anker-solix

Home Assistant integration for Anker Solix Power devices
MIT License
73 stars 2 forks source link

Does your Plugin Supprt the new Solix 2 Pro ? #60

Open xsasx opened 1 month ago

xsasx commented 1 month ago

Checklist

Is your feature request related to a problem? Please describe.

I want to know if your plugin support the new Solix 2 Pro ?

Describe the solution you'd like

I want to know if your plugin support the new Solix 2 Pro ?

Describe alternatives you've considered

I want to know if your plugin support the new Solix 2 Pro ?

Additional context

I want to know if your plugin support the new Solix 2 Pro ?

thomluther commented 1 month ago

Nope. And I have nothing in plan to enhance the integration for it, since I will neither have such a device, nor time to develop and test required enhancements.

scho0ck commented 1 month ago

I've preordered a Solix 2 Pro do you think it would be hard to implement? I'd guess the devices share the same api but then we'll only see that once devices start shipping.

Edit: For now I'm also just interested to get regular data from the inverter and battery I'll check the api once I receive my device.

thomluther commented 1 month ago

well, you need python skills and start with the Api libary first: https://github.com/thomluther/anker-solix-api Once you have a system in your account, you can use the export_system tool to get an extract of all data. The new solarbank may need/use additional endpoints to get more data, which are not used in the export tool yet. This data must be built into the api library dictionaries for site details and device details. Those dictionaries are used as base for the HA integration.

To enhance the integration, I recommend to setup a development environment as described here. Otherwise you will have little fun when enhancing integrations, since each change requires restart of the HA instance and you need debugging capabilities. That is nothing you want to do in your productive HA. The dev container in Visual Studio code also provide great help and simplification for this development work. But since Anker allows only a single owner account for the system, you cannot use it in your productive HA instance while using it in the dev container. You may have to switch each other more frequently between owner and shared account configuration, since shared account permissions also need to be validated when doing enhancements. Not every query works for shared accounts, but that is something you need to catch in the api library already by doing manual testing.

So its LOTS of work and testing, and only possible when you can access a real device in your account, since NOTHING is documented, and expect that reported api fields may have inconsistent values between various query types. That is something you need to figure out during testing and implement work arounds in the api library, which builds the consolidated device information dictionaries.

thomluther commented 1 month ago

What will become a challenge is the new schedule and preset changes. I expect it will use completely different schedule structures since weekdays are now definable per schedule and the endpoint to change the schedule may be also different. Solarbank 2 also does not seem to have same settings per interval like the old one, so the structure and changable fields per slot may be less. This would simplify the implementation of a new helper method to modify the solarbank 2 schedules (and manual settings if no smartreader is used).

scho0ck commented 1 month ago

It seems Anker has no interest in third party integrations as posted on their forum which means any effort being made could break forever at any given time. I've canceled my order as it is my requirement to have the device in HA including energy dashboard etc. hopefully in the future anker decides to release something.

thealkly commented 3 weeks ago

I just tested the new Solix 2 Pro with the current API version. It seems to retrieve some or all values, but there are issues with timing. As usual, you get significantly more sensor values than with the current app version.

For example, the SOC is transmitted correctly, but after a few minutes, a value of 0 is received, and then a few minutes later, the correct SOC is received again. This happens with many values like battery power, battery energy, solar power, and grid feed-in power. Daily solar kWh seems to work, as well as daily discharging in kWh.

If I find some spare time in the next few weeks, I will try to check the Python API and conduct some investigations. For now, I am very grateful that some data is already available in Home Assistant. With a simple template sensor, I could filter out the 0 values as a short workaround.

kitokirisaki commented 2 weeks ago

I switched from a dual Solix E1600 to the Solix 2 Pro today. Worked well with removing the configuration and changing to the new one. But like @thealkly already mentioned, it works perfectly well until the moments where the integration just receives nothing anymore.

image

For me, it looks like it's a firmware bug of the Solix 2 Pro, since the API does not have a timeout or something like that. It just shows a regular response, just with empty / null values.

I'm still not sure, but also don't know what data I should provide. Maybe @thomluther can tell me for what he is looking in detail.

Here are some parts of the debug log of HA:

2024-06-19 16:24:30.192 DEBUG (MainThread) [custom_components.anker_solix] Finished fetching anker_solix_has* data in 0.464 seconds (success: True)
2024-06-19 16:25:29.728 DEBUG (MainThread) [custom_components.anker_solix] Api Coordinator has* is updating sites 
2024-06-19 16:25:29.729 DEBUG (MainThread) [custom_components.anker_solix] Updating Sites data
2024-06-19 16:25:29.729 DEBUG (MainThread) [custom_components.anker_solix] Getting site list
2024-06-19 16:25:29.729 DEBUG (MainThread) [custom_components.anker_solix] Request Url: POST https://ankerpower-api-eu.anker.com/power_service/v1/site/get_site_list
2024-06-19 16:25:29.729 DEBUG (MainThread) [custom_components.anker_solix] Request Headers: {'Content-Type': 'application/json', 'Model-Type': 'DESKTOP', 'App-Name': 'anker_power', 'Os-Type': 'android', 'Country': 'DE', 'Timezone': 'GMT+02:00', 'x-auth-token': '<AUTH_TOKEN>', 'gtoken': '<G_TOKEN>'}
2024-06-19 16:25:29.729 DEBUG (MainThread) [custom_components.anker_solix] Request Body: None
2024-06-19 16:25:29.839 DEBUG (MainThread) [custom_components.anker_solix] has* request post https://ankerpower-api-eu.anker.com/power_service/v1/site/get_site_list response received
2024-06-19 16:25:29.839 DEBUG (MainThread) [custom_components.anker_solix] Response Headers: <CIMultiDictProxy('Date': 'Wed, 19 Jun 2024 14:25:29 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '347', 'Connection': 'keep-alive', 'Bizcode': '0', 'Trace': '6dcead252505fcaa14bd91c03e7f2d83', 'Traceparent': '00-6dcead252505fcaa14bd91c03e7f2d83-41cadc46a2cee314-00', 'Server': 'APISIX')>
2024-06-19 16:25:29.839 DEBUG (MainThread) [custom_components.anker_solix] Response Data: {'code': 0, 'msg': 'success!', 'data': {'site_list': [{'site_id': '<SIDE_ID>', 'site_name': 'Home', 'site_img': '', 'device_type_list': [3], 'ms_type': 2, 'power_site_type': 5, 'is_allow_delete': True, 'support_device_models': ['A17C1', 'A17X7', 'A17X8'], 'current_site_device_models': ['A17C1']}]}, 'trace_id': '6dcead252505fcaa14bd91c03e7f2d83'}
2024-06-19 16:25:29.839 DEBUG (MainThread) [custom_components.anker_solix] Getting scene info for site
2024-06-19 16:25:29.839 DEBUG (MainThread) [custom_components.anker_solix] Request Url: POST https://ankerpower-api-eu.anker.com/power_service/v1/site/get_scen_info
2024-06-19 16:25:29.839 DEBUG (MainThread) [custom_components.anker_solix] Request Headers: {'Content-Type': 'application/json', 'Model-Type': 'DESKTOP', 'App-Name': 'anker_power', 'Os-Type': 'android', 'Country': 'DE', 'Timezone': 'GMT+02:00', 'x-auth-token': '<AUTH_TOKEN>', 'gtoken': '<G_TOKEN>'}
2024-06-19 16:25:29.839 DEBUG (MainThread) [custom_components.anker_solix] Request Body: {'site_id': '<SIDE_ID>'}
2024-06-19 16:25:30.235 DEBUG (MainThread) [custom_components.anker_solix] has* request post https://ankerpower-api-eu.anker.com/power_service/v1/site/get_scen_info response received
2024-06-19 16:25:30.235 DEBUG (MainThread) [custom_components.anker_solix] Response Headers: <CIMultiDictProxy('Date': 'Wed, 19 Jun 2024 14:25:30 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '1790', 'Connection': 'keep-alive', 'Bizcode': '0', 'Trace': 'a396ecfd8e4aa303f197338edb60dfe9', 'Traceparent': '00-a396ecfd8e4aa303f197338edb60dfe9-207dea7870a000fc-00', 'Server': 'APISIX')>
2024-06-19 16:25:30.235 DEBUG (MainThread) [custom_components.anker_solix] Response Data: {'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': '0.57', 'unit': 'kWh'}, {'type': '2', 'total': '0.57', 'unit': 'kg'}, {'type': '3', 'total': '0.20', 'unit': '€'}], 'topology_type': '1', 'solarbank_info': {'solarbank_list': [{'device_pn': 'A17C1', 'device_sn': '<SERIAL_NUMBER>', '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': '67', 'bind_site_status': '', 'charging_power': '249', 'power_unit': 'W', 'charging_status': '0', 'status': '1', 'wireless_type': '1', 'main_version': '', 'photovoltaic_power': '137', 'output_power': '249', 'create_time': 1718799203, 'set_load_power': '', 'sub_package_num': 0, 'output_cutoff_data': 10, 'is_display': True}], 'total_charging_power': '0', 'power_unit': 'W', 'charging_status': '0', 'total_battery_power': '0.67', 'updated_time': '1970-01-01 00:00:00', 'total_photovoltaic_power': '137', 'total_output_power': '249.00', 'display_set_power': False, 'battery_discharge_power': '112', 'ac_power': '20', 'to_home_load': '229', 'is_display_data': True, 'solar_power_1': '69', 'solar_power_2': '68', 'solar_power_3': '0', 'solar_power_4': '0'}, 'retain_load': '250W', 'scene_mode': 3, 'home_load_power': '249', 'updated_time': '01-01-0001 00:00:00', 'power_site_type': 5, 'site_id': '<SIDE_ID>', 'powerpanel_list': [], 'grid_info': None, 'is_downgrade': False, 'error_code': 0, 'smart_plug_info': None, 'feature_switch': {'multi_pv': True}}, 'trace_id': 'a396ecfd8e4aa303f197338edb60dfe9'}
2024-06-19 16:25:30.236 DEBUG (MainThread) [custom_components.anker_solix] Api Coordinator has* request statistics: 132 last hour, 2 last minute
2024-06-19 16:25:30.236 DEBUG (MainThread) [custom_components.anker_solix] Coordinator has* data: {'2fb852e1-3d71-4ca0-bd5b-1cb2788844f2': {'type': 'system', 'site_info': {'site_id': '<SIDE_ID>', 'site_name': 'Home', 'site_img': '', 'device_type_list': [3], 'ms_type': 2, 'power_site_type': 5, 'is_allow_delete': True, 'support_device_models': ['A17C1', 'A17X7', 'A17X8'], 'current_site_device_models': ['A17C1']}, 'site_admin': False, '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': '0.57', 'unit': 'kWh'}, {'type': '2', 'total': '0.57', 'unit': 'kg'}, {'type': '3', 'total': '0.20', 'unit': '€'}], 'topology_type': '1', 'solarbank_info': {'solarbank_list': [{'device_pn': 'A17C1', 'device_sn': '<SERIAL_NUMBER>', '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': '67', 'bind_site_status': '', 'charging_power': '-112', 'power_unit': 'W', 'charging_status': '0', 'status': '1', 'wireless_type': '1', 'main_version': '', 'photovoltaic_power': '137', 'output_power': '249', 'create_time': 1718799203, 'set_load_power': '250', 'sub_package_num': 0, 'output_cutoff_data': 10, 'is_display': True, 'alias_name': 'Solarbank 2 E1600 Pro', 'current_home_load': '250'}], 'total_charging_power': '-112.0', 'power_unit': 'W', 'charging_status': '0', 'total_battery_power': '0.67', 'updated_time': '1970-01-01 00:00:00', 'total_photovoltaic_power': '137', 'total_output_power': '249.00', 'display_set_power': False, 'battery_discharge_power': '112', 'ac_power': '20', 'to_home_load': '229', 'is_display_data': True, 'solar_power_1': '69', 'solar_power_2': '68', 'solar_power_3': '0', 'solar_power_4': '0'}, 'retain_load': '250W', 'scene_mode': 3, 'home_load_power': '249', 'updated_time': '01-01-0001 00:00:00', 'power_site_type': 5, 'site_id': '<SIDE_ID>', 'powerpanel_list': [], 'grid_info': None, 'is_downgrade': False, 'error_code': 0, 'smart_plug_info': None, 'feature_switch': {'multi_pv': True}, 'site_details': {'has_unread_msg': False}}, '<SERIAL_NUMBER>': {'device_sn': '<SERIAL_NUMBER>', 'type': 'solarbank', 'site_id': '<SIDE_ID>', 'is_admin': False, 'device_pn': 'A17C1', 'battery_soc': '67', 'battery_capacity': '1056', 'battery_energy': '707', 'charging_power': '-112', 'power_unit': 'W', 'charging_status': '0', 'charging_status_desc': 'detection', 'status': '1', 'status_desc': 'online', 'wireless_type': '1', 'input_power': '137', 'output_power': '249', 'set_output_power': '250', 'power_cutoff': 10, 'alias': 'Solarbank 2 E1600 Pro', 'set_system_output_power': '250'}}

2024-06-19 16:25:30.236 DEBUG (MainThread) [custom_components.anker_solix] Finished fetching anker_solix_has* data in 0.507 seconds (success: True)
2024-06-19 16:26:29.729 DEBUG (MainThread) [custom_components.anker_solix] Api Coordinator has* is updating sites 
2024-06-19 16:26:29.730 DEBUG (MainThread) [custom_components.anker_solix] Updating Sites data
2024-06-19 16:26:29.730 DEBUG (MainThread) [custom_components.anker_solix] Getting site list
2024-06-19 16:26:29.730 DEBUG (MainThread) [custom_components.anker_solix] Request Url: POST https://ankerpower-api-eu.anker.com/power_service/v1/site/get_site_list
2024-06-19 16:26:29.730 DEBUG (MainThread) [custom_components.anker_solix] Request Headers: {'Content-Type': 'application/json', 'Model-Type': 'DESKTOP', 'App-Name': 'anker_power', 'Os-Type': 'android', 'Country': 'DE', 'Timezone': 'GMT+02:00', 'x-auth-token': '<AUTH_TOKEN>', 'gtoken': '<G_TOKEN>'}
2024-06-19 16:26:29.730 DEBUG (MainThread) [custom_components.anker_solix] Request Body: None
2024-06-19 16:26:29.827 DEBUG (MainThread) [custom_components.anker_solix] has* request post https://ankerpower-api-eu.anker.com/power_service/v1/site/get_site_list response received
2024-06-19 16:26:29.827 DEBUG (MainThread) [custom_components.anker_solix] Response Headers: <CIMultiDictProxy('Date': 'Wed, 19 Jun 2024 14:26:29 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '347', 'Connection': 'keep-alive', 'Bizcode': '0', 'Trace': 'd28c6e783b4629d3ca6a03b1282697ca', 'Traceparent': '00-d28c6e783b4629d3ca6a03b1282697ca-007893ea2f2a263f-00', 'Server': 'APISIX')>
2024-06-19 16:26:29.827 DEBUG (MainThread) [custom_components.anker_solix] Response Data: {'code': 0, 'msg': 'success!', 'data': {'site_list': [{'site_id': '<SIDE_ID>', 'site_name': 'Home', 'site_img': '', 'device_type_list': [3], 'ms_type': 2, 'power_site_type': 5, 'is_allow_delete': True, 'support_device_models': ['A17C1', 'A17X7', 'A17X8'], 'current_site_device_models': ['A17C1']}]}, 'trace_id': 'd28c6e783b4629d3ca6a03b1282697ca'}
2024-06-19 16:26:29.827 DEBUG (MainThread) [custom_components.anker_solix] Getting scene info for site
2024-06-19 16:26:29.827 DEBUG (MainThread) [custom_components.anker_solix] Request Url: POST https://ankerpower-api-eu.anker.com/power_service/v1/site/get_scen_info
2024-06-19 16:26:29.827 DEBUG (MainThread) [custom_components.anker_solix] Request Headers: {'Content-Type': 'application/json', 'Model-Type': 'DESKTOP', 'App-Name': 'anker_power', 'Os-Type': 'android', 'Country': 'DE', 'Timezone': 'GMT+02:00', 'x-auth-token': '<AUTH_TOKEN>', 'gtoken': '<G_TOKEN>'}
2024-06-19 16:26:29.827 DEBUG (MainThread) [custom_components.anker_solix] Request Body: {'site_id': '<SIDE_ID>'}
2024-06-19 16:26:30.219 DEBUG (MainThread) [custom_components.anker_solix] has* request post https://ankerpower-api-eu.anker.com/power_service/v1/site/get_scen_info response received
2024-06-19 16:26:30.220 DEBUG (MainThread) [custom_components.anker_solix] Response Headers: <CIMultiDictProxy('Date': 'Wed, 19 Jun 2024 14:26:30 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '1790', 'Connection': 'keep-alive', 'Bizcode': '0', 'Trace': '5ea2fec5b989521df82a53b46f1e09d0', 'Traceparent': '00-5ea2fec5b989521df82a53b46f1e09d0-bd951782b05e08df-00', 'Server': 'APISIX')>
2024-06-19 16:26:30.220 DEBUG (MainThread) [custom_components.anker_solix] Response Data: {'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': '0.57', 'unit': 'kWh'}, {'type': '2', 'total': '0.57', 'unit': 'kg'}, {'type': '3', 'total': '0.20', 'unit': '€'}], 'topology_type': '1', 'solarbank_info': {'solarbank_list': [{'device_pn': 'A17C1', 'device_sn': '<SERIAL_NUMBER>', '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': '67', 'bind_site_status': '', 'charging_power': '249', 'power_unit': 'W', 'charging_status': '0', 'status': '1', 'wireless_type': '1', 'main_version': '', 'photovoltaic_power': '137', 'output_power': '249', 'create_time': 1718799203, 'set_load_power': '', 'sub_package_num': 0, 'output_cutoff_data': 10, 'is_display': True}], 'total_charging_power': '0', 'power_unit': 'W', 'charging_status': '0', 'total_battery_power': '0.67', 'updated_time': '1970-01-01 00:00:00', 'total_photovoltaic_power': '137', 'total_output_power': '249.00', 'display_set_power': False, 'battery_discharge_power': '112', 'ac_power': '20', 'to_home_load': '229', 'is_display_data': True, 'solar_power_1': '69', 'solar_power_2': '68', 'solar_power_3': '0', 'solar_power_4': '0'}, 'retain_load': '250W', 'scene_mode': 3, 'home_load_power': '249', 'updated_time': '01-01-0001 00:00:00', 'power_site_type': 5, 'site_id': '<SIDE_ID>', 'powerpanel_list': [], 'grid_info': None, 'is_downgrade': False, 'error_code': 0, 'smart_plug_info': None, 'feature_switch': {'multi_pv': True}}, 'trace_id': '5ea2fec5b989521df82a53b46f1e09d0'}
2024-06-19 16:26:30.220 DEBUG (MainThread) [custom_components.anker_solix] Api Coordinator has* request statistics: 134 last hour, 3 last minute
2024-06-19 16:26:30.220 DEBUG (MainThread) [custom_components.anker_solix] Coordinator has* data: {'2fb852e1-3d71-4ca0-bd5b-1cb2788844f2': {'type': 'system', 'site_info': {'site_id': '<SIDE_ID>', 'site_name': 'Home', 'site_img': '', 'device_type_list': [3], 'ms_type': 2, 'power_site_type': 5, 'is_allow_delete': True, 'support_device_models': ['A17C1', 'A17X7', 'A17X8'], 'current_site_device_models': ['A17C1']}, 'site_admin': False, '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': '0.57', 'unit': 'kWh'}, {'type': '2', 'total': '0.57', 'unit': 'kg'}, {'type': '3', 'total': '0.20', 'unit': '€'}], 'topology_type': '1', 'solarbank_info': {'solarbank_list': [{'device_pn': 'A17C1', 'device_sn': '<SERIAL_NUMBER>', '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': '67', 'bind_site_status': '', 'charging_power': '-112', 'power_unit': 'W', 'charging_status': '0', 'status': '1', 'wireless_type': '1', 'main_version': '', 'photovoltaic_power': '137', 'output_power': '249', 'create_time': 1718799203, 'set_load_power': '250', 'sub_package_num': 0, 'output_cutoff_data': 10, 'is_display': True, 'alias_name': 'Solarbank 2 E1600 Pro', 'current_home_load': '250'}], 'total_charging_power': '-112.0', 'power_unit': 'W', 'charging_status': '0', 'total_battery_power': '0.67', 'updated_time': '1970-01-01 00:00:00', 'total_photovoltaic_power': '137', 'total_output_power': '249.00', 'display_set_power': False, 'battery_discharge_power': '112', 'ac_power': '20', 'to_home_load': '229', 'is_display_data': True, 'solar_power_1': '69', 'solar_power_2': '68', 'solar_power_3': '0', 'solar_power_4': '0'}, 'retain_load': '250W', 'scene_mode': 3, 'home_load_power': '249', 'updated_time': '01-01-0001 00:00:00', 'power_site_type': 5, 'site_id': '<SIDE_ID>', 'powerpanel_list': [], 'grid_info': None, 'is_downgrade': False, 'error_code': 0, 'smart_plug_info': None, 'feature_switch': {'multi_pv': True}, 'site_details': {'has_unread_msg': False}}, '<SERIAL_NUMBER>': {'device_sn': '<SERIAL_NUMBER>', 'type': 'solarbank', 'site_id': '<SIDE_ID>', 'is_admin': False, 'device_pn': 'A17C1', 'battery_soc': '67', 'battery_capacity': '1056', 'battery_energy': '707', 'charging_power': '-112', 'power_unit': 'W', 'charging_status': '0', 'charging_status_desc': 'detection', 'status': '1', 'status_desc': 'online', 'wireless_type': '1', 'input_power': '137', 'output_power': '249', 'set_output_power': '250', 'power_cutoff': 10, 'alias': 'Solarbank 2 E1600 Pro', 'set_system_output_power': '250'}}

2024-06-19 16:26:30.220 DEBUG (MainThread) [custom_components.anker_solix] Finished fetching anker_solix_has* data in 0.490 seconds (success: True)
2024-06-19 16:27:29.728 DEBUG (MainThread) [custom_components.anker_solix] Api Coordinator has* is updating sites 
2024-06-19 16:27:29.728 DEBUG (MainThread) [custom_components.anker_solix] Updating Sites data
2024-06-19 16:27:29.728 DEBUG (MainThread) [custom_components.anker_solix] Getting site list
2024-06-19 16:27:29.728 DEBUG (MainThread) [custom_components.anker_solix] Request Url: POST https://ankerpower-api-eu.anker.com/power_service/v1/site/get_site_list
2024-06-19 16:27:29.728 DEBUG (MainThread) [custom_components.anker_solix] Request Headers: {'Content-Type': 'application/json', 'Model-Type': 'DESKTOP', 'App-Name': 'anker_power', 'Os-Type': 'android', 'Country': 'DE', 'Timezone': 'GMT+02:00', 'x-auth-token': '<AUTH_TOKEN>', 'gtoken': '<G_TOKEN>'}
2024-06-19 16:27:29.728 DEBUG (MainThread) [custom_components.anker_solix] Request Body: None
2024-06-19 16:27:29.825 DEBUG (MainThread) [custom_components.anker_solix] has* request post https://ankerpower-api-eu.anker.com/power_service/v1/site/get_site_list response received
2024-06-19 16:27:29.825 DEBUG (MainThread) [custom_components.anker_solix] Response Headers: <CIMultiDictProxy('Date': 'Wed, 19 Jun 2024 14:27:29 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '347', 'Connection': 'keep-alive', 'Bizcode': '0', 'Trace': 'd02a860b24d3372976b48c2403b8ff4e', 'Traceparent': '00-d02a860b24d3372976b48c2403b8ff4e-0b9d2b9d16ee0bfe-00', 'Server': 'APISIX')>
2024-06-19 16:27:29.825 DEBUG (MainThread) [custom_components.anker_solix] Response Data: {'code': 0, 'msg': 'success!', 'data': {'site_list': [{'site_id': '<SIDE_ID>', 'site_name': 'Home', 'site_img': '', 'device_type_list': [3], 'ms_type': 2, 'power_site_type': 5, 'is_allow_delete': True, 'support_device_models': ['A17C1', 'A17X7', 'A17X8'], 'current_site_device_models': ['A17C1']}]}, 'trace_id': 'd02a860b24d3372976b48c2403b8ff4e'}
2024-06-19 16:27:29.825 DEBUG (MainThread) [custom_components.anker_solix] Getting scene info for site
2024-06-19 16:27:29.825 DEBUG (MainThread) [custom_components.anker_solix] Request Url: POST https://ankerpower-api-eu.anker.com/power_service/v1/site/get_scen_info
2024-06-19 16:27:29.825 DEBUG (MainThread) [custom_components.anker_solix] Request Headers: {'Content-Type': 'application/json', 'Model-Type': 'DESKTOP', 'App-Name': 'anker_power', 'Os-Type': 'android', 'Country': 'DE', 'Timezone': 'GMT+02:00', 'x-auth-token': '<AUTH_TOKEN>', 'gtoken': '<G_TOKEN>'}
2024-06-19 16:27:29.825 DEBUG (MainThread) [custom_components.anker_solix] Request Body: {'site_id': '<SIDE_ID>'}
2024-06-19 16:27:30.216 DEBUG (MainThread) [custom_components.anker_solix] has* request post https://ankerpower-api-eu.anker.com/power_service/v1/site/get_scen_info response received
2024-06-19 16:27:30.216 DEBUG (MainThread) [custom_components.anker_solix] Response Headers: <CIMultiDictProxy('Date': 'Wed, 19 Jun 2024 14:27:30 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '1776', 'Connection': 'keep-alive', 'Bizcode': '0', 'Trace': 'ae36bfc64ce6864cf17137a0260c34e2', 'Traceparent': '00-ae36bfc64ce6864cf17137a0260c34e2-2b032c6ef936faef-00', 'Server': 'APISIX')>
2024-06-19 16:27:30.216 DEBUG (MainThread) [custom_components.anker_solix] Response Data: {'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': '0.58', 'unit': 'kWh'}, {'type': '2', 'total': '0.58', 'unit': 'kg'}, {'type': '3', 'total': '0.20', 'unit': '€'}], 'topology_type': '1', 'solarbank_info': {'solarbank_list': [{'device_pn': 'A17C1', 'device_sn': '<SERIAL_NUMBER>', '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': '67', 'bind_site_status': '', 'charging_power': '250', 'power_unit': 'W', 'charging_status': '1', 'status': '1', 'wireless_type': '1', 'main_version': '', 'photovoltaic_power': '136', 'output_power': '250', 'create_time': 1718799203, 'set_load_power': '', 'sub_package_num': 0, 'output_cutoff_data': 10, 'is_display': True}], 'total_charging_power': '0', 'power_unit': 'W', 'charging_status': '0', 'total_battery_power': '0.67', 'updated_time': '2024-06-19 16:26:50', 'total_photovoltaic_power': '136', 'total_output_power': '250.00', 'display_set_power': False, 'battery_discharge_power': '114', 'ac_power': '0', 'to_home_load': '250', 'is_display_data': True, 'solar_power_1': '69', 'solar_power_2': '67', 'solar_power_3': '0', 'solar_power_4': '0'}, 'retain_load': '250W', 'scene_mode': 3, 'home_load_power': '250', 'updated_time': '01-01-0001 00:00:00', 'power_site_type': 5, 'site_id': '<SIDE_ID>', 'powerpanel_list': [], 'grid_info': None, 'is_downgrade': False, 'error_code': 0, 'smart_plug_info': None, 'feature_switch': None}, 'trace_id': 'ae36bfc64ce6864cf17137a0260c34e2'}
2024-06-19 16:27:30.216 DEBUG (MainThread) [custom_components.anker_solix] Api Coordinator has* request statistics: 136 last hour, 3 last minute
2024-06-19 16:27:30.216 DEBUG (MainThread) [custom_components.anker_solix] Coordinator has* data: {'2fb852e1-3d71-4ca0-bd5b-1cb2788844f2': {'type': 'system', 'site_info': {'site_id': '<SIDE_ID>', 'site_name': 'Home', 'site_img': '', 'device_type_list': [3], 'ms_type': 2, 'power_site_type': 5, 'is_allow_delete': True, 'support_device_models': ['A17C1', 'A17X7', 'A17X8'], 'current_site_device_models': ['A17C1']}, 'site_admin': False, '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': '0.58', 'unit': 'kWh'}, {'type': '2', 'total': '0.58', 'unit': 'kg'}, {'type': '3', 'total': '0.20', 'unit': '€'}], 'topology_type': '1', 'solarbank_info': {'solarbank_list': [{'device_pn': 'A17C1', 'device_sn': '<SERIAL_NUMBER>', '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': '67', 'bind_site_status': '', 'charging_power': '-114', 'power_unit': 'W', 'charging_status': '1', 'status': '1', 'wireless_type': '1', 'main_version': '', 'photovoltaic_power': '136', 'output_power': '250', 'create_time': 1718799203, 'set_load_power': '250', 'sub_package_num': 0, 'output_cutoff_data': 10, 'is_display': True, 'alias_name': 'Solarbank 2 E1600 Pro', 'current_home_load': '250'}], 'total_charging_power': '-114.0', 'power_unit': 'W', 'charging_status': '0', 'total_battery_power': '0.67', 'updated_time': '2024-06-19 16:26:50', 'total_photovoltaic_power': '136', 'total_output_power': '250.00', 'display_set_power': False, 'battery_discharge_power': '114', 'ac_power': '0', 'to_home_load': '250', 'is_display_data': True, 'solar_power_1': '69', 'solar_power_2': '67', 'solar_power_3': '0', 'solar_power_4': '0'}, 'retain_load': '250W', 'scene_mode': 3, 'home_load_power': '250', 'updated_time': '01-01-0001 00:00:00', 'power_site_type': 5, 'site_id': '<SIDE_ID>', 'powerpanel_list': [], 'grid_info': None, 'is_downgrade': False, 'error_code': 0, 'smart_plug_info': None, 'feature_switch': None, 'site_details': {'has_unread_msg': False}}, '<SERIAL_NUMBER>': {'device_sn': '<SERIAL_NUMBER>', 'type': 'solarbank', 'site_id': '<SIDE_ID>', 'is_admin': False, 'device_pn': 'A17C1', 'battery_soc': '67', 'battery_capacity': '1056', 'battery_energy': '707', 'charging_power': '-114', 'power_unit': 'W', 'charging_status': '1', 'charging_status_desc': 'bypass', 'status': '1', 'status_desc': 'online', 'wireless_type': '1', 'input_power': '136', 'output_power': '250', 'set_output_power': '250', 'power_cutoff': 10, 'alias': 'Solarbank 2 E1600 Pro', 'set_system_output_power': '250'}}

2024-06-19 16:27:30.216 DEBUG (MainThread) [custom_components.anker_solix] Finished fetching anker_solix_has* data in 0.488 seconds (success: True)
2024-06-19 16:28:29.729 DEBUG (MainThread) [custom_components.anker_solix] Api Coordinator has* is updating sites 
2024-06-19 16:28:29.729 DEBUG (MainThread) [custom_components.anker_solix] Updating Sites data
2024-06-19 16:28:29.729 DEBUG (MainThread) [custom_components.anker_solix] Getting site list
2024-06-19 16:28:29.729 DEBUG (MainThread) [custom_components.anker_solix] Request Url: POST https://ankerpower-api-eu.anker.com/power_service/v1/site/get_site_list
2024-06-19 16:28:29.729 DEBUG (MainThread) [custom_components.anker_solix] Request Headers: {'Content-Type': 'application/json', 'Model-Type': 'DESKTOP', 'App-Name': 'anker_power', 'Os-Type': 'android', 'Country': 'DE', 'Timezone': 'GMT+02:00', 'x-auth-token': '<AUTH_TOKEN>', 'gtoken': '<G_TOKEN>'}
2024-06-19 16:28:29.729 DEBUG (MainThread) [custom_components.anker_solix] Request Body: None
2024-06-19 16:28:29.805 DEBUG (MainThread) [custom_components.anker_solix] has* request post https://ankerpower-api-eu.anker.com/power_service/v1/site/get_site_list response received
2024-06-19 16:28:29.805 DEBUG (MainThread) [custom_components.anker_solix] Response Headers: <CIMultiDictProxy('Date': 'Wed, 19 Jun 2024 14:28:29 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '347', 'Connection': 'keep-alive', 'Bizcode': '0', 'Trace': 'c4d30f0a2f6786369e75d16367c2919d', 'Traceparent': '00-c4d30f0a2f6786369e75d16367c2919d-c4173d43aa313002-00', 'Server': 'APISIX')>
2024-06-19 16:28:29.805 DEBUG (MainThread) [custom_components.anker_solix] Response Data: {'code': 0, 'msg': 'success!', 'data': {'site_list': [{'site_id': '<SIDE_ID>', 'site_name': 'Home', 'site_img': '', 'device_type_list': [3], 'ms_type': 2, 'power_site_type': 5, 'is_allow_delete': True, 'support_device_models': ['A17C1', 'A17X7', 'A17X8'], 'current_site_device_models': ['A17C1']}]}, 'trace_id': 'c4d30f0a2f6786369e75d16367c2919d'}
2024-06-19 16:28:29.805 DEBUG (MainThread) [custom_components.anker_solix] Getting scene info for site
2024-06-19 16:28:29.805 DEBUG (MainThread) [custom_components.anker_solix] Request Url: POST https://ankerpower-api-eu.anker.com/power_service/v1/site/get_scen_info
2024-06-19 16:28:29.805 DEBUG (MainThread) [custom_components.anker_solix] Request Headers: {'Content-Type': 'application/json', 'Model-Type': 'DESKTOP', 'App-Name': 'anker_power', 'Os-Type': 'android', 'Country': 'DE', 'Timezone': 'GMT+02:00', 'x-auth-token': '<AUTH_TOKEN>', 'gtoken': '<G_TOKEN>'}
2024-06-19 16:28:29.805 DEBUG (MainThread) [custom_components.anker_solix] Request Body: {'site_id': '<SIDE_ID>'}
2024-06-19 16:28:30.179 DEBUG (MainThread) [custom_components.anker_solix] has* request post https://ankerpower-api-eu.anker.com/power_service/v1/site/get_scen_info response received
2024-06-19 16:28:30.179 DEBUG (MainThread) [custom_components.anker_solix] Response Headers: <CIMultiDictProxy('Date': 'Wed, 19 Jun 2024 14:28:30 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '1759', 'Connection': 'keep-alive', 'Bizcode': '0', 'Trace': '897eee47254f760a816e56d4b6cff39c', 'Traceparent': '00-897eee47254f760a816e56d4b6cff39c-4e82e6f0f6b6f32f-00', 'Server': 'APISIX')>
2024-06-19 16:28:30.179 DEBUG (MainThread) [custom_components.anker_solix] Response Data: {'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': '0.58', 'unit': 'kWh'}, {'type': '2', 'total': '0.58', 'unit': 'kg'}, {'type': '3', 'total': '0.20', 'unit': '€'}], 'topology_type': '1', 'solarbank_info': {'solarbank_list': [{'device_pn': 'A17C1', 'device_sn': '<SERIAL_NUMBER>', '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': '0', 'bind_site_status': '', 'charging_power': '0', 'power_unit': 'W', 'charging_status': '0', 'status': '1', 'wireless_type': '1', 'main_version': '', 'photovoltaic_power': '0', 'output_power': '0', 'create_time': 1718799203, 'set_load_power': '', 'sub_package_num': 0, 'output_cutoff_data': 10, 'is_display': False}], 'total_charging_power': '0', 'power_unit': 'W', 'charging_status': '0', 'total_battery_power': '0.00', 'updated_time': '1970-01-01 00:00:00', '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': False, 'solar_power_1': '0', 'solar_power_2': '0', 'solar_power_3': '0', 'solar_power_4': '0'}, 'retain_load': '250W', 'scene_mode': 0, 'home_load_power': '0', 'updated_time': '01-01-0001 00:00:00', 'power_site_type': 5, 'site_id': '<SIDE_ID>', 'powerpanel_list': [], 'grid_info': None, 'is_downgrade': False, 'error_code': 0, 'smart_plug_info': None, 'feature_switch': None}, 'trace_id': '897eee47254f760a816e56d4b6cff39c'}
2024-06-19 16:28:30.179 DEBUG (MainThread) [custom_components.anker_solix] Api Coordinator has* request statistics: 138 last hour, 3 last minute
2024-06-19 16:28:30.179 DEBUG (MainThread) [custom_components.anker_solix] Coordinator has* data: {'2fb852e1-3d71-4ca0-bd5b-1cb2788844f2': {'type': 'system', 'site_info': {'site_id': '<SIDE_ID>', 'site_name': 'Home', 'site_img': '', 'device_type_list': [3], 'ms_type': 2, 'power_site_type': 5, 'is_allow_delete': True, 'support_device_models': ['A17C1', 'A17X7', 'A17X8'], 'current_site_device_models': ['A17C1']}, 'site_admin': False, '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': '0.58', 'unit': 'kWh'}, {'type': '2', 'total': '0.58', 'unit': 'kg'}, {'type': '3', 'total': '0.20', 'unit': '€'}], 'topology_type': '1', 'solarbank_info': {'solarbank_list': [{'device_pn': 'A17C1', 'device_sn': '<SERIAL_NUMBER>', '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': '0', 'bind_site_status': '', 'charging_power': '0', 'power_unit': 'W', 'charging_status': '0', 'status': '1', 'wireless_type': '1', 'main_version': '', 'photovoltaic_power': '0', 'output_power': '0', 'create_time': 1718799203, 'set_load_power': '250', 'sub_package_num': 0, 'output_cutoff_data': 10, 'is_display': False, 'alias_name': 'Solarbank 2 E1600 Pro', 'current_home_load': '250'}], 'total_charging_power': '0', 'power_unit': 'W', 'charging_status': '0', 'total_battery_power': '0.00', 'updated_time': '1970-01-01 00:00:00', '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': False, 'solar_power_1': '0', 'solar_power_2': '0', 'solar_power_3': '0', 'solar_power_4': '0'}, 'retain_load': '250W', 'scene_mode': 0, 'home_load_power': '0', 'updated_time': '01-01-0001 00:00:00', 'power_site_type': 5, 'site_id': '<SIDE_ID>', 'powerpanel_list': [], 'grid_info': None, 'is_downgrade': False, 'error_code': 0, 'smart_plug_info': None, 'feature_switch': None, 'site_details': {'has_unread_msg': False}}, '<SERIAL_NUMBER>': {'device_sn': '<SERIAL_NUMBER>', 'type': 'solarbank', 'site_id': '<SIDE_ID>', 'is_admin': False, 'device_pn': 'A17C1', 'battery_soc': '0', 'battery_capacity': '1056', 'battery_energy': '0', 'charging_power': '0', 'power_unit': 'W', 'charging_status': '0', 'charging_status_desc': 'detection', 'status': '1', 'status_desc': 'online', 'wireless_type': '1', 'input_power': '0', 'output_power': '0', 'set_output_power': '250', 'power_cutoff': 10, 'alias': 'Solarbank 2 E1600 Pro', 'set_system_output_power': '250'}}
2024-06-19 16:28:30.179 DEBUG (MainThread) [custom_components.anker_solix] Finished fetching anker_solix_has* data in 0.450 seconds (success: True)
Disane87 commented 1 week ago

I got my Solix 2 pro today and can assist if some testers/coders are needed :)

thomluther commented 1 week ago

The last query in the debug data is showing that the API really returns 0 values for most fields. They are interpreted as is, since it must be considered these are the real values. Seems to be a cloud bug that it is sometimes providing 0 values in queries... On the other hand, if you look closely there is a new field that is set false only for the 0 value response: 'is_display_data': True/False That could be used by the library to judge whether the values should be updated or not. But the problem is that values will become stale as long as the response does not return valid data and users will not be aware that they are stale.... So the better approach would be to empty the fields in the Api cache if the response does not have valid data (field is false). This would make missing data obvious, and in HA the entities will render unavailable while no valid data is received.

thomluther commented 1 week ago

@kitokirisaki , any idea what the field 'ac_power': '20' could mean in your debug data while the output power to home is 100 or higher?

kitokirisaki commented 1 week ago

@kitokirisaki , any idea what the field 'ac_power': '20' could mean in your debug data while the output power to home is 100 or higher?

No, sadly I don't know what it could mean. But I will keep an eye on it maybe I will figure it out :)

Disane87 commented 1 week ago

I used the solarbank_monitoring.py of the python lib and it really seems that these values are directly 0 from the api. IMHO these values are only 0 when the charge status is detection:

Solarbank Monitor (refresh 60 s, details refresh 600 s):
Sites: 1, Devices: 1,           Data-Updated: 1970-01-01 00:00:00
Device         : NoName                  Alias         : Unterstand
Serialnumber   : [redacted]              Admin         : NO
Site ID        : [redacted]
Wifi SSID      :
Wifi state     : Unknown                 Signal        :  --- %
SW Version     : Unknown                 Auto-Upgrade  : Unknown
Cloud Status   : online                  Status code   : 1
Charge Status  : detection               Status code   : 0
State Of Charge:    0 %                  Min SOC       :   10 %
Battery Energy :    0 Wh                 Capacity      : 1600 Wh
Solar Power    :    0 W                  Output Power  :    0 W
Charge Power   :    0 W                  Device Preset :  200 W

Api Requests: 9 last hour, 4 last minute
Site refresh:  46 sec,  Device details refresh: 525 sec  (CTRL-C to abort)

Would it be a possible solution the skip the entity update while the status is detection or will this distort the value calculation for example in the energy dashboard?

thomluther commented 1 week ago

The status description 'Detection' is just my translation in the library for a status code 0. This is 0 like all other values, so it cannot be used as differenciator. When value updates are skipped, they will be stale for each query interval until good data is received again. This is not a good approach I think. I would rather set them to None to make it visible in the entity history when false data is received. Eventually for Solarbank 2 the query interval must be reduced, since that probably updates the cloud more often. Did you test the Monitor tool with 10s refresh? Do the data update that frequently? When valid data is received, you see a data-updated timestamp as well. This is when the solarbank sent the data to the cloud. Question is how much of delay does that have to the query time as maximum when Solarbank is working? Solarbank1 was sending every 60 seconds, so how often does Solarbank 2 send data? In Standby mode it does not send updates that frequently.

If that is for example every 10 seconds, the query interval could be reduced to 10 sec, but this will not eliminate responses with false data. However there could be more frequent queries that return valid data. So if there are typically 3-4 false responses and 1-2 correct responses within a minute as average, the false could simply be skipped to have at least one reliable data update within a minute.

TobTkyDev commented 1 week ago

I have the same behavior with my integration. Roughly every 4mins it will send valid data. Bildschirmfoto 2024-06-24 um 11 49 47

thomluther commented 1 week ago

You need to understand the frequency and intervals of invalid responses in relation to the frequency the data is queried. When the API queries only once per minute, it could query at a time where the cloud is just refreshing the data from the device and therefore not send valid data on a request. If the device is sending data in shorter intervals, there are higher chances that a 60 sec query hits such a cloud update period. So various update intervals must be validated to understand:

When those metrics are known, then the query interval can maybe be adjusted around those metrics to reduce number of false responses when solarbank 2 is used. For other devices, it does not make sense to query in less than 60 seconds. Any interval reduction will further increase the cloud server traffic significantly (24*7). When query interval time is reduced, the multiplier for the device details intervals must be increased at same time. Doesn't make sense to run those many queries in less than 10 minute intervals.

nicolinuxfr commented 1 week ago

I also have a Solix 2 Pro installed and I enjoy this integration, even if I also have noticed the bug with 0 values sent regularly. Fortunately, Home Assistant is showing a somewhat correct line in the graphs :

Capture d’écran 2024-06-24 à 17 17 09

I am no developper but if I can help expand the integration, it will be my pleasure.

The two items I'm missing the most are the electricity returned to the grid which is always 0 W (though I have installed Anker's Smart Meter) and for my need, I would love to have a switch in order to (de)activate the smart/AI mode and the custom mode. I want to keep the battery at maximum capacity during the night, since I'm paying the electricity less than during the day and I would rather use the kWh stored inside in the morning when the sun is not high enough. Unfortunately, Anker won't let you program a mix of smart and fixed values, so I was counting on Home Assistant to do so.

thomluther commented 1 week ago

Another open question is how the Solix 2 will use the status codes. Do they have the same coding as for Solix 1? What you currently see for the status code description is translated only by the library based on what the Solix 1 was doing when reporting a certain code. We need a translation table for the Solix 2 status codes as well. Ignore 0 when false values are returned, but watch status code and actual description for other conditions:

The solarbank monitor will show both, the status code and its translation. In HA you can also see the history of both, but the code is only an attribute and you need to create a template helper entity first for status code history tracking and comparison to the description: {{state_attr('sensor.sb_e1600_betriebszustand','charging_status')}}

nicolinuxfr commented 1 week ago

You mean this, I presume ?

Capture d’écran 2024-06-25 à 13 33 02

EDIT : forget what's after, I did something weird and using what you gave (charging_status) as parameter seem to work. I will add a template helper on my HA.

I'm not sure how to create the template helper, I tried this code in the template pane of the dev tools, but only got "null" {{state_attr('sensor.solarbank_2_e1600_pro_mode','statut_charge')}}.

I'm guessing the second parameter is wrong, I tried some variations about code status, both in French and English, but could not get anything besides a null value.

thomluther commented 1 week ago

@nicolinuxfr , @TobTkyDev , @thealkly , @scho0ck , @xsasx , @kitokirisaki , @Disane87 I released a new version of the Api library. Please use it to extract your system configuration and explore existing or new endpoints to query or change data. If you can assist development, have a look to the open issues where help is needed. I have no Solarbank 2, so cannot explore anything through the Api.

Enhancements of the Api library are the pre-req for doing enhancements to the HA integration which uses the libarary and its helper methods

thealkly commented 6 days ago

@thomluther thanks for the API update, we ran some tests.

With the new api library version i was able to get first only valid data in terms of SOC and charge status (detection and once full_bypass ) Starting of solarbank monitor 21:00:59 UTC +0200 till 21:07:39 UTC, Update time 10 seconds, 126 API Requests. All solid SOC without any 0.

But after some more testing we found out a strange behaviour: First of all i was not able to login into the app (error maximum logins within 24h) But export_system is working.

When running export_system for 5-6 times, most of the time it worked with correct data in the api_sites.json like

( "home_load_power": "669", is the current grid consumption in watt from the smart meter )

Valid export_systems api_sites.json

  "solarbank_info": {
      "solarbank_list": [
        {
          "device_pn": "SN",
          "device_sn": "SN",
          "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": "200",
          "sub_package_num": 1,
          "output_cutoff_data": 10,
          "is_display": true,
          "alias_name": "Solarbank 2 E1600 Pro",
          "current_home_load": "200"
        }
      ],
      "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": "ID",
    "powerpanel_list": [],
    "grid_info": {
      "grid_list": [
        {
          "device_pn": "SN",
          "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

But sometimes we got, running the same export. big difference is all values are missing + "is_display_data": false.

"solarbank_info": {
      "solarbank_list": [
        {
          "device_pn": "PN",
          "device_sn": "SN",
          "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": "0",
          "bind_site_status": "",
          "charging_power": "0",
          "power_unit": "W",
          "charging_status": "0",
          "status": "1",
          "wireless_type": "1",
          "main_version": "",
          "photovoltaic_power": "0",
          "output_power": "0",
          "create_time": 1718626540,
          "set_load_power": "200",
          "sub_package_num": 0,
          "output_cutoff_data": 10,
          "is_display": false,
          "alias_name": "Solarbank 2 E1600 Pro",
          "current_home_load": "200"
        }
      ],
      "total_charging_power": "0",
      "power_unit": "W",
      "charging_status": "0",
      "total_battery_power": "0.00",
      "updated_time": "1970-01-01 00:00:00",
      "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": false,
      "solar_power_1": "0",
      "solar_power_2": "0",
      "solar_power_3": "0",
      "solar_power_4": "0"
    },
    "retain_load": "200W",
    "scene_mode": 0,
    "home_load_power": "0",
    "updated_time": "01-01-0001 00:00:00",
    "power_site_type": 5,
    "site_id": "sd",
    "powerpanel_list": [],
    "grid_info": {
      "grid_list": [
        {
          "device_pn": "pn",
          "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": "0",
      "grid_status": 0,
      "has_history_data": true
    },
thomluther commented 6 days ago

Hi @thealkly Thanks for the examples so far. So it seems the 'is_display_data' field can be reliably used to decide whether most the whole data in the response is invalid or not. The big question is what can be the typical or max duration for false responses? Depending on that we could simply skip those responses (if it will be few typically in shorter query intervals), or render the HA entities to unavailable.

Other things to note:

Disane87 commented 6 days ago

Here is my api_sites.json which looks like it doesn't got any data because the battery is full accordingn to the Annker app and there is pretty much sun on the panels.

{
  "0d6f482d-fb6a-edbc-fedf-9ec66eacddef": {
    "type": "system",
    "site_info": {
      "site_id": "0d6f482d-fb6a-edbc-fedf-9ec66eacddef",
      "site_name": "Rennstr",
      "site_img": "",
      "device_type_list": [
        3,
        6
      ],
      "ms_type": 2,
      "power_site_type": 5,
      "is_allow_delete": true,
      "support_device_models": [
        "A17C1",
        "A17X7",
        "A17X8"
      ],
      "current_site_device_models": [
        "A17C1",
        "A17X7"
      ]
    },
    "site_admin": false,
    "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": "20.85",
        "unit": "kWh"
      },
      {
        "type": "2",
        "total": "20.79",
        "unit": "kg"
      },
      {
        "type": "3",
        "total": "6.05",
        "unit": "\u20ac"
      }
    ],
    "topology_type": "1",
    "solarbank_info": {
      "solarbank_list": [
        {
          "device_pn": "A17C1",
          "device_sn": "YIGFIMJ6Q4UE8OKD",
          "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": "0",
          "bind_site_status": "",
          "charging_power": "0",
          "power_unit": "W",
          "charging_status": "0",
          "status": "1",
          "wireless_type": "1",
          "main_version": "",
          "photovoltaic_power": "0",
          "output_power": "0",
          "create_time": 1718984888,
          "set_load_power": "0",
          "sub_package_num": 0,
          "output_cutoff_data": 10,
          "is_display": false,
          "alias_name": "Unterstand",
          "current_home_load": "0"
        }
      ],
      "total_charging_power": "0",
      "power_unit": "W",
      "charging_status": "0",
      "total_battery_power": "0.00",
      "updated_time": "1970-01-01 00:00:00",
      "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": false,
      "solar_power_1": "0",
      "solar_power_2": "0",
      "solar_power_3": "0",
      "solar_power_4": "0"
    },
    "retain_load": "0W",
    "scene_mode": 0,
    "home_load_power": "0",
    "updated_time": "01-01-0001 00:00:00",
    "power_site_type": 5,
    "site_id": "0d6f482d-fb6a-edbc-fedf-9ec66eacddef",
    "powerpanel_list": [],
    "grid_info": {
      "grid_list": [
        {
          "device_pn": "A17X7",
          "device_sn": "Y7P5T5EDG2I7CT1T",
          "device_name": "Smart Meter",
          "device_img": "",
          "create_time": 1719053239,
          "status": "1",
          "bind_site_status": "",
          "wireless_type": ""
        }
      ],
      "photovoltaic_to_grid_power": "0",
      "grid_to_home_power": "0",
      "grid_status": 0,
      "has_history_data": true
    },
    "is_downgrade": false,
    "error_code": 0,
    "smart_plug_info": null,
    "feature_switch": null,
    "site_details": {
      "has_unread_msg": true
    }
  }
}
thomluther commented 6 days ago

Hello all It does not help to provide examples with "is_display_data": false, we learned that such data is NOT USABLE and does not give any glue how the data is relating to the App or the devices/systems. Please report and discuss any Solarbank 2 related stuff in the Api library. A full set of export data is needed if you want to provide examples via the system export tool. This will also randomize your sensitive data, but make sure that "is_display_data": true in the scene_info or api_sites output.

Please use the tools in the repo to extract your system configuration and explore existing or new endpoints to query or change data. If you can assist development, have a look to the open issues and report examples there or participate in the related discussions. If you have a new topic to consider, open a new issue there

Disane87 commented 6 days ago

Sorry that was my fault. Didn’t read your post good enough. Sorry!

xsasx commented 2 days ago

So I installed the Solix 2 at the weekend - and the Plugin works more or less which you know :) very frustrating is that the plugin very often disconnect and shows me on all entities 0 also for example battery " 0! " so i cant use the sensors for solar meassureing and stuff like that ( i have tested it with my admin account also with the 2nd account which has only read permissions.

You have all have these same behaviors ?

I will try to export you the data which maybe i can help with.

user86000 commented 1 day ago

So I installed the Solix 2 at the weekend - and the Plugin works more or less which you know :) very frustrating is that the plugin very often disconnect and shows me on all entities 0 also for example battery " 0! " so i cant use the sensors for solar meassureing and stuff like that ( i have tested it with my admin account also with the 2nd account which has only read permissions.

You have all have these same behaviors ?

I will try to export you the data which maybe i can help with.

The official anker app also disconnects often (smart meter and solix2), wlan and internet is stable

xsasx commented 5 hours ago

I would like to export also my Stuff from Solix 2 Pro and Smart Meter for your help - could anybody advice me how to do that under windows ?

thomluther commented 3 hours ago

I would like to export also my Stuff from Solix 2 Pro and Smart Meter for your help - could anybody advice me how to do that under windows ?

You can install python 3.12 runtime for windows. It comes with IDLE that can be used as lightweight runtime and development environment. You can install following required packages manually Required Python modules: pip install cryptography pip install aiohttp pip install aiofiles

Then you should be good to go to run the tools from the Api or build your own client.py according the example for testing your own Api requests.

Optionally you can install Windows subsystem for Linux (depends on your licence),Docker for Window and Visual Studio code according to the HA developer description. VSC makes the python coding and debugging much easier.