Hi! I am using the HACS integration battery_sim to simulate a âWorks locally with Home Assistantâ-home battery I pre-ordered. Because of this, I have sensors indicating the current capacity in kWh and the current charging and discharging rates in kW.
I wanted to have a sensor thatâll estimate the time to a complete (dis)charge. I couldnât find any examples on the internet so I decided to make my own and publish it here!
How to reproduce
- Go to Settings > Devices & Services > Helpers > Create Helper > Template > Template Sensor.
- Enter any name you want, e.g. âHWE Battery - time to fullâ.
- Enter the templates provided below and replace the sensor entities with your own.
- Set the Device Class to âTimestampâ and leave the other options empty.
- Done!
Template to estimate when a battery is full:
- Replace
sensor.battery_sim_hwe_current_charging_rate
with your current charging speed in kW. - Replace
sensor.battery_sim_hwe
with your current charge level in kWh. - Set
full_capacity
to the full battery capacity in kWh.
{% if states('sensor.battery_sim_hwe_current_charging_rate') | float > 0 %}
{% set full_capacity = 2.688 | float %}
{% set remaining_capacity = full_capacity - states('sensor.battery_sim_hwe') | float %}
{% set charging_time_seconds = (remaining_capacity / states('sensor.battery_sim_hwe_current_charging_rate') | float) * 3600 %}
{{ now() + timedelta(seconds=charging_time_seconds) }}
{% endif %}
Template to estimate when a battery is empty:
- Replace
sensor.battery_sim_hwe_current_discharging_rate
with your current discharging speed in kW. - Replace
sensor.battery_sim_hwe
with your current charge level in kWh.
{% if states('sensor.battery_sim_hwe_current_discharging_rate') | float > 0 %}
{% set remaining_capacity = states('sensor.battery_sim_hwe') | float %}
{% set discharging_time_seconds = (remaining_capacity / states('sensor.battery_sim_hwe_current_discharging_rate') | float) * 3600 %}
{{ now() + timedelta(seconds=discharging_time_seconds) }}
{% endif %}
Theyâll look like this: (state will be âUnknownâ when there is no estimate to be made, obviously)
Enjoy, and be sure to let me know if and how you used it or if you improved on it!