Persistent Timer (although it's not really a timer)

This is a two part Blueprint to create a ‘timer’ that is unaffected by a system restart (unless the restart happens at the exact same time as the intended action). It is triggered by a switch and turns a switch off but could easily be adapted for other entities.

It’s not really a Timer but I like to use automations like this if I have something I want to be sure is turned off, regardless of a HA restart. Taras has a solution for persistent Timers, so definitely worth checking that out, depending on your use case, but I find this a simple and great solution for my needs, so I created a blueprint based on automations I’ve read about in the community.

You need to create two automations for this - one saves the desired time to turn the switch off and the other triggers at that set time. The latter is turned off, once it completes, so it doesn’t keep triggering every day.

You need to create a few helpers for this: -

input_datetime.when_to_turn_the_switch_off

input_number.helper_hour

input_number.helper_minute

input_number.helper_second

You can display the input_numbers in a lovelace card e.g. entities card, with ‘Input Field’ selected.

You can import the first from: -

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

or, if you go to Configuration > Blueprints, you can import from: -

and the second from

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

or

I imagine it would be straightforward to include days in this automation as well but I don’t have that particular use-case.

I’m sure there’s more elegant solutions than this and so I hope someone else will create an even better version I/we can adopt.

Thanks

This is an interesting solution. Why use “input_number” sector and not just “number” or “duration” to input the time into the Blueprint itself? I suppose that allows you to change the duration in the UI. It would be nice if HA had a “duration” helper type. Personally I’d probably just use Minutes for a fan timer so I could reduce it to one input_number.

Hi, yes the input_number is used because it provides a versatile way of changing the duration and interacting with that, in a card on your dashboard. I think HA has got better at having timers that survive a restart but I like using this method, as it’s a very reliable way of making sure the second part of the automation happens when intended.

1 Like