#Battery estimated time remaining

1 messages · Page 1 of 1 (latest)

rich vector
#

I created a sensor in home assistant that takes the remaining kw storage left in my powerwall then calculating the current kWh usage and it gives me an estimated time remaining based on current usage.

Thought someone else might like it

sensor:

  • platform: template
    sensors:
    battery_remaining_time:
    friendly_name: "Battery Remaining Time"
    unit_of_measurement: "hours"
    value_template: >
    {% set battery_level = states('sensor.battery_level_kw') | float(0) %}
    {% set usage_rate = states('sensor.current_usage_kwh') | float(0) %}
    {% if usage_rate != 0 %}
    {{ (battery_level / usage_rate) | round(2) }}
    {% else %}
    Infinity
    {% endif %}
sly hare
#

I did something similar to start with - though I used a statistics helper to work out the average use for the last hour and used that, rather than instantaneous current_usage as I found that jumped around a bit much
I eventually went with something more complicated because I was bored on a train journey - I worked out my average home energy consumption per half hour time period of the day for weekdays and weekends and saved it as an array in a template. I can then add stuff in like taking into account the day's solar forecasts, free energy periods when I switch to grid power and can recharge the battery, if my washing machine is going to turn on etc to adjust that time.

#

I would look at adding some default values to your template, as if either of your sensors goes unavailable/unknown - your template will throw errors trying to set them to floats

rich vector
#

Ahh good idea. I’ll do that. I updated the code

hexed vessel
#

Such forecasts are typically done by machine learning. For example EMHASS has that built into its addon