#Trigger automation 1 minute before the timer finishes?

1 messages · Page 1 of 1 (latest)

long geyser
#

I'm trying to figure out the best way to trigger automation once the timer reaches 1 minute before it ends. Is there a good, reliable way to do that? The only two ways (not the best one) I can think of are:

  • set second timer with time set to original's time - 1 min and wait for timer.finished event.
  • in automation, set trigger as template: {{ (as_timestamp(state_attr('timer.my_timer', 'finishes_at')) - now().timestamp()) | int < 60 }}

As the first one looks like working reliably, it's a bit of overkill to create additional timers and keep them in sync…
The second solution kind of works cause it rarely gets executed at the proper moment (I believe templates can be triggered once every minute or so).

Any other ideas?

remote quiver
#

a now() template will only update every minute, yes
the only thing i can think of is - instead of using a timer helper, if you instead made a calendar and stored the trigger time in there as a 1s long event, you can easily do an offset to "event start". but you obviously lose a load of timer controls like pausing etc unless you re-implement them in automations yourself
Honestly I think just having 2 timers is probably the easiest solution - you could make a script to interact with them to ensure you only ever set/reset/etc them together

celest current
#

I suggest instead of two timers, just make a timestamp sensor of the finishes_at attribute with a template.

You can then use that sensor in a time trigger, with offset -1 minute.

long geyser
#

That's nice @celest current, sounds like something that may work 😉