ta2four Posted February 25, 2015 Posted February 25, 2015 Hi, I have an ISY994i and I'm running firmware version 4.2.18. I'm new to programing ISY. I recently created the following program which was intended to flash lights 5 times: ------- If Control '**002 Kitchen Pots' is switched On Then Repeat 5 times Set '**003 Living Room Pots' On Set '**003 Living Room Pots' Off Wait 1 second Else - No Actions - (To add one, press 'Action') --------- The program above worked fine. The lights would flash 5 times and be turned off. I then wanted to augment the program to leave the light in the same state that it was before I started flashing it. I created two programs (one that checked if the state was already OFF) and the other that checked if the state was NOT OFF. ---------- If Control '**002 Kitchen Pots' is switched On And Status '**003 Living Room Pots' is OffThen Repeat 5 times Set '**003 Living Room Pots' On Set '**003 Living Room Pots' Off Wait 1 second Else - No Actions - (To add one, press 'Action') --------- and the second program: --------- If Control '**002 Kitchen Pots' is switched On And Status '**003 Living Room Pots' is not OffThen Repeat 5 times Set '**003 Living Room Pots' Off Set '**003 Living Room Pots' On Wait 1 second Else - No Actions - (To add one, press 'Action') ---------- The issue here is that the REPEAT loop is only executed once. The lights only flash once. Any ideas? Thanks, Ta
andyf0 Posted February 25, 2015 Posted February 25, 2015 Your repeat loop is interrupted because you changed the state of **003 Living Room Pots. Since this device is now part of the "if" statement it causes the repeat to be interrupted and the "if" re-evaluated.
ta2four Posted February 25, 2015 Author Posted February 25, 2015 In order to implement my feature I had to write 4 programs (see below). Basically I moved the REPEAT Loops into a separate program and called them from controller programs. ---------- Program 1: Call Tim Control Off If Control '**003 Living Room Pots / 003H Call Tim' is switched On And Status '**003 Living Room Pots' is Off Then Run Program 'Call Tim Leave Off' (Then Path) Else - No Actions - (To add one, press 'Action') -------- Program 2: Call Tim Control On If Control '**003 Living Room Pots / 003H Call Tim' is switched On And Status '**003 Living Room Pots' is not Off Then Run Program 'Call Tim Leave On' (Then Path) Else - No Actions - (To add one, press 'Action')-------- Program 3: Call Tim Leave Off If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Repeat 5 times Set '**003 Living Room Pots' On Set '**003 Living Room Pots' Off Wait 1 second Else - No Actions - (To add one, press 'Action') ---------------- Program 4: Call Tim Leave On If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Repeat 5 times Set '**003 Living Room Pots' Off Set '**003 Living Room Pots' On Wait 1 second Else - No Actions - (To add one, press 'Action') --------
ta2four Posted February 25, 2015 Author Posted February 25, 2015 Thanks for confirming this Andy. It is not entirely obvious that this is what was happening, but my solution and your comment confirms it. In other programming languages, when you are inside of the "THEN" or "ELSE" clause of an IF---THEN---ELSE statement the programming language would not re-evaluate the IF "Condition" again inside a WHILE or REPEAT loop. However, there are certainly cases for wanting this, but the condition is usually listed as part of the REPEAT block and not in the outside block.... That is, the language syntax would normally be "IF <condition> THEN <statement> ELSE <statement>" And a "REPEAT" is another statement that COULD be implemented as: REPEAT <statements> WHILE <condition> Where <condition> in the REPEAT loop is not the same as the <condition> in the IF statement. But here the implementation of the REPEAT statement is using the same condition of the IF statement... which to me is rather bizarre. Is there any documentation for the language syntax that the ISY is using?
LeeG Posted February 25, 2015 Posted February 25, 2015 (edited) The ISY Wiki is a good source. This link covers various Program statements including Wait and Repeat that allow If section to reevaluate.http://wiki.universal-devices.com/index.php?title=ISY-99i/ISY-26_INSTEON:Program_Commands Edited February 25, 2015 by LeeG
larryllix Posted February 26, 2015 Posted February 26, 2015 (edited) The ISY Wiki is a good source. This link covers various Program statements including Wait and Repeat that allow If section to reevaluate. http://wiki.universal-devices.com/index.php?title=ISY-99i/ISY-26_INSTEON:Program_Commands Unfortunately, the repeat information in this linked wiki is stated incorrectly as are the syntaxes of both forms of Repeat in the ISY programming. The descriptions should read: "Repeat Every Time causes the Repeat block to repeat with a Wait time specified amount of time (hours, minutes, seconds) on each repeat loop." ie. The loop time in a "Repeat Every Time" will be the total of Time plus any Wait times used inside the Repeat loop statements. "Repeat For Times causes the Repeat block to execute the specified number of times." ie. "Repeat For 1 Times" does not repeat the lines inside the Repeat For any times but rather executes the inside code lines only once without any repeat. Edited February 26, 2015 by larryllix
larryllix Posted February 27, 2015 Posted February 27, 2015 Thank you.Remember this is a real time system and anytime the if section is retriggered by the involved devices changing state the If section is re-evaluated and the Then and Else section is either restarted or stopped and the other section started (retriggered).
Recommended Posts