I made a simple automation with trigger id’s to turn on a light when there is movement and turn it of after 5 minutes when there is no movement. This is done in 1 automation with a trigger id and if then.
I added a condition, to only let this work between sunset and 7:00am.
This is working great, but not when there is movement at 6:58. THe light won’t turn of after 5 minutes as the condition is after 7.00am. How can I fix this?
With this I have an other question. So with this automation you have to turn on thelight by hand during the day. I tried to add a trigger, which says that if light A is on for 5 minutes, it has to turn off. But that gives some strange behaviour. Any ideas how to solve this?
you need to post the automation(s) in yaml (no screensots) and ensuring that you format it correctly using ``` on the line before and after the code block.
the only way you can do it since you are using two opposing triggers in a single turn on/turn off automation is to move the time condition out of the ‘condition:’ section and into the ‘action:’ section. then use a ‘choose:’ in the actions with the time as a condition for the turn on action and no time condition (or a later time condition ie a few minutes later than 7 to accommodate the delay) for the turn off action.
general questions are very rarely that. it’s hard to visualize from a description what you are trying to convey when reading the code provides a concrete example.
also it helps others to help you by providing the details needed to allow us to copy/edit/paste the solution.
as in the example above there’s no way I could (or would) type all of that out by hand but using your existing code as a starting point allows me to better help you.
that said none of what I wrote has been tested or even checked for proper syntax but hopefully it works for you.
Unless you tag me (by using @finity) or click the reply button directly below a post of mine I don’t get notified that you’ve replied to me. So I then have to notice that the thread is in my unread posts list.
Here’s a way to do it using logically ORed Trigger Conditions, where the second one is logically ANDed with a Time Condition, and a single service call.
Here’s another way using State Triggers, logically ORed Template Conditions in shorthand notation where the second one is logically ANDed with a Time Condition, and no trigger id.
If you chose to use finity’s suggestion, please consider marking his post with the Solution tag.
If you chose to use either of my two suggestions, please consider marking my post with the Solution tag.
By marking the post with the Solution tag, it will automatically place a checkmark next to the topic’s title. This signals to other users that this topic has been solved and helps them find answers to similar questions. It also places a link in the first post that leads to the Solution post.
@123 In your code, I guess the second id: ‘on’ should that be off instead of on?
And thanks for the enhanchement tip, as I also have a PIR in my hallway. The lights turn on, but as we are moving there a lot for minutes, it means the automation is started many times, as the light was already on.
For now I implemented the solution by @finity and see if it works like i would like it But I am going to try yours too @123, as it learned me to think in automations.