Control lights logic with lots of triggers

Here's the logic I'm looking for:

If any of five contact sensors (doors) open OR any of two motion sensors detect motion
Turn on the garage light switch AND keep them on as long as any of the same two motion sensors keep detecting motion
Turn off the garage light switch after 20 minutes delay regardless of if any of the contact sensors are still open

I can get the logic to trigger on the contact open/motion active events but running to turn off timer that can get interrupted by new motion is giving me trouble. TIA!

1 Like

I'm about to finish my lunch break, so can't give this as much time as I should, but I think the kind of structure you want in your rule is:

Trigger Events: Motion / Contact conditions as per your post
Cancel actions
Turn on garage lights
Delay 20 minutes
Turn off garage lights

It's something close to that, others may be able to spell it out better than me or provide a better alternative, but hopefully this may help.


Probably should explain you need to ensure the actions are cancellable and the intention of the cancel actions step is to cancel any previous triggered instance of the rule, hopefully achieving what you are missing.

Excellent pointers in the right direction. Here's my interpretation of the guidance:

The Actions logic says (I think): Turn on the garage lights then set a delayed turn off of 20 minutes, unless motion A or B is active, then cancel that delayed off action.

I wonder if this says "cancel the turn off (delayed) action" or does it say "cancel the delay and go ahead with the turn off"?

1 Like

I don't think you need the condition, just move the cancel to be the first step / action

I.e. the rule being triggered again acts as the if condituon

I think you're going to get tripped up on that cancel delayed actions.
Here's a similar rule for garage door. If any door or motion gets triggered, then the lights turn on, but everything has to be closed and silent before they turn off.

Cancel delayed actions has to be used when the rule evaluates to false to keep the lights on.

You could put the cancel delayed actions in the top if and eliminate the end if remove the second if and kepe the else-if at the bottom for the same result. This was a rule that I built early on and never corrected. But it still works.

1 Like

OK, here's what Simon is saying AFAIK:

This logic says "Did a door open or motion event happen? Then cancel any previous delay, send ON to the lights, send Off +20 min to the lights." "Did it trigger again? Rinse, repeat."

1 Like

I believe that is the way that is meant to work

You can also look at this question I posted where I actually went against my own advice to you :grin:

Tinkering with this a little more, looking for a way to avoid lots of unneeded ON actions, I moved the ON and OFF actions into conditional loops. I let the Cancel action trigger no matter what (seems harmless) but then check to see if the lights are already ON and if so, re-establish the OFF +20 min status and exit. If the lights are OFF, then I do both the ON and OFF + 20 actions.

1 Like

Nice work

1 Like

I'd set the Garage Motion trigger to active to cut down on the number of times the rule triggers.