#Timer.x.remaining = Timer.x.duration

1 messages · Page 1 of 1 (latest)

modern jackal
#

It appears to me that the .Remaining attribute of a Timer helper is always the same as the initial duration, even when the timer is running. (See screen shots, Note: I'm GMT-4, so the times do match up.)

Is this a bug or is this expected, but I'm not understanding what .Remaining is supposed to represent?

How do I go about getting that time remaining that counts down when I select the timer from the Helper tab of the Devices & services section of Settings?

plain token
#

It only changes when you pause the timer.
If you want to get the actual remaining time, use the finishes_at attribute

#

This is intended, as an attribute which changes every second isn't beneficial for your database

modern jackal
#

Thanks, but finishes_at gives me a fixed time. How then do I do the math to report the number of minutes returned by:
timer.finishes_at - now()

#

I would like to display the number of minutes remaining in a dashboard element.

vast spire
#

Something like:
{{ ((state_attr('timer.test_2', 'finishes_at')|as_datetime - now()).total_seconds()/60)|round(1) }}

modern jackal
#

something like that, but not that. LOL.

'datetime.datetime object' has no attribute 'total_seconds'

#

Ahhhh! it's the | as_datetime that seems to be doing it for me.
I tried to use as_datetime(timer.finishes_at), calling it as a function instead of piping through it, and that definitely wasn't working.

#

How do I know when to use CastFunction() vs | CastFunction?

#

{{ (state_attr('timer.master_bath_manual_start_timer', 'finishes_at')| as_datetime - now()) / 60 | round (1) }} is close, but gets me 0:00:05.805486 The round() doesn't seem to be pulling its weight.

short beacon
#

That rounds the 60, not the result of the division.

modern jackal
#

ah ha! I had the .total_seconds() in the wrong spot. It was inside the now().total_seconds) when it should have been after the 2nd )
Getting much closer, but still getting decimal minutes

#

Yup. I figured that. Tried wrapping all the math in parens, but must have missed.
I managed to get them in the right spot this time.

#

{{ ((state_attr('timer.master_bath_manual_start_timer', 'finishes_at')| as_datetime - now()).total_seconds() / 60) | round (0) }} is now giving me a whole number of minutes.