I want to share my work that I did to intergrate the Anker Solix Solarbank E1600 into Home Assistant. Be aware that there is currently no API or integration availailable for the Solarbank. Although there is a promising project to obtain data from the Anker App and broadcast them via MQTT, there is still some work required. I would love to see if a developper could pick up the project work and build a custom integration for HA. Links to the existing projects:
I describe here what is possible without integration. I implemented 3 projects for the solarbank:
- Automatically adjusting solarbank discharge power to what is needed in the house, using OpenDTU for adjusting inverter limit
- Implementing template sensors to integrate the solarbank battery to dashboards, using solar forecast integration data to estimate the battery state of charge and the actual charging power
- Get recommendation for the solarbank house load setting during daytime to avoid daylight discharging and allow slowest possible full charge on sunny days, using solar forecast per hour. This aims to ensure that full bypass power is not at noon peek, but late in the afternoon while battery still gets fully charged.
I start describing project 1 inititially, since this might be most interesting. The others took lot of time to developp and tweak to the actual solarbank behavior since there is very limited information available from Anker. The behavior also changed recently with firmware 1.4.1 and more tweaking is required until there is an API to get true values from the solarbank. It will also take lot of time to document those projects for a broader community. Therefore let me know if there is interest.
If you are interested to get more details about Solarbank behavior, a user from the photovoltaik forum wrote a nice PDF with the accumulated observations. This is all German, but you can easily have it translated.
Requirements for automatic solarbank discharge adjustment
- An inverter that supports real time AC output limit adjustment. I have a Hoymiles inverter which has that feature
- An interface for the inverter which can be integrated into HA. I have an OpenDTU kit, which can integrate Hoymiles via MQTT
- A smart meter reader, that can be integrated into HA and being able to provide actual power values in less than 5 sec intervals. Slower intervals will work, but make the automation much less effective. I use a ready built DIY ESP smart meter kit, that uses Tasmota and can provide values via WLAN and MQTT in 1 sec intervals. A Shelly 3M will probably work as well. Originally I used Powerfox Poweropti, but last forced firmware update closed local RPC API capability. The powerfox cloud API is lagging behind, is not stable and I could only get 25 sec value intervals at min. So itâs no longer a usable device for real-time power reading and automation.
Note: I donât want to describe how you integrate your inverter or your grid smart meter to HA. There are other posts describing that in more detail. If you cannot fulfill those requirements, this project probably wonât help you.
While I was testing how the output from the Solarbank can be adjusted by the inverter limit, I noticed that any limitation during battery charge mode will negatively impact the solar panel production. Therefore avoid inverter limitations during the day when the solarbank may be charging or bypassing, meaning during any potential solar production. During the day, you have to accept the minimum house load that you can set in the Anker App. If the 100/150 W is too much, better feed something to the grid without compensation than avoiding the energy production.
I created an automation, that applies only when sun is below a certain level, eg 4°, where Iâm sure that the panels cannot produce anything. The rest of the automation uses (template) sensors from the inverter and grid meter provided via MQTT. I also try to avoid too many inverter limit changes and set only the temporary limit, but not the permanent limit. I want automatic limit reset in the morning when the inverter starts, and the permanent limit will probably be written to an EPROM that might have limited write cycles. Temporary limit changes go to RAM and should not be limited in number of changes. The Hoymiles inverters are fortunately very fast reacting on limit changes and change AC output within 1s. So you can truly achieve near 0 power consumption from the grid when consumption is within adjustable range.
In contrast, the Solarbank is very slowly reacting on changes in the house load, which can take 1 to 3 minutes, especially during charge mode. Therefore the Solarbank limit setting is very unusable for near real time adjustments. (Even if there will be an API for this in future). But during discharge mode you can set a house load profile from any min to max value, and the inverter behind the Solarbank will limit a high output immediately when set. It can also increase the battery output immediately up to the family load set in the App profile. So during discharge mode the battery reacts like solar panels to the inverter, and with the inverter limit you can reduce the discharge to lower values than the Anker App allows, and also faster than the solarbank itself would allow⌠a real benefit if your house load is fluctuating below the Anker App 150 W or 100 W minimum limit.
For example, my house is consuming only 50-120 W when nobody is at home or during night. So with the Solarbank alone, I would still waste 50% energy to the grid with no chance using it by myself. This project allows me to use 100% of battery energy by myself !!!
This is why I think this is most relevant to others in similar situation.
I kept the automation a bit conservative and set only values at 10 W granularity. When grid meter goes to negative value indicating injection, limit adjustment is immediately down to a value below my house consumption template sensor. A limit increase occurs only in steps of 20 W when grid consumption shows more than 30 W. This automation keeps my grid consumption in a range from 0-30 W while the Solarbank is discharging. You can make the automation more aggressive for lower grid consumption, but this might mean more wasted energy to the grid if your house consumption makes lot of big changes, and it also means more limit adjustments in your inverter without that you gain anythingâŚ
Here is a screen shot showing the effect of the automation.
Blue is the grid meter sensor of the house circuit. A negative value indicates power flow back to the grid that I want to avoid, because I donât get any compensation for it. Orange is the solar power, either from panels or from the battery. Actually this is a template sensor using measured value from the inverter AC output or from the smart plug where the inverter is plugged in (in case inverter output is unavailable). Green is the solar power that I can consume by myself. Any surplus of solar power will be feed back to the grid. My heat pump uses a separate circuit and smart meter, therefore I disabled that graph for the Screenshot.
During the day I use 100 W house load setting in the Anker App, but currently also disable discharge load during the day. You can see that for my empty house, 100 W is still too much at various times, but this feeding to the grid during the day I cannot avoid. Starting before 17:00, you can see that solar power going down for sunset. At 17:00 my App profile changes from 0 to 300 W. That means if the solarbank is off, it should go on. Then it should feed 300 W constantly to the house. This is where automation jumps in. The green self consumption now fully overlays the orange solar power coming now only from the solarbank, and the blue line is slightly above 0 W, showing just little grid consumption.
This is how I set my house load profile in the App:
Note that discharge output is only 50 W although the profile is set to 300 W
The only things I need to adjust from time to time are the daily start and end times depending on sunrise and sunset. They should be before solar production start and after production end.
The daily load I adjust depending on solar forecast (project 3). When you expect less than 2 kWh solar energy from the panels for a day, I suggest you set the load to the minimum possible and then disable the house load completely for the daytime interval. This avoids that the Solarbank will switch to discharge mode during daytime if panels produce less than 25W, which can happen around sunset or during cloudy days, since the Solarbank needs around 25 W from the panels to do anything good with it. (Weak low power usability that will hopefully be improved by future firmware updates)
Here is the automation I use:
alias: Solarbank zero grid injection
description: >-
Dynamically change inverter limit to avoid battery feeding the grid
trigger:
- platform: state
alias: New grid power value received
entity_id: sensor.strom_aktuell
id: NewValue
to: null
condition:
- alias: Test that inverter is producing AC power
condition: state
state: "on"
entity_id: binary_sensor.hoymiles_hm_600_producing
- condition: or
conditions:
- condition: state
alias: Test that Solarbank is discharging
entity_id: sensor.solarbank_status
state: discharging
enabled: false
- condition: numeric_state
alias: Test that sun too deep for solar production
entity_id: sun.sun
attribute: elevation
below: 4
action:
- choose:
- conditions:
- condition: numeric_state
alias: Test if feeding to grid
entity_id: sensor.strom_aktuell
below: 0
- condition: numeric_state
alias: Test if inverter limit should be reduced further
entity_id: number.hoymiles_hm_600_limit_nonpersistent_absolute
above: 30
sequence:
- service: number.set_value
data:
value: >
{# Decrease inverter limit rounded by 10 below consumption value #}
{% set minlimit = 30 %}
{% set base = 10 %}
{% set actlimit = states('number.hoymiles_hm_600_limit_nonpersistent_absolute')|float(0)|round(-1) %}
{% set maxlimit = min(600,actlimit) %}
{% set consumption = states('sensor.strom_hausverbrauch_aktuell')|int(0) %}
{% set newlimit = max(min(maxlimit,consumption-base/2),minlimit)|int %}
{% set newlimit = newlimit - (base + newlimit) % base %}
{{newlimit}}
target:
entity_id: number.hoymiles_hm_600_limit_nonpersistent_absolute
alias: >-
Feeding to grid, increase inverter limit if conditions match
- conditions:
- condition: numeric_state
alias: >-
Test if grid consumption large enough to increase limit and allow more discharing
entity_id: sensor.strom_aktuell
above: 30
- condition: numeric_state
alias: Test that inverter limit below max limit
entity_id: number.hoymiles_hm_600_limit_nonpersistent_absolute
below: 599
- condition: template
value_template: >-
{{states('number.hoymiles_hm_600_limit_nonpersistent_absolute')|int(0)-states('sensor.bkw_einspeisung')|int(0) < 30}}
alias: Test that solarbank discharge limit is not reached
sequence:
- service: number.set_value
data:
value: >
{# Increase inverter limit to next rounded 20 W step #}
{% set maxlimit = 600 %}
{% set minlimit = 30 %}
{% set base = 20 %}
{% set actlimit = states('number.hoymiles_hm_600_limit_nonpersistent_absolute')|float(0)|round(-1) %}
{% set newlimit = max(min(maxlimit,actlimit+base/2),minlimit)|int %}
{% set newlimit = newlimit + (base - newlimit) % base %}
{{newlimit}}
target:
entity_id: number.hoymiles_hm_600_limit_nonpersistent_absolute
alias: >-
High grid consumption, increase inverter limit one step if
conditions match
enabled: true
mode: single
You need to replace the sensor names as following:
- sensor.strom_aktuell
This is your sensor presenting actual power from or to the grid (positive and negative Watt) within 1-5 sec intervals - sensor.bkw_einspeisung
This is your sensor presenting actual AC output from your inverter in Watt within 1-5 sec intervals - sensor.strom_hausverbrauch_aktuell
This is your sensor presenting the power your house is actually consuming in Watt within 1-5 sec intervals. It is usually the grid value plus the inverter output value. But you have to consider special conditions and value time lags, therefore I use a template sensor for this. See example below. - sensor.solarbank_status
This is a template sensor I created in project 2. It aims to more accurately recognize when solarbank switches to discharge mode, independently from sun level. I disabled this OR condition since not needed for project 1 automation. Delete condition completely if you get errors for non existing sensor.
Note: The state trigger is explicitly set to none to avoid the trigger is fired on attribute changes or each update interval. Itâs only fired when the smart meter value really changes, to reduce execution of the automation to a minimum.
Template sensor example for house load calculations:
- sensor:
- name: "Strom-Hausverbrauch-aktuell"
unique_id: "Strom-Hausverbrauch-aktuell"
unit_of_measurement: "W"
device_class: "power"
icon: mdi:home-lightning-bolt
state: >
{% set stromzaehler = states('sensor.strom_aktuell')|float %}
{% set bkw = states('sensor.bkw_einspeisung')|float(0) %}
{% set mystate = this.state if this.state not in [None,'unavailable','unknown',''] else 0 %}
{% if is_number(stromzaehler) %}
{# add grid value and inverter value for house load, but avoid negative house load by value time lags #}
{{ (stromzaehler + bkw) | round(1) if stromzaehler + bkw > 0 else mystate}}
{% else %}
{{mystate}}
{% endif %}
availability: >
{{is_number(states('sensor.strom_aktuell'))}}
I have defined my template sensors via a separate file that I included as following in configuration.yaml
template: !include template.yaml
If you include the sensor directly in configuration.yaml, put it to the template: section and ensure formatting is correct.
With a full battery and low discharge over short nights in summer, it may happen that battery is not empty yet when production starts again the next day. Therfore I created another automation that ensures the inverter is reset in the morning. You can trigger it again via the sun level.
alias: Inverter daily reset
description: Ensure inverter reset in the morning to start new production cycle
trigger:
- platform: numeric_state
alias: Test that solar production shortly prior start
id: reset
entity_id: sun.sun
attribute: elevation
above: 4
condition:
- condition: state
alias: Test that inverter is still on
entity_id: binary_sensor.hoymiles_hm_600_reachable
state: "on"
action:
- alias: Wait for Hoymiles Yield sensor availability
wait_for_trigger:
- platform: state
entity_id:
- sensor.hoymiles_hm_600_yieldday
from: unavailable
timeout:
hours: 0
minutes: 0
seconds: 10
- alias: Reload Hoymiles MQTT device config if not available
if:
- condition: state
entity_id: sensor.hoymiles_hm_600_yieldday
state: unavailable
then:
- service: homeassistant.reload_config_entry
data: {}
target:
device_id: 24219185c693b268d6640b68398cb5da
- delay:
hours: 0
minutes: 0
seconds: 5
- alias: Restart inverter if not off in last 5h, else check limit is at max
if:
- condition: trigger
id:
- reset
- condition: template
value_template: >
{{expand('binary_sensor.hoymiles_hm_600_reachable')|selectattr('last_changed',
'lt', now()-timedelta(hours=5))|map(attribute='entity_id')|list|count > 0 }}
alias: Test that inverter was not off in last 5h
then:
- service: button.press
data: {}
target:
entity_id: button.hoymiles_hm_600_restart_inverter
alias: Restart inverter
else:
- alias: Reset inverter limit if required
- if:
- condition: numeric_state
entity_id: number.hoymiles_hm_600_limit_nonpersistent_absolute
below: 599
then:
- service: number.set_value
data:
value: 600
target:
entity_id: number.hoymiles_hm_600_limit_nonpersistent_absolute
mode: single
Note: I included the MQTT device restart because the sensors have been in a weird state once although the inverter was on. To get your device id, select this service and device via UI in developper tools services tab, then switch to YAML mode and copy the code.
Conclusion
I hope this project is useful for you and you can get some inspiration for your own battery discharge control to maximize your solar power self consumption.
Project 2 is about how to create sensors with the solar forecast integration to provide visualization in the UI:
If you are interested in this topic, you need to do some preparation and calibrate the forecast integration so it is reflecting pretty accurately the hourly solar production in your energy dashboard.
Hint: Check your calibration in the evening of a sunny day without having the Solarbank installed.