Battery Wh usage extrapolation/trend/projection for how many hours left

Hi Community,

I was trying to find a solution to extrapolate my apartment’s power usage from the off-grid system using a utility meter that tracks the amount of energy my inverter pulls from batteries.

The main idea is as follows:

  • knowing how many kWh have been consumed already from the batteries and how fast for the time window, and how many are left (approx), I want to calculate how many hours/minutes are left for my apt to run on battery power.

I already have a lot of metrics:

  • when the blackout started (datetime helper)
  • how battery charge is consumed (utility meter from inverter power sensor)
  • how much power is used constantly (inverter sensor)

I tried to search for “extrapolation” and I only found this one:

To be honest, I know it’s kind of an overkill, I have a lot of data already to rely on. But it will be a nice finishing touch to see a counter that can predict (approx) how many hours are left in my system, so I can tune my power usage to make it work longer if a longer blackout happens.

Maybe similar to what I’m asking:

I am not sure if I understand your question correctly. So let me summarize what I understand and think is necessary to achieve your goal. You have

  • a sensor, which gives you the energy in kWh, which is still available in your battery
  • a sensor, which gives you the current power usage in kW

If that is the case and if you are willing to make the assumption of a constant power usage (i.e. linear growth of energy usage), can’t you just create a template sensor, which calculates the quotient of the two sensors above? Since I have a similar setup I just tried that and created the following template sensor and it seems to work quite well:

{% set capacity = states('sensor.remaining_battery_energy') | float(0) %}
{% set power = states('sensor.power_usage') | float(0) * 1000 %}
{% if power > 0 %}
  {{ (capacity / power) | round(2) }}
{% else %}
    0
{% endif %}

where in my case sensor.remaining_battery_energy is measured in Wh and sensor_power_usage in kW. Thus, after multiplying the power usage sensor by 1000 I have a value in W and (capacity / power) returns a value in hours and corresponds to the time, which is left until your battery is empty if you use the same amount of power during this time period. Would this already satisfy your needs or did I misunderstand something?