Battery Available Energy

Post Reply
Dave Foster
Posts: 822
Joined: Thu Oct 13, 2022 7:21 pm

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 %}
User avatar
Will
Site Admin
Posts: 197
Joined: Thu Oct 13, 2022 5:56 pm

Good job, thanks for sharing.
Community Admin / FoxESS Professional

Buy me a coffee or Book a zoom meeting for remote consultancy

FoxESS Tri Inverter Installation
2 x KH Series Inverters
24 x HV2600 (62.4kWh)
32 x 490w across 4 arrays
Dual Tesla Household
Heatpump & Low Carbon Housebuild
Post Reply