I am trying to calculate the percentage of a timers time left. I have run into the problem, that my template sensor, just won’t update.
- name: "Timer Completion Percentage"
unit_of_measurement: "%"
state: >
{% set total_duration = state_attr('timer.my_timer', 'duration') | float %}
{% set remaining_duration = state_attr('timer.my_timer', 'remaining') | float %}
{% if remaining_duration is not none and total_duration > 0 %}
{{ ((total_duration - remaining_duration) / total_duration * 100) | round(1) }}
{% else %}
0
{% endif %}
If I understand it correctly, that is because the timers state does not change.
So how could I calculate the percentage updating for example once every 10 second? Using an automation, that will trigger the homeassistant.update_entitiy does not seem to do anything either.
alias: update percentage standing timer
description: ""
triggers:
- seconds: "10"
trigger: time_pattern
conditions: []
actions:
- target:
entity_id: sensor.timer_completion_percentage
action: homeassistant.update_entity
data:
entity_id:
- sensor.timer_completion_percentage
mode: single
Any tips or ideas would be greatly appreciated