I have a virtual switch that is turned on when my back doorbell button is pressed. Then I have a rule that is triggered by that virtual switch being turned on to turn my carport light on. In this rule I want one of two events to turn the light off. Currently I have it to wait for an elapsed time of 5 minutes and turn the carport light off. I would also like for there to be an "OR" event of a contact sensor closing (door closed) after a door has been opened to turned the light off. Concept is if doorbell is pushed the carport light comes on. If the back door is opened and then closed the light goes off, but if no one is home to open and close the door then after 5 minutes the light goes off. I have tried to figure out how to put both these conditions in but I can't figure it out. I am open to any help and suggestions.
Below is a screenshot of my current rule with only the wait event of elapsed time.
Then I didn't do a good job explaining because this rule does exactly what I want when I want for both the light and turning off the virtual switch that is activated regardless the time of day when it is pushed (the door bell doesn't give me sunset to sunrise only times and I want that to change naturally not be a fixed time). So I use the if statements inside the rule to clarify what to do inside the day because the rule needs to run every time the doorbell is pushed.
The only thing different is I want to add the door opening and closing as a trigger to turn off as well but I can't figure out how to do that. Rule Machine won't seem to let me do a time period or a contact sensor. I can do either or do two physical items such as sensor and switch but not time and sensor.
I see that the rule I outlined would leave the virtual switch on during the day. Why don't you just set the virtual switch to auto-off after 10 seconds and remove the off command for the virtual switch from the rule?
I think when you say 'trigger to turn off' you mean the wait for event action? What I described is exactly how you do either a device or an elapsed time. Use the timeout option in the wait action.
The rule will continue after either the door closes, or 5 minutes passes without the door closing.
I didn't know you could do an auto off on the switch. I will have to look into that or if you can give a quick explanation.
When I get home tonight I will try setting it up. My problem was when I put the door in the rule I couldn't find an option for time. It was like that option disappeared. I must be overlooking it
The other thing to know based on the picture that @Alan_F provided, is that you could add another Wait Event and it gets treated as an "OR". With your elapsed time wait, you could also add a Wait for Event of the contact being closed. This would give you two different Waits without the timeout. Here is an example of overnight lighting in my house:
You'll see that there are two different Wait for Events that would allow the rule to progress with both being covered via a timeout.
The example provided of the contact closing with a timeout is probably a little bit cleaner, but it is possible to do what you wanted in the initial post.
Something like this is what originally had in mind with "wait for 5 minutes and no other actions light turns off" or "the contact sensor closes the light turns off even if that is before the 5 minutes is up".
Problem I was running into is I can't figure out a way to use the wait time or the contact sensor. I can do the "or" for two different physical wait events but I can't mix a "time" wait and a "physical" event wait if that makes sense.
The timeout may have to be the route to go. If you know how to get a wait for a physical event to happen or wait for a time event to be on the same wait event line in a rule please let me know.
When editing an elapsed time event, it's coded as timeout. Basically, just put in the contact sensor as closing with a timeout and it means the exact same thing as what you want.