Hey there,
It’s me again with a weird / complex automation/trigger question
I’m trying to get one or two automations done that will control my X-Mas lights on the balcony. To not blind my neighbors and make them get epileptic attacks, I want to enable an effect every 10 minutes and let it run for just 5 minutes. So I was planning to have two automations:
- One that sets an effect every 10 minutes
- One that resets it to a solid color / disables the effect
- Aaaaand both of these only between 6 and 10pm
So I found the time_pattern
platform and thought that would be it. As somebody who’s used to write crontab entries in his past, that sounded like it.
If the time_pattern
would work as I expected it to work (== like crontab), there are basically two solutions to my requirement:
- Have two automations: One running every 10 minutes that sets an effect and one every 5 minutes that disables any effect. But the issue here is, that I can’t guarantee the execution order, so the activate might run first and a second after the deactivate automation. So I thought solution two is more suitable:
- Again two automations: One runs at minute 0, 15, 30, 45 to activate an effect and one that runs at minutes 5, 20, 35, 50 to deactivate any effect. This would work perfectly.
Of course, both would also have a condition to run only between 6 and 10pm. Somehow.
Unfortunately, all my attempts fail to use the time_pattern
platform. My first try was this:
trigger:
- platform: time_pattern
hours: [18,19,20,21,22]
minutes: [0,15,30,45]
This is not throwing any error and I can successfully reload the automations. But it doesn’t work. It’s doing something “random”. Maybe it’s just executing the last working state of that automation. I actually don’t know. But it’s not doing what I expected it to do.
I also tried specifying it as a comma separated string, but that even results in an error when trying to reload the automation.
So despite it being “hours” and “minutes” (plural!), it seems to only accept a single minute or hour!?
Also, is it even possible to specify both “hours” and “minutes” in the same trigger? Or do I need to specify two triggers with an “and”?
I know, that there are probably other ways to solve this with weird template triggers (found something close to that I want to do in the forums already) or maybe even combining the time_pattern
trigger with one or more conditions and probably also here template comparisons…
I’m just wondering what the limits of the time_pattern
trigger are and if somebody managed to do something more complex than just a single minute/hour or using the “/x” pattern. The docs are not that helpful, as they don’t give too many examples: https://www.home-assistant.io/docs/automation/trigger/#time-pattern-trigger
Or maybe somebody even has an automation that does something similar to what I want to do
Thanks and greetings,
Andy!