I've just gotten a Hue outdoor motion sensor and have ordered a few Sonoff ZBMINIs. I'll be using these to automate my outdoor lights in the backyard. The existing switches are just standard "dumb" toggle switches. I have three outdoor lights on different circuits that I want to automate to work together. I've learned that it helps for me to plan out my rules and think through the scenarios before I just dive into RM. I'd appreciate some feedback on this set of rules to see if I'm on the right track or if I'm missing something.
My intent is this:
Scenario 1: Outdoor illuminance greater than 50 lux. Motion detection does nothing.
Scenario 2: All lights are off and outdoor illuminance is less than 50 lux. If the motion sensor detects motion, all three lights come on for 5 minutes and then turn off.
Scenario 3: All lights are off, illuminance is any value. Any of the three switches connected to the ZBMINIs is toggled, all lights turn on and remain on. Toggling any switch will turn the lights off.
Scenario 4: All lights are on (based on previous toggling of a switch), illuminance is less than 50 lux. Motion is detected and the lights (which are already on) are commanded to turn on again. No perceptible change. Five minutes later the lights DO NOT turn off.
I'm planning to build my rules like this:
Create global variable, BackyardLightsOn (varBLO, for short) as a boolean. Motion sensor is MS1, ZBMINIs are SW1, SW2, and SW3.
Rule 1, Switch-based Operation:
Trigger: SW1, SW2, or SW3 is changed.
Actions: IF varBLO is FALSE, Turn SW1, SW2, SW3 to ON. Update varBLO to TRUE.
ELSE Turn SW1, SW2, SW3 to OFF, Update varBLO to FALSE.
Rule 2, Motion-based Operation:
Trigger: MS1 = Active.
Actions: IF lux > 50, Exit Rule.
ELSEIF varBLO = TRUE, Exit Rule
ELSE turn SW1, SW2, SW3 to ON.
Wait 5 minutes,
IF varBLO = FALSE, turn SW1, SW2, SW3 to OFF. (simple conditional)
I added that last conditional for the case that the lights are off, turned on by motion, and then I toggle a switch to keep them on. In practice, I think that the act of toggling the switch will turn the light off (due to behavior of ZBMINI) and it will immediately be turned on again by Rule #1. I think this will be acceptable, but I might have to add a short delay in Rule #1 to prevent the switch from changeing states too fast and getting out of sync.
As an option, I've thought about creating a third rule that will check illuminance and "Pause" Rule #2 if lux > 50. That way I could use this same rule to pause/resume any future rules that are only intended to run during daylight or darkness.
Thoughts or advice? Also, how does one handle the case of additional motion=active triggers that would occur during the 5 minutes that the lights are supposed to be on? I would like them to remain ON until the state has changed to INACTIVE for 5 minutes, as opposed to 5 minutes from the first ACTIVE state. So if motion is detected intermittently over a period of 3 minutes, the total time ON would be 8 minutes.