Page 1 of 1

Battery Available Energy

Posted: Wed Oct 19, 2022 8:22 pm
by Dave Foster
This sensor takes the battery SoC and given the known values of Battery Capacity (kwH) and minimum SoC, it calculates the available energy to use in kWh

Enter this sensor code in your configuration.yaml, edit the kWh_tot and minSoC values to match your system and it will provide a new sensor 'sensor.battery_available_energy' that shows the available battery energy remaining.

This example is from my system with 13kWh of batteries and a 10% minSoC

Code: Select all

  - sensor:
      - name: "Battery - Available Energy"
        unit_of_measurement: "kWh"
        state: >
          {% set kWh_tot = 13 | float %}
          {% set minSoC = 10 | float %}
          {% if  states("sensor.battery_soc") in ['unknown', 'unavailable'] %}
            {{ states("sensor.battery_soc") }}
          {% elif  states("sensor.battery_soc")|float >= minSoC%}
            {{ ( kWh_tot * ( states("sensor.battery_soc")|float - minSoC ) / 100 )|round(1, default=0) }}
          {% else %}
            {{ 0|float }}
          {% endif %}

Re: Battery Available Energy

Posted: Wed Oct 19, 2022 9:05 pm
by Will
Good job, thanks for sharing.

Re: Battery Available Energy

Posted: Tue Jul 16, 2024 10:02 pm
by markhaines
This is useful, have stolen it for my own install - thanks!

Re: Battery Available Energy

Posted: Mon Jul 14, 2025 7:39 am
by rpdasd
This is available in the API

- ResidualEnergy:
name:
zh_CN: 电池剩余电量
en: Battery Residual Energy
pl: Battery Residual Energy
fr: Battery Residual Energy
pt: Battery Residual Energy
de: Battery Residual Energy
unit: kWh
Grid-tied inverter: false
Energy-storage inverter: true

Re: Battery Available Energy

Posted: Mon Jul 21, 2025 3:45 pm
by iew100
For me, the residual energy (sensor.foxess_residual_energy) is just the maximum capacity*min_soc so 1.036kWh for an EP11 with 10.36kWh capacity.

I set up Dave's template sensor as shown and it works very well.

I also made the min_soc input % a dynamic field in case I change it.

{% set minSoC = states("number.min_soc") | float %}