Turn Porch Light off with delay after turning on with Motion

I have a Wyze Camera on my front porch which detects motion. I created a "Virtual Switch" called "Front Door Motion" in hubitat. In IFTTT when Wyze detects motion it turns on the virtual switch "Front Door Motion".

This switch is a trigger in my rule. The problem I have is this switch needs to be turned off in my Rules prior to any re-evaluation of the rule and it needs to be turned off after any delay I have in the rules. The reason is the Wyze cam will detect motion when the porch light is turned on or off which is a false "Positive" motion.

From my code where the light is turning off after a delay of 10 minutes, the Wyze Cam detects motion and IFTTT turns the virtual switch on. As you see in my code, the last line is to turn off the switch after everything has been evaluated, but I think the rule is re-evaluated independent of the delay statement causing the light to just turn back on .

Your rule has a lot of triggers: do you really only want the porch light to turn on when there's motion (the only thing you mentioned), or do you also want it to turn on or off based on mode or illuminance (as the rule actions also do)? You can check for illuminance and/or mode in the actions, as you're already doing, without using them as triggers (where they will force running of the actions if the trigger event fires). That aside...

What is the problem you're seeing? I know you said "I think the rule is re-evaluated independent of the delay statement causing the light to just turn back on," but Rule 4.0 doesn't have "rules" to evaluate, so I'm assuming you mean that the "Actions" section is running again. That will happen regardless of any delays you have in the actions--they run every time any trigger event fires. (That's why I asked to make sure you needed all of those as triggers.) Any delays already scheduled will remain scheduled unless you cancel them (by setting the "Cancel?" flag on them and having a "Cancel Delayed Actions" action run somewhere else to actually cancel them), but I don't know if that would explain your problem.

Something you may want to know is that setting a delay on an individual action (such as "Off," as you've done here) basically scheduled that job but continues running the rule. So a quick glance here suggests that if the conditions are right for your "Off: Porch Light --> after a delay of 0:10:00" action runs, you'll actually get it turning off 5 seconds later because it will go to the next action in your rule, with is the "Off: Front Door Motion --> after a delay of 0:00:05" in this case. (By the way, there's a hole in your illuminance logic: what if the value is between between 800 and 810 or equal to either of those values? The "ELSE-IF" could just be an "ELSE" to make this easier if you don't need to test for anything else.)

Could that explain the behavior you're seeing? Turning on logging in the rule might also help you see what's happening when to help narrow it down.

Yes: I want light turned on under certain conditions without the motion. The motion detection is only for late night through early morning when light would typically be turned off.

The 810 value for the illuminance is to not toggle if bouncing around 800-810, which most likely wouldn't happen. The 800-810 range is don't care.

The problem is the what you mentioned the rules continue to run even with scheduled jobs I guess I expected the "Delays" to cascade: Light off after 10 minutes, then 5 seconds later set switch to off, then continue to run actions.

This is what I was looking for:
On: Porch Light
Pause all actions for 10 minutes
OFF: Porch Light
Pause all actions for 5 seconds (Time to let light turn off and trigger IFTTT due to Wyze)
OFF: Front Door Motion
Continue to start over evaluating Actions from the TOP.

It's confusing, but a delay on an action delays that action but continues with the rest of the script. (In some cases, you can still create the cascade by making the next delays progressively longer, but since yours don't always follow the same code path I'm not sure you'd want to.) A "standalone" action of "Delay" will pause the script on that action, so that sounds like the best thing to do here, in case I wasn't clear above. I think you'd also want this (at least the first one) to be cancelled on a re-trigger, otherwise even if the rule actions run again due to another trigger firing, the job scheduled by this delay will still be there, lurking and waiting to finish executing when it's time.

I will give that a try.

Thank you
-Leon