How to monitor Solarbank battery efficiency and health #109
Replies: 3 comments 5 replies
-
Great instructions, thank you very much! Could you possibly also share the code for the dashboard or the other health sensors that you showed as examples above? |
Beta Was this translation helpful? Give feedback.
-
hi specialists..... or is on YT a video...... maybe in German ...... to get the script into my HA thanks |
Beta Was this translation helpful? Give feedback.
-
I updated the trigger based sensor for remaining capacity since there may be errors logged if the state is set to none as documented. This should be an accepted state for numeric sensors, but obviously it causes an exception in core for state evaluation. There is actually an issue open against core. |
Beta Was this translation helpful? Give feedback.
-
How to monitor Solarbank battery efficiency and health
The Solarbank itself does not provide any metrics to get an idea about the battery efficiency or its age and healthiness. Here I want to describe which metrics and entities I implemented to track both.
Solarbank battery age, healthiness and overall efficiency
First of all, I'm not a battery expert and there are probably many metrics required to estimate a proper fitness level for a battery over lifetime. From my base knowledge, following 2 fundamental metrics can help in this regard:
Anker claims that their Solarbank E1600 LPFE battery will survive 6000 cycles while still providing 80% of the capacity. So how can you track that if you have no indications in the Anker App for it? And how can you track the efficiency of the battery to get an understanding of the energy loss that occurs by charging and discharging?
Using Home Assistant and the Anker Solix integration, you can establish template entities that will help tracking these metrics, at least at an approximate level.
Following is the implementation approach:
When you created those entities and assigned them to your solarbank device, you will be able to track them with the other device entities provided by the integration. Following is an example with the created entities:
This was taken at the end of a cloudy day, where only 13% have been charged/discharged. And as you see in the daily efficiency, this can be really low if the battery just operates at the lower range compared to the overall efficiency.
The next sections will describe each implementation step for those additional solarbank entities in more detail.
1. Template entities for charge and discharge energy
Separate tracking for charge and discharge energy provides the base for many things that you want to monitor for your solarbank. For example, the HA energy dashboard requires separate total increasing energy entities to track battery charge and discharge energy. The recommended way to create a total increasing energy entity is to create a Riemann Integral helper over a power sensor that accumulates the energy (power over time) and is per definition a total increasing sensor. To make sure the integral value is really only increasing, you need to ensure that the source power entity only provides positive values. Since the Anker Solix integration only provides a single entity for the battery power which is positive for charging and negative for discharging power, you have to separate those values first with another set of template sensors. This approach is explained in the discussion thread for Solarbank integration into the Energy Dashboard.
At this point we assume you created your total increasing charge and discharge entities accordingly, and you hopefully integrated them properly into your energy dashboard. In the following section we will refer to them as:
sensor.solarbank_charge_kwh
sensor.solarbank_discharge_kwh
2. Utility meter helper to reflect total energies
While the previous entities already reflect an ever increasing energy value which is sufficient for the energy dashboard, they might not reflect the total value since your implementation of the sensors is somewhat delayed from the solarbank installation. Since it is not that easy to adjust or calibrate the total increasing entities, and doing the same could also mess up your continuous energy tracking in the dashboard, we create utility meter entities for the total increasing energies. Utility meter entities can be optionally reset at regular intervals, but can also be calibrated via a service (now action) to reflect to correct value. The recommended way to create those total energy utility meters is from the UI while using following settings:
Solarbank charge kWh total
andSolarbank discharge kWh total
sensor.solarbank_charge_kwh
andsensor.solarbank_discharge_kwh
Once both utility meters are setup, they start increasing with their source entity. Next step is to calibrate both for the real value since the installation of the solarbank. Typically you can find the overall charge and discharge energy of your solarbank battery in the Anker mobile App, when you look at the energy statistics of your system. Make sure to select the full range since the installation to get the overall total amounts. With those amounts you can calibrate your total energy utility meters.
You can use the UI mode in the HA developer tools, services (now Actions) and then look for the
utility_meter.calibrate
service. Use it to calibrate both utility meters subsequently to their correct value. Here is the YAML code for this service as an example:Finally check in the developer tools that your calibrated utility meters now show the correct value. From this point on, they continue to represent the overall energies for your battery. However, they may differ slightly from the values in the Anker app after some time since the Anker cloud and the HA energy entities integrate separately from the provided/available power values.
3. Template sensor to calculate full discharge cycles from the total discharge energy
This is a simple template sensor that you can create in the UI. It simply divides the total discharge energy by the number of nominal energy for a full discharge cycle. You need to be aware, that there are various classifications what counts as full discharge cycle, and I have no clue what classifications where used for the Solarbank cycle specification. So it is an approximate value to give you a clue how many full cycles your solarbank battery may have been done. For simplicity I selected 90% of 1600 Wh assuming that 10 % SOC reserve is used, which resolves to 1340 Wh nominal per full discharge cycle. Of course, those nominal 1340 Wh cannot be discharged over lifetime during a full cycle after the battery capacity is degrading. So you can adjust this divider as desired to represent an average full discharge cycle.
When you create the template sensor from the UI helpers, e.g.
sensor.solarbank_battery_cycles
, you can use following templates considering thatsensor.solarbank_discharge_kwh_total
is the total discharge energy utility meter, that you created and calibrated earlier.State template:
Availability template in case you define the sensor via YAML:
The sensor unit should be set to
%
. The rest of the sensor definition you can declare as desired.Hint:
Since the 2024.07 HA release, you can also assign any UI template entity to your Solarbank device, which will enable the display of this entity when you watch your solarbank device or when you filter for solarbank device entities. Following is just an example how your Solarbank device entities may look like after assigning additional UI template entities.
4. Template sensor to calculate overall battery efficiency
Creating an entity to reflect the overall battery efficiency is not that difficult once you have separate entities reflecting the total charge and discharge energy. Since those entities cover multiple cycles over time, the time difference you always have between the charge and later discharge energy can be ignored. This is completely different if you want to track efficiency for each battery cycle, which is explained further below.
When you create the template sensor from the UI helpers, e.g.
sensor.solarbank_battery_efficiency
, you can use following templates considering thatsensor.solarbank_charge_kwh_total
andsensor.solarbank_discharge_kwh_total
are the total energy utility meters, which you created and calibrated earlier.State template:
Availability template in case you define the sensor via YAML:
The sensor unit should be set to
%
. The rest of the sensor definition you can declare as desired.5. Template sensor to calculate actual battery capacity
Following is the base concept to calculate an approximate remaining capacity for any battery. We know the nominal battery capacity of 1600 Wh for the solarbank. The SOC reflects the battery charge level, which is always 100 % when no more power can be loaded to the battery. However 100 % can mean the nominal capacity, maybe more if extra capacity is factored into the device, but for sure less when the capacity degrades over time. When you count the discharge energy for a discharge interval, you can compare how much energy you still got out of the battery for a certain discharge % and compare this energy with the nominal discharge energy assuming a new battery provides 1600 Wh for 100%.
First I implemented this calculation via input number helpers and an automation. But I quickly realized, that this entity needs long term recording, so it must be included in HA long term statistics to see how it evolves over months or years. Entities must comply certain requirements to be tracked in long term statistics. A main requirement is that it must be a sensor with a state class, that is either classified as
total
,total_increasing
ormeasurement
. That means input number helpers to store the calculated result from an automation do not make it into long term history tracking at all.For that reason I implemented a trigger based template sensor which does the same and which is also recorded in long term statistics. So it should be possible to see the average capacity and its degradation over many months or years instead of just knowing an estimated actual value.
Since this is a trigger based template sensor, you cannot create it yet in the UI. You must create it in the configuration.yaml or a children file for template sensors, that is included into the configuration.yaml.
Following is the code. You need to replace following entities with yours:
sensor.sb_e1600_mode
for the solarbank statussensor.sb_e1600_state_of_charge
for the solarbank battery SOCsensor.solarbank_discharge_kwh_total
for the total discharge energy created earlierI selected a device class of
battery
for the sensor, this will use automatic battery icons including coloring based on sensor value, but you can also skip the device class. Furthermore you can define a fixedicon
if desired.Note:
Even if the sensor value typically will be calculated maximum once per day when discharge is larger than defined significance of 20 %, you may see fluctuations in this value resulting from accuracy of your discharge energy aggregation, as well as from the actual accuracy of charge level percentage reflected by the solarbank. Any SOC percentage below 100 % may be offset and should typically recalibrate internally when there is a full charge/discharge cycle. The value must really be seen as a long term indication to understand how its value average and trend is evolving over months and years.
Expand to see sensor code
Attention:
Trigger based template sensors will be initialized with a state of
unknown
during initial registration (HA restart or template sensor reload) until they are triggered the first time and can resolve their state. Also the sensor attributes may be undefined until triggered the first time. Therefore, the sensor templates must consider initial setup conditions properly with default statements to avoid errors in the HA logs when accessed sensor attributes are not defined yet.Furthermore, when the templates are executed they have no access to the new state or attribute values that are actually being set for the sensor. In the templates you can only access the sensor state objects from before or after the trigger condition, but this is always before the new state or attributes are evaluated.
Solarbank battery cycle efficiency
As described in previous sections, the overall battery efficiency is easy to track. However, if you want to track the efficiency for each battery cycle it becomes more difficult. The reason is that you have to consider the time difference when the charge and discharge energies accumulate. Furthermore you cannot use daily utility meters which typically reset at a fixed time (usually midnight), because when you want to track a full 'solar' cycle that includes a battery, the battery discharge can extend until next day in the morning when solar production starts again. Therefore you need a capability to dynamically trigger a reset of the energy utility meters that are supposed to count entities based on a full solar cycle.
HA provides a service to reset a utility meter entity, however this only works against the
select.*
entity of a utility meter, which is only created when you define a utility meter with at least one tariff.To summarize, for entities that you want to count for a full solar cycle, you need following:
1. Utility meter with tariff to count charge and discharge energy for a solar cycle
The required utility meters can be created easily from the UI as helper entities with following settings:
Solarbank charge kWh
andSolarbank discharge kWh
sensor.solarbank_charge_kwh
andsensor.solarbank_discharge_kwh
solarcycle
ON
Keep the defaults for the other settings. This will create 2 entities for each utility meter. Following entities will be available once finished:
select.solarbank_charge_kwh
sensor.solarbank_charge_kwh_solarcycle
select.solarbank_discharge_kwh
sensor.solarbank_discharge_kwh_solarcycle
2. Trigger for new solar cycle start
A good trigger for the solar cycle start might be when your solarbank starts production again. It might be also when the sun exceeds a certain elevation. Or it might be when your inverter starts, which is for sure a good solar cycle trigger when the solarbank is not installed temporarily, for example in winter. Multiple triggers may be possible which you can use in the automation. Here I show you an example that I implemented in the form of a trigger based template sensor, which holds its last reset time stamp as state and provides an attribute that is indicating whether it was reset today or not. I use that as a common source for anything that needs to be triggered once for each solar cycle start and it allows easy monitoring when the start was triggered the last time.
Basically the sensor triggers when the solarbank mode changes into a state that indicates solar power. The other trigger comes from my inverter integration once the inverter becomes reachable, and another time based trigger after midnight. Those are required to trigger a potential solar cycle start when the solarbank is not installed or available.
Following are the entities that you need to replace in the template code:
sensor.sb_e1600_mode
for your solarbank mode entitybinary_sensor.hoymiles_hm_600_reachable
for your inverter powered on entity if applicableIf you don't have a proper entity to indicate an inverter start, you can also remove this
reachable
trigger and the associated statements in the state and attribute templates. You also need to keep in mind that the inverter will not start together with the solarbank, when any charge priority is configured with the MI80 or the 0 W output switch. In that case, the solarbank starts charging in the morning, but the inverter will stay off since it will not get any DC power until the solarbank starts bypassing PV power to the inverter. In that case, only the solarbank mode state change will be a trigger for the solar cycle start. So you must cover all mode states that may occur during potential solar production.Expand to see sensor code
Note:
Trigger based template sensors can only be defined in configuration.yaml or an included child yaml. Those sensors will also be unknown until triggered the first time after initial load.
3. Automation to reset your solar cycle utility meters
Following automation can be used to reset your utility meters for each solar cycle start. It will cover also situations when a state change of the solar cycle start template sensor is triggered by template reload or HA restart actions.
Expand to see automation code
Template sensor for daily battery efficiency
When you create the template sensor from the UI helpers, e.g.
sensor.solarbank_battery_efficiency_daily
, you can use following templates considering thatsensor.solarbank_charge_kwh_solarcycle
andsensor.solarbank_discharge_kwh_solarcycle
are the daily energy utility meters, which you created earlier.State template:
Availability template in case you define the sensor via YAML:
The sensor unit should be set to
%
. The rest of the sensor definition you can declare as desired.When you have some history data available for this daily sensor, you can see how it increases from 0 % in the evening during discharge start until ~80% in the night/morning when the discharge is fully completed. At weak PV days, the battery efficiency can also be lower as seen at the last day of the history.
Attention:
In case the battery is not empty before next solar cycle starts, this energy is dropped during utility meter reset and may cause an efficiency offset for the current cycle calculation since you potentially discharge not only the new daily energy, but also the remaining energy from the previous day.
Beta Was this translation helpful? Give feedback.
All reactions