I have a case where a button-press would start a timer for 1 hour, and if the button was pressed again, add another hour, and a third press would make it a total of 3 hours. The remaining time would be presented on a screen.
When less then 1 hour remains you should be able to press the button again to extend the time.
The “What the heck?!” is that there is no sensor or something that can give you the time remaining.
In a perfect world there would be a sensor for the timer with the time remaining.
And also the possibility to add/remove time from the timer.
Absolutely! I’ve been looking for a way to do this for quite some time… and there’s never been a good way to do it.
I have a timer that displays while a given entity ID is ‘on’. The entity is supposed to turn off after a few min on it’s own, but occasionally it does not. As a ‘backup’ i have a HA timer that starts counting down once the entity ID is on.
If i do something like this in my lovelace config:
- type: vertical-stack
# See: https://www.home-assistant.io/lovelace/vertical-stack/
cards:
- type: entity-button
name: SomeEntity
entity: switch.some_device
# If the timer is counting down....
- type: conditional
conditions:
- entity: timer.some_device_max_duty_time
state_not: "idle"
card:
# ... show how much time remaining
type: entity
entity: timer.some_device_max_duty_time
attribute: remaining
I only ever see the initial time that the timer is set to. I would expect that the value displayed reflects the counting down nature… After all, this works as expected:
# In lovelace:
- type: vertical-stack
# See: https://www.home-assistant.io/lovelace/vertical-stack/
cards:
- type: custom:bignumber-card
entity: sensor.human_date
# In sensors:
# There's no "easy" way to get the simple date (MM/DD, no YY) so we template it
# This is used for dashboards as a 'wall clock'
- platform: template
sensors:
human_date:
# Will be in format like 'Sat Nov 30'
# See: http://strftime.org/
##
# Note: the \n in there to *force* a new line for display in love lace
value_template: "{{ now().strftime('%H:%M\n%a %b %d') }}"
friendly_name: "Human Date"
##
# Note: Home Assistant will NOT update the value unless the tempalate is associated w/ an entity
# that fires off state change events.
entity_id: sensor.time
So the value of the template sensor is constantly changing which is reflected on the UI but the value of a counting down timer is not!?!?
I was just in the progress of raising this before I found this topic.
As mentioned above, it is widely discussed on these forums that the ‘remaining’ attribute of a timer doesn’t update unless an event is fired in the backend - the countdown that occurs on the frontend is purely frontend driven and is not fed back so, can actually get slightly out-of-sync with the actual timer.
While it would be great to have this attribute updating live, as a go-between, it would be nice to have a service which could be called such as timer.refresh or timer.update that would fire an empty event on the timer and update it’s attributes.
This could then be built in to templating avoiding hacky work-arounds (such as last triggered offsets from now, or firing an event such as timer.pause, then timer.resume to update it’s value)
I don’t think so, I’ve been trying to get the remaining time all night but it looks like the attribute is still stale.
It’s hacky but you can work around it by pausing then immediately starting the timer. I’m doing this in Node Red and so far it’s working well. You’ll see a flicker if you display the remaining time on your dashboard though.