Illusion Posted May 1, 2012 Posted May 1, 2012 I think I am having a brain failure. I should know this but I am stumped. I have a really complex program that is re-entering execution during a wait and I want to fix this today, but I cannot figure out what to do. So I made a small program that is simple and explanatory of my issue: If Status 'Kitchen / Kitchen Fan-Light' is On Or Status 'Kitchen / Kitchen LEDs' is On Or Status 'Office / Office Fan' is On Or Status 'Office / Office Hutch Lights' is On Then Wait 10 seconds Set 'Office / Office Desk Lamp' On Else - No Actions - (To add one, press 'Action') For this example I want the desk lamp to come on 10s after any of the other units in the if come on. The problem here is that as long as I am changing some of the units in the condition I can keep the desk lamp from coming on. Even though the program is always true as I leave one of the conditions units on, the new status of another device in the if causes a re-entry into the wait and the desk lamp does not come on. So I logically split this into two programs: If Status 'Kitchen / Kitchen Fan-Light' is On Or Status 'Kitchen / Kitchen LEDs' is On Or Status 'Office / Office Fan' is On Or Status 'Office / Office Hutch Lights' is On Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') If Program 'Test Program' is True Then Wait 10 seconds Set 'Office / Office Desk Lamp' On Else - No Actions - (To add one, press 'Action') But this suffers the same issue. Even though the test program is true, and an event causes an evaluation of the status that results in 'true' so the program status does not change, the second program re-evaluates and I can keep the desk lamp from coming on as long as I change conditions in the test program before it gets through its wait, but always being true. How do I set this up so the desk lamp comes on 10s after any of the other units come on, but not if all of the units are off before the wait expires? In the real program, the issue is that I have lots of conditions. I want something to happen, but only after 10m of 'True'. I do not care how the conditions change, as long as it has been 'True' for 10m. If at anytime in the 10m wait there is a condition of 'False' I do not want execution.
io_guy Posted May 1, 2012 Posted May 1, 2012 Use a state variable. In the first program's then, statevar = 1. In the else statevar = 0. In your second program, use the statevar as the if, not a program state.
Illusion Posted May 1, 2012 Author Posted May 1, 2012 Thanks for the quick reply!! Works great. An interesting distinction between variables and using programs as flags. It had not occurred to me that setting up a variable as a 1 or 0 would be any different that the true-false condition of a program, but here we are. And indeed you solution works perfectly.
Illusion Posted May 1, 2012 Author Posted May 1, 2012 So, just out of curiosity, as the state variable idea is working great, how would we have done this before variables?
apostolakisl Posted May 1, 2012 Posted May 1, 2012 So, just out of curiosity, as the state variable idea is working great, how would we have done this before variables? How about this Program 1 If Status 'Kitchen / Kitchen Fan-Light' is On Or Status 'Kitchen / Kitchen LEDs' is On Or Status 'Office / Office Fan' is On Or Status 'Office / Office Hutch Lights' is On Then Run program 2 then clause Else - No Actions - (To add one, press 'Action') Program 2 If No condition Then Disable Program 1 Wait 10 seconds Set 'Office / Office Desk Lamp' On Enable Program 1 Else - No Actions - (To add one, press 'Action') Haven't tested it, but it should work
Illusion Posted May 1, 2012 Author Posted May 1, 2012 A cool idea, using disable. But my requirements are that should the conditions become false during the wait, the action does not execute.
apostolakisl Posted May 1, 2012 Posted May 1, 2012 A cool idea, using disable. But my requirements are that should the conditions become false during the wait, the action does not execute. Program 1 If Status 'Kitchen / Kitchen Fan-Light' is On Or Status 'Kitchen / Kitchen LEDs' is On Or Status 'Office / Office Fan' is On Or Status 'Office / Office Hutch Lights' is On Then Run program 2 then clause Else - No Actions - (To add one, press 'Action') Program 2 If No condition Then Disable Program 1 Wait 10 seconds Set 'Office / Office Desk Lamp' On Enable Program 1 Else - No Actions - (To add one, press 'Action') Program 3 If Status 'Kitchen / Kitchen Fan-Light' is On Or Status 'Kitchen / Kitchen LEDs' is On Or Status 'Office / Office Fan' is On Or Status 'Office / Office Hutch Lights' is On Then - No Actions - (To add one, press 'Action') Else - Enable program 1 - Stop program 2
Recommended Posts