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!