kevman Posted May 26, 2013 Posted May 26, 2013 So the objective of this program is to turn on the foyer light when ever I walk near the motion sensor (zone6) and only when the alarm is armed (stay_mode). The problem I have is when I turn on the foyer light manually it will simply turn off after one minute, which I don't want it to do. Can anyone point me in the right direction? If $Zone6 is 1 And Program 'stay_mode' is True Then Set Scene 'Foyer' On Else Wait 1 minute Set Scene 'Foyer' Off
arw01 Posted May 26, 2013 Posted May 26, 2013 so what is causing the variable to change and cause the if clause to evaluate and then be false so it runs the else? Alan
LeeG Posted May 26, 2013 Posted May 26, 2013 All changes to $Zone6 and Program 'stay_mode' trigger the Program. Most of the time the If is going to be evaluated False which results in the Wait and turning the Set Scene 'Foyer' Off. I assume these statements were put in the Else because the Set Scene 'Foyer' Off was not being executed when put in the Then clause. They don't get executed because a Wait allows the If to be reevaluated. The Program trigger condition changes to False during the Wait so the statement(s) after the Wait do not get executed. Rather than put the Wait and Set Scene 'Foyer' Off in the Else, split the logic into two Programs. The first Program triggers as coded now but invokes a second Program from the first Program Then clause which has the Then clause Then Set Scene 'Foyer' On Wait 1 minute Set Scene 'Foyer' Off This way the If in the first Program does not get revaluated because there is no Wait statement.
kevman Posted May 26, 2013 Author Posted May 26, 2013 Thanks Lee, I think that makes sense what do i put in the if statement of the second program?
LeeG Posted May 26, 2013 Posted May 26, 2013 Nothing is needed in the second Program If section. If $Zone6 is 1 And Program 'stay_mode' is True Then Run Program 2 Else If Then Set Scene 'Foyer' On Wait 1 minute Set Scene 'Foyer' Off Else
kevman Posted May 28, 2013 Author Posted May 28, 2013 Do I set it to Run (Then Path ) when I call it from the first program?
LeeG Posted May 28, 2013 Posted May 28, 2013 Does not matter. Run If is the same as Run Then in this case.
Recommended Posts