edokid Posted September 23, 2014 Posted September 23, 2014 I think the answer is yes based on the program I just wrote and noticed working. If I have conditions like: If Status Kitchen Light is On And Status Laundry Light is On And Status Bathroom Light is On Then control Living Room Light On Wait 30 minutes control Living Room Light Off Else no action So basic example, I turn all 3 of those lights on the If becomes true, lights go on and we wait 30 minutes. If I turn the Bathroom light off, am I correct in that the If is no longer true therefore the program stops? And if I turn the bathroom light back on, If is now true and the 30 minutes starts over? I'd assume that no actions after the "Wait 30 minutes" would occur once any of the If conditions are no longer true? Thanks!
LeeG Posted September 23, 2014 Posted September 23, 2014 (edited) When the Conditions are no longer True the Wait is terminated and the Else clause runs. Should the If Conditions become True again the Program is triggered and the Then clause runs fron the beginning. Edited September 23, 2014 by LeeG
MWareman Posted September 23, 2014 Posted September 23, 2014 You are correct. Yes, to keep running true the conditions must remain true. Additionally, any reevaluation of conditions will cause 'Then' to start over. So, dimming one of the lights (still on though, and still evaluating true) will cause the If to reevaluate and restart the timer. Michael.
ISYhbsh01 Posted September 23, 2014 Posted September 23, 2014 You are correct on all counts. Sent from my SPH-D710 using Tapatalk
edokid Posted September 23, 2014 Author Posted September 23, 2014 That's great thanks so much, stumbled upon that by accident and was wondering why it was happening but now it will be so much easier to code.
LeeG Posted September 23, 2014 Posted September 23, 2014 One note, if any of the lights are dimmed the If is False as On means 100% On. To cover dimmed value the If would state If Status 'xxxx' is not Off rather than On.
EricK Posted September 23, 2014 Posted September 23, 2014 If you always want the living room lights to turn off after 30 minutes then create a second program. Add run program 2 "then" after the line to turn the lights on, delete the rest. Program two: If. Blank Then. Wait 30 minutes Turn control living room lights off. There are a lot of ways to set things up. I would typically create a scene for the living room lights and control the scene with the program. One reason to do this if you add any cross linked devices such as a Kpl with a button to control the living room lights, then you would add those to your scene. Your program would then turn on and off all scene members keeping them in synch. Eric
edokid Posted September 23, 2014 Author Posted September 23, 2014 Oh that program I just made up as an example to explain what I meant, I don't actually have any need to do that. I was writing a program to delay setting off security alerts if the doors are opened when the house is in Away mode and it popped up. Was easier to use the 3 lights example instead of mine
MWareman Posted September 23, 2014 Posted September 23, 2014 One note, if any of the lights are dimmed the If is False as On means 100% On. To cover dimmed value the If would state If Status 'xxxx' is not Off rather than On. Forgot that little nugget! Thanks!
paulbates Posted September 25, 2014 Posted September 25, 2014 Based on the learnings in this thread, I need to rethink this program. It kills my sprinklers if enough rain falls during the 4 hour sprinkling cycle. On my way out, I reset both variables that I check in the 'if' to see if I need to do it at all... If $Sprinkling_Now is 1 And $Ok_to_Sprinkle is 0 Then Stop program 'Sprinklers - Normal Run' Set 'Yard / Sprinklers / Master Valves / EZ1 Master' Off Set 'Yard / Sprinklers / Zone 01' Off Set 'Yard / Sprinklers / Master Valves / EZ2 Master' Off Set 'Yard / Sprinklers / Zone 08' Off $Partial_Sprinkler_Cycle_avoided += 1 Send Notification to 'Default' content 'Sprinking Canceled In Flight' $Ok_to_Sprinkle = 1 $Sprinkling_Now = 0 Else - No Actions - (To add one, press 'Action') If enough rain falls during the 4 hour cycle, cancel the remainder Do you think the last variable assignment step gets run, or does the previous step kill it? If not, do you think moving those two steps to an inactive program, and calling it's 'then', instead of resetting the variables will work?
larryllix Posted September 25, 2014 Posted September 25, 2014 (edited) Based on the learnings in this thread, I need to rethink this program. It kills my sprinklers if enough rain falls during the 4 hour sprinkling cycle. On my way out, I reset both variables that I check in the 'if' to see if I need to do it at all... If $Sprinkling_Now is 1 And $Ok_to_Sprinkle is 0 Then Stop program 'Sprinklers - Normal Run' Set 'Yard / Sprinklers / Master Valves / EZ1 Master' Off Set 'Yard / Sprinklers / Zone 01' Off Set 'Yard / Sprinklers / Master Valves / EZ2 Master' Off Set 'Yard / Sprinklers / Zone 08' Off $Partial_Sprinkler_Cycle_avoided += 1 Send Notification to 'Default' content 'Sprinking Canceled In Flight' $Ok_to_Sprinkle = 1 $Sprinkling_Now = 0 Else - No Actions - (To add one, press 'Action') If enough rain falls during the 4 hour cycle, cancel the remainder Do you think the last variable assignment step gets run, or does the previous step kill it? If not, do you think moving those two steps to an inactive program, and calling it's 'then', instead of resetting the variables will work? The first program can still re-initiate the second program's then will redo everything. IMHO this would be better. Use the "one and only one" technique. Program 1 --------------- If trigger event Then Run Program 2 Else --- Program 2 (disabled) -------------- If -- Then Disable Program 1 do stuff..... Enable Program 1 Else -- Edited September 25, 2014 by larryllix
larryllix Posted September 25, 2014 Posted September 25, 2014 (edited) I think the answer is yes based on the program I just wrote and noticed working. If I have conditions like: If Status Kitchen Light is On And Status Laundry Light is On And Status Bathroom Light is On Then control Living Room Light On Wait 30 minutes control Living Room Light Off Else no action So basic example, I turn all 3 of those lights on the If becomes true, lights go on and we wait 30 minutes. If I turn the Bathroom light off, am I correct in that the If is no longer true therefore the program stops? And if I turn the bathroom light back on, If is now true and the 30 minutes starts over? I'd assume that no actions after the "Wait 30 minutes" would occur once any of the If conditions are no longer true? Thanks! Here is a way some use to cancel the whole thing without leaving the light on. If Status Kitchen Light is On And Status Laundry Light is On And Status Bathroom Light is On Then Set Living Room Light On Wait 30 minutes Run This_Program (else) Else Set Living Room Light Off Edited September 25, 2014 by larryllix
LeeG Posted September 25, 2014 Posted September 25, 2014 paulbates There are no Wait or Repeat statements in that Program. The Then clause will run all the statements. The issue that started this topic was a Wait that allows the change in if Conditions to terminate the clause. When no Wait or Repeat is used the clause runs all the statements.
paulbates Posted September 25, 2014 Posted September 25, 2014 Thanks Sent from my iPad using Tapatalk HD
apostolakisl Posted September 25, 2014 Posted September 25, 2014 (edited) When the Conditions are no longer True the Wait is terminated and the Else clause runs. Should the If Conditions become True again the Program is triggered and the Then clause runs fron the beginning. This is not correct in all situations. In your particular example, it is correct, because all the conditions are "status" conditions, which are triggers upon any change in status. For a "wait" to terminate, the program must trigger, and not all conditions are triggers. example if status light is 100% and $integervariablex is 1 Then something wait something else. The above program DOES NOT abort the wait if the variable changes to something other than 1 because integer variables are not triggers. Only if the status of the light changes does the program abort the wait. Edited September 25, 2014 by apostolakisl
Recommended Posts