I am still new with HA but I am looking at the Timer Helper and I can see if I “start” it from the GUI the timer counts down in seconds, on the screen, like the first image
Does anyone know how I can get a similar countdown showing on a button in a dashboard?
I thought if I created a sensor and show it’s state, like below, it might work, but it doesn’t update and just shows the initial value.
A timer’s remaining attribute is not updated in real-time (it’s updated when paused). The countdown you see in the UI is managed by the UI on behalf of the timer entity (effectively, it’s doing its own countdown).
Your Template Sensor will need to compute the timer’s remaining time. When the timer is active it has a finishes_at attribute. You can use that with now() to compute the remaining time. When the timer is paused, the finishes_at attribute ceases to exist and the remaining attribute represents the balance left. An important detail is that whatever template you create to compute the remaining time using now() will have a minimum resolution of one minute (i.e. template will be evaluated at intervals of one minute).
That template overlooks an important detail I mentioned. The finishes_at attribute doesn’t exist when the timer is idle or paused. You have to make the template handle that situation gracefully.
One of the problems you will encounter is that because the time resolution is in minutes, when the countdown drops below 1 minute it cannot display the remaining seconds so it will report 0 minutes remaining (for a full minute).
No one should be pigeonholed into using an entity card for displaying an attribute. It’s sad to see there has never been development on fixing this after so many years. Tracking time left on a given timer is a quintessential component of process control.
I’m also trying to figure this out.
I’m struggling with now() because that shows the time without DST and the ‘finishes at’ uses DST so I’d have to add more code to calculate DST adjustments which seems messy.
Also I’d rather be able to see the seconds remaining.
There must be a way to acheive this! If the timer page in the UI can do it, why is it so complicated?
In my case, I’m not viewing it in the UI. I want to display it on my AWTRIX clock. For that I need something like {{ states (‘timer.boo_boo_timer’) }} to return the remaining time.