I have a 2 motion sensors (one upstairs and other downstairs) and depending on specific conditions, I'd like to perform multiple actions .. wanted to get your thoughts on what might be a better way:
Requirements:
1. Continue to turn downstairs lights on for 5 min when detect motion downstairs between sunset and 8 pm
2. Continue to turn upstairs lights on for 20 min when detect motion upstairs between sunset and 10 pm
3. Continue to turn downstairs thermostat on for 15 min when detect motion downstairs between 4 pm - 7 pm
4. Continue to turn upstairs thermostat on for 30 min when detect motion downstairs between 4 pm - 9 pm
5. Turn few other lights on when motion detected both upstairs and downstairs (under certain conditions)
6. Few other requirements on similar lines ..
Approach A:
Each requirement becomes a set of programs of it's own, for example
-- when detect motion downstairs between sunset and 8pm, call a program to turn downstairs lights on for 5 min
-- when detect motion upstairs between <conditions> , call a program to <take action>
-- similar set of programs
Approach B:
Create a program to detect motion downstairs and yet another one to detect motion upstairs. Any every time a motion is detected it calls sub programs that evaluate conditions and take action, for example:
-- when detect motion downstairs, call the following programs:
--- if between sunset and 8pm, turn downstairs lights on for 5 min
--- if between 4pm - 7pm, turn downstairs thermostat on
--- similar set of programs
The key difference in the 2 approaches is that first one fires when the all conditions are true and will fire only during few hours in the evening. However, in approach B, the main program will fire all the time (even if there is motion detected in the morning hours), but the sub programs will evaluate whether or not the condition is true to take an action.
What are your thoughts on which might be better? Or if there is yet another more elegant way to achieve this?
Thanks so much for your inputs.