Battery Available Energy
Posted: Wed Oct 19, 2022 8:22 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
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 %}