Guest Posted January 23, 2011 Posted January 23, 2011 I read through some of the posts on the forum related to timers, etc. and I want to make sure what I think is happening with my programs is happening and that this is the most efficient way. I want a MS to turn on a light after sunset/before sunrise. I also want there to be a timer that resets with every motion detected such that the timer then runs out x minutes after last motion. I think I have accomplished this but would like to run it by someone more knowledgeable. Here goes... Kitchen Motion Program: If Status 'Security / Kitchen:Motion-Sensor' is On And Status 'Lighting / Kitchen:Light' is Off And From Sunset To Sunrise (next day) Then Set Scene 'Scenes / Kitchen:Scene' On Stop program 'Kitchen Timer' Run Program 'Kitchen Timer' (If) Else - No Actions - (To add one, press 'Action') Kitchen Timer Program: If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 15 minutes Set Scene 'Scenes / Kitchen:Scene' Off Else - No Actions - (To add one, press 'Action') I did the stop program run program so that the timer is reset. Do I need to do this or will running the timer program again auto reset the timer? Also, does it have to be a separate timer? Could I just run the timer as an action in the Motion Sensor program? Thanks
Chris Jahn Posted January 23, 2011 Posted January 23, 2011 Although not needed in this example, here's a couple rules of thumb for ISY programs: 1) If your actions contain a wait or repeat and you don't want them interrupted then split the program into two programs, with the first containing the conditions, and one second containing the actions. Use 'Run Then' in the first program to start the actions in the second program. 2) If you want to have some conditions trigger the program, and others not trigger the program then split the program in into two programs, with the first containing the trigger conditions, and the second containing the non-trigger conditions and actions. Use 'Run (If)' in the first program to start the second program running. The second program should be disabled (ie. not automatically triggered). As for your specific example, these programs will turn the light on/off using the motion sensor unless the light was already on. The reset program stops the off timer if you manually turn the light off/on after the motion sensor turns off. All programs are enabled: KitchenMotion.On If Status 'MotionSensor' is On And Status 'KitchenLight' is Off And From Sunset To Sunrise (next day) Then Set 'KitchenLight' On Run Program 'KitchenMotion.Flag' (Then Path) Else - No Actions - (To add one, press 'Action') KitchenMotion.Off If Status 'MotionSensor' is Off And Program 'KitchenMotion.Flag' is True Then Wait 15 minutes Set 'KitchenLight' Off Run Program 'KitchenMotion.Flag' (Else Path) Else - No Actions - (To add one, press 'Action') KitchenMotion.Reset If Status 'MotionSensor' is Off And Status 'KitchenLight' is Off Then Run Program 'KitchenMotion.Flag' (Else Path) Else - No Actions - (To add one, press 'Action') KitchenMotion.Flag If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') There is another example here showing how to implement a state machine for more complex cases.
oberkc Posted January 23, 2011 Posted January 23, 2011 Is "kitchen light" part of the scene "kitchen:scene"? If so, then I am concerned that this program will not re-trigger at each motion detect (because the first condition will evaluate false when the kitchen light is on). Also, I suspect you could have better luck with "control" rather than "status" on the motion sensor condtion: control 'MotionSensor' is turned On There is a very thorough example on the wiki, in case you have not found it.
oskrypuch Posted January 23, 2011 Posted January 23, 2011 +1 on control vice status. Believe this is the wiki reference, yes? ... Using Motion Sensors in Bathrooms * Orest
TJF1960 Posted January 23, 2011 Posted January 23, 2011 I did the stop program run program so that the timer is reset. Do I need to do this or will running the timer program again auto reset the timer? Also, does it have to be a separate timer? Could I just run the timer as an action in the Motion Sensor program? I believe you can delete the stop and change "Run Program 'Kitchen Timer' (If)" to "Run Program 'Kitchen Timer' (Then)." I also believe you do need 2 programs because of the "And Status 'Lighting / Kitchen:Light' is Off." If it were all in one program once the program turned the light on the status would change and the program would turn false thus killing the wait. So the light would not get turned off. Great job on programming! Tim
Recommended Posts