TJP_426 Posted December 24, 2011 Posted December 24, 2011 I have a program that runs after sunset that checks the condition of a few interior lights status after the garage door sensor opens to ensure I my wife does not come home to a dark house. I want the program to turn on two lights and then 5 minutes later turn off only the laundry room lights. I can't seem to get my syntax down. When the garage door closes after pulling the car in the status then becomes false and negates the then commands. If I add the timer sequence to the else command anytime the light is turned on it turns off 5 minutes later. The code is below. Thanks in advance! If Status 'Garage Door Sensor' is On And Status 'Kitchen - Under Cabinet' is Off And From Sunset + 15 minutes To Sunrise - 3 hours (next day) Then Set 'Kitchen - Under Cabinet' On Set 'Laundry Room - L [East]' On Wait 5 minutes Set 'Laundry Room - L [East]' Off Else - No Actions - (To add one, press 'Action')
oberkc Posted December 24, 2011 Posted December 24, 2011 Try "control" rather than "status". Control will be triggered only by an "on" command. Status is triggered by ANY change in status. If >>>control 'Garage Door Sensor' is On And Status 'Kitchen - Under Cabinet' is Off And From Sunset + 15 minutes To Sunrise - 3 hours (next day) Then Set 'Kitchen - Under Cabinet' On Set 'Laundry Room - L [East]' On Wait 5 minutes Set 'Laundry Room - L [East]' Off Else - No Actions - (To add one, press 'Action')
TJP_426 Posted December 24, 2011 Author Posted December 24, 2011 oberkc, That was actually my thoughts as well intially, but the 'if' evaluates as false and proceeds to 'else' because of the sequence of events. State 1 = Garage door sensor is off. State 2 = Garage door sensor is on. 'If'a runs (assuming remainder of 'and' conditons are satisfied) during this time to garage door sensor returns to off (wifes closes door as she enters laundry room), then 'If' status becomes false, so the 'then' never reaches the 'wait' 5 minutes portion. If I add the 'wait' 5 minutes to the 'else' then anytime the light is turned on locally @ the switch this command turns the light off 5 minutes after. I am brand new to ISY-99 so this could easily be a glaring ommision on my part, but I believe I have an intial understanding of the logic (I hope...) Thanks again!
LeeG Posted December 25, 2011 Posted December 25, 2011 Minor point but the Then does execute the Wait. It is the Wait (or Repeat) that allows for the reevaluation because Status has changed. If there was no Wait (or Repeat) the Then clause would run to the end regardless of the change in Status. The suggestion oberkc made regarding changing the If Status to If Control would have allowed the original Program to work. There is no change in state when using If Control 'xxxx' On when the I/O Linc issues the Off command.
oberkc Posted December 25, 2011 Posted December 25, 2011 'If'a runs (assuming remainder of 'and' conditons are satisfied)during this time to garage door sensor returns to off (wifes closes door as she enters laundry room), then 'If' status becomes false, so the 'then' never reaches the 'wait' 5 minutes portion. If you use "control", shutting the garage door (turning the sensor off) will NOT, by itself, trigger an evaluation of the program. "Control On" is only triggered by receipt of the "on" command. Off, dim, bright, will not trigger an evaluation. Given that the program is not triggered, there is no evaluation rendered. Of course, your wife could come in, open the door (triggering the program), then turn on the undercabinet light before the five-minte wait. This WOULD trigger an evaluation (status), which would then render a false conclusion, interrupting the wait, and sending the program into the "else" path. Alternatively, your wife could come home at sunset-3:01 hours, and trigger the program. A minute later, the program would trigger again (sunset - 3 hours) and send the program to the else path. One needs to look at what triggers evaluations of programs here, as well as the logical conclusions resulting from those evaluations: - Status is triggered at ANY change of status - Time from XXX to YYY is triggered twice: at time XXX and YYY. - Control is triggered only upon reciept of the specific command, whether off or on. Control on will NOT be triggered by an OFF command.
ergodic Posted December 26, 2011 Posted December 26, 2011 TJP_426: My suggestion for this kind of thing usually is to break the triggers and the actions into two separate programs so a false trigger condition re-evaluation cannot interrupt itself. If there are any problems with your logic they also will be easier to spot. If Control 'Garage Door Sensor' is On And Status 'Kitchen - Under Cabinet' is Off And From Sunset + 15 minutes To Sunrise - 3 hours (next day) Then Run Program DoLights (Then Part) Else - No Actions - (To add one, press 'Action') //DoLights Program If - No conditions Then Set 'Kitchen - Under Cabinet' On Set 'Laundry Room - L [East]' On Wait 5 minutes Set 'Laundry Room - L [East]' Off Else - No actions DoLights has no conditions, so it only runs when it is explicitly called. And it also cannot be interrupted once started unless you create another program that calls its Else. For example, you might want to create another program to cancel (run the Else part of DoLights) if somebody manually changes the status of the lights while the program is in the 5 minute wait. With this, it shouldn't matter to the execution whether you use Control or Status, though Control is probably the better choice.
Recommended Posts