#Trigger an automation every n minutes in a certain time window

14 messages · Page 1 of 1 (latest)

pastel echo
#

Hello, I want to have an integration that gets triggered every x minutes between, say 9pm and midnight. The best thing I can figure out so far is to use a cron expression trigger (also known as time_pattern) and check in the conditions whether we are in the required time window. That seems a bit wasteful though. Is there a better way to do that?

somber sorrel
#

Nope. That’s the way you do it.

#

You could use a template trigger (or binary sensor template helper), but that’s actually worse.

shut lake
#

If you really want to cut down on the automation triggers for some reason - add 2 more triggers, one to enable the time pattern trigger at the start of the time period, and another to disable it at the end

somber sorrel
#

Enable/disable the triggers themselves in an automation? How?

shut lake
#

Ah no, ignore that, you'd need a second automation to enable/disable the whole first automation.

pastel echo
#

It's ok, if that's how it's done then that's how it's done. The reason I was asking is, I'm in software development long enough to know that the fact that something is a working solution doesn't necessarily mean it's not a totally cock-eyed solution. Oh the things I have seen...

somber sorrel
#

lol same. I have horror stories.

shut lake
#

i feel personally attacked

somber sorrel
#

But yeah, use the time pattern or go crazy with a template.

pastel echo
#

We have a saying in Germany: He whom the shoe fits will put it on.

#

😛

shut lake
#

My code is never meant for release!

somber sorrel
#

And only us pros debug in prod too. lol