Case Study - NightlightPro
Demonstrates a handoff of timers between two motion sensors. Some may term this a cascade or a flip. Each motion sensor will change the others timers giving the effect of a cascade from one sensor to the other. This example will demonstrate the use of 2 variables along with switch and case statements.
This coRE was an idea based off of the groovy runin() scheduling functions. After some experiments, I found I could use the same methods inside of CoRE. It stated:
By default, if a method is scheduled to run in the future, and then if another call to runIn() with the same method is made, the last one overwrites the previously scheduled method. This is usually preferable.
Scene: Between midnight and sunrise, turn on bulb for 15 seconds if Motion Sensor 1(MS1) is active. Wait 10 seconds to see if I walked from MS1 to Motion Sensor 2(MS2). If MS2 is active, change the wait time from 15 seconds to 60 seconds. However, if I walk back into MS1, reset timer to 10 seconds. Turn off light after wait timer ends and all motion stops.
Requires:
2 Motion Sensors, Minimum (Switch statement may be extended for more sensors)
1 Bulb, Minimum
Before starting, set for expert mode: Settings->ExpertFeatures turn ON Expert Mode
*Note in my example, I use 3 motion sensors:
Bed Left Toe Motion Sensor
Bed Right Toe Motion Sensor
Bathroom Toe Motion Sensor
You’ll note on the Trigger of the motion sensors, you will be adding the variable @deviceList. This will return the current device activated such as ‘Bedroom Right Toe Motion Sensor’ in this example.
Here is a different view of the code. First, the ‘If True’:
And the ‘If False’:
You’ll then place each of the ‘If True’ and ‘If False’ with ‘between midnight/sunrise’ (my example shows testing of sunrise and sunset)