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 %}