I have a simple timer that starts at 30 minutes and counts down to zero. In the developer template, developer states, and in scripts I’m always getting a value of 30 (when the timer is running) for the following (and variations)
{{state_attr('timer.frontdoor', 'remaining')}}
In lovelace, when I display timer.frontdoor I see the correct value counting down to zero. How can I get the remaining time and use it in scripts?
Apparently time remaining doesn’t work when the timer is active. Strange. In any case here’s what I did. I added a condition so my script only runs when the timer is active. Then when the script is called, it pauses the timer, gets/processes the time remaining, and then restarts the timer. Oh workarounds.
timer_remaining:
sequence:
- condition:
condition: state
entity_id: 'timer.frontdoor'
state: 'active'
- service: timer.pause
entity_id: timer.frontdoor
- service: tts.google_say
data_template:
entity_id: 'media_player.entryway_speaker'
message: "{{state_attr('timer.frontdoor', 'remaining')}}"
- service: timer.start
entity_id: timer.frontdoor