Monday at 11:00 PM1 day Hi - trying to find out if there is a way to do a nested "if". In other words - I need the "if" to be inside the "Then" and the "Else" (I need to do this for a variable test as part of a program that tests status of several devices). I cannot add this test as part of the first "if" because then the "else" will fire and run those commands - though I need the same "if" within the else.Basically the code would be:IF status Device_X is offAND status Device_Y is offAND status Device_Z is offThen if variable Poll_Running =1 Then do somethingElse if variable Poll_Running =1 then do something differentBottom line - if the Poll_Running variable is not 1 - then I don't want anything to happen irrespective of the state of the devices.Any thoughts?
Monday at 11:12 PM1 day If I understand your needs, Create the variable Poll_running as an integer type and add it to the If. They do not cause a program to trigger like state type. Edited Monday at 11:13 PM1 day by hart2hart
Monday at 11:16 PM1 day You can't have an IF statement in the THEN or ELSE statementYou can split it up into two programs Edited Monday at 11:18 PM1 day by Techman
Yesterday at 02:44 AM1 day There is a nasty way of doing most of these using "repeat while" construct.If whateverThen do something Repeat While 'lamp' < 1% do somethingElse set 'lamp' = 100% Repeat for 1 times do anotherthingElse --Of course you can set a variable before the repeat while loop and then modify it in the loop.Dirty but it can work in most cases.Multiple Case type constructs can be built by terminating each Case with a line: Stop 'ThisProgram' .Note: Repeat For X times is a program logical syntax error. 'Repeat 1 times' means no repeat at all. Should have been named: 'Execute for 1 times'.
Yesterday at 10:59 AM1 day 11 hours ago, SMonk said:trying to find out if there is a way to do a nested "if"@hart2hart 's solution should work in your particular situation. If, for some reason, you cannot change the variable to an "integer" type, then allow me to expand upon @Techman 's suggestion to try a second program:if IF status Device_X is offAND status Device_Y is offAND status Device_Z is offthen run a second program (if path)Second program (disabled):if variable Poll_Running =1then do something
23 hours ago23 hr Author 16 hours ago, hart2hart said:If I understand your needs, Create the variable Poll_running as an integer type and add it to the If. They do not cause a program to trigger like state type.I originally thought about this (the Poll_Running variable is already an integer - set by a prior program). Unfortunately if I add th ePoll_Running variabel to the if clause - then when this runs if Poll_Running is "not" 1 - then it will default to the "else" clause when triggered - which I do not want it to do.
23 hours ago23 hr Author 4 hours ago, oberkc said:@hart2hart 's solution should work in your particular situation. If, for some reason, you cannot change the variable to an "integer" type, then allow me to expand upon @Techman 's suggestion to try a second program:if IF status Device_X is offAND status Device_Y is offAND status Device_Z is offthen run a second program (if path)Second program (disabled):if variable Poll_Running =1then do somethingYes - this is the approach I decide to try out. It does work - but it's just a lot of programs (as I need to do this for many rooms (one program per room, and one line of the if statement for each device in a room) - hence looking to try and reduce number of programs by finding some potential alternative. 12 hours ago, larryllix said:There is a nasty way of doing most of these using "repeat while" construct.If whateverThendo somethingRepeat While 'lamp' < 1%do somethingElseset 'lamp' = 100%Repeat for 1 timesdo anotherthingElse--Of course you can set a variable before the repeat while loop and then modify it in the loop.Dirty but it can work in most cases.Multiple Case type constructs can be built by terminating each Case with a line:Stop 'ThisProgram' .Note: Repeat For X times is a program logical syntax error. 'Repeat 1 times' means no repeat at all. Should have been named:'Execute for 1 times'.This is very interesting - I have never used the "Repeat While" function - I will investigate that. This "could" be the solution to reducing the number of programs significantly. I'll let you know how it goes.
23 hours ago23 hr The second program method is the way I do it. The second program is a disabled program that only gets run by the first program. I even name it starting with DNE (for Do Not Enable) to make it stand out.
23 hours ago23 hr Author 6 minutes ago, Guy Lavoie said:The second program method is the way I do it. The second program is a disabled program that only gets run by the first program. I even name it starting with DNE (for Do Not Enable) to make it stand out.That is very interesting - so if you mark a program as disabled you can still call it? I was not aware of THAT - I thought if it was disabled - then it is disabled. Thate introduces some quite interesting concepts for me.Just to clarify - setting to disabled then really only means "do not react automatically to status or control changes within the insteon network" (for example if I use a Status or a Control element in the "if" for a device - if that device is manually turned on or off - the program will not fire), however it WILL run if I call it from another program?Very interesting - please confirm that my understanding of that is correct.
23 hours ago23 hr Author 13 minutes ago, Guy Lavoie said:The second program method is the way I do it. The second program is a disabled program that only gets run by the first program. I even name it starting with DNE (for Do Not Enable) to make it stand out.No all you have to do is tell me how to make program calls in a synchronous manner (so that my parent program waits for the called programs to finish before executing the next command) rather than executing them all (basically) simultaneously and then moving on immediately LOL.If you can do that - I'm thinking you may also have a solution for world peace?
22 hours ago22 hr 41 minutes ago, SMonk said:Very interesting - please confirm that my understanding of that is correct.Yes, that's how it works. A disabled program won't be run by the main IoX routine, but can be run on demand by another program. I use this in a garage door routine that updates the backlight of a keypadlinc button even if the garage door is operated manually. As you want to do, this is like a nested IF.39 minutes ago, SMonk said:No all you have to do is tell me how to make program calls in a synchronous manner (so that my parent program waits for the called programs to finish before executing the next command) rather than executing them all (basically) simultaneously and then moving on immediately LOL.There are two ways to do this: inefficiently, or ugly! The inefficient way is to use a Wait statement to pause the operation of your first program, to allow the second one time to run. Inefficient because you need to wait a bit more than usually required to be safe (that's it's actually finished) and for that to work, the triggering status of your first program has to remain true for the time the Wait finishes. So if your second program changes the status of one of your devices that triggered your first program, the Wait and the rest of the program just gets canceled.The ugly way is to use...a third program. You could put the commands you want to run after the second program is finished into a third program, which either the second program runs (set it up as a disabled program, which the second program runs when it's done) or by having the second program set a status variable, which triggers the third program when the value is set to the triggering value. I tend to prefer the ugly way, using status variables. It's akin to "state machine" programming and is easier to test and troubleshoot.
20 hours ago20 hr Author 1 hour ago, Guy Lavoie said:Yes, that's how it works. A disabled program won't be run by the main IoX routine, but can be run on demand by another program. I use this in a garage door routine that updates the backlight of a keypadlinc button even if the garage door is operated manually. As you want to do, this is like a nested IF.There are two ways to do this: inefficiently, or ugly! The inefficient way is to use a Wait statement to pause the operation of your first program, to allow the second one time to run. Inefficient because you need to wait a bit more than usually required to be safe (that's it's actually finished) and for that to work, the triggering status of your first program has to remain true for the time the Wait finishes. So if your second program changes the status of one of your devices that triggered your first program, the Wait and the rest of the program just gets canceled.The ugly way is to use...a third program. You could put the commands you want to run after the second program is finished into a third program, which either the second program runs (set it up as a disabled program, which the second program runs when it's done) or by having the second program set a status variable, which triggers the third program when the value is set to the triggering value. I tend to prefer the ugly way, using status variables. It's akin to "state machine" programming and is easier to test and troubleshoot.Well now you have piqued my interest even more. So if I create a program (NOT Disabled) with an 'IF" statement that simply looks at a state variable (e.g. in my case the "Poll_Running" integer variable) - so for example "If Poll_Running = 1" - does that mean that this program will run whenever that variable gets set to 1 without specifically being called by another program? If so - does that not mean that the "else" portion of that program would be "true" almost all the time (except when Poll_Running = 1") and hence would be constantly "running"? I must be missing something here.....If so - that blows my mind - I had assumed that programs were only triggered either by looking at insteon device state or control statements when someone manually operates a switch OR when called by another program. Is this not the case - and that programs with a simple variable in the IF will be automatically triggered if that variable changes to the required value?I also remember someone telling me that programs that have Control/State "if" tests of insteon devices are only triggered by manual changes to a device and NOT by changes initiated by a program - so that would then kinda be in conflict with the above would it not?Or perhaps I just have made a leap of logic to somewhere that does not exist LOL....Please elaborate. This is extremely interesting......
20 hours ago20 hr 5 minutes ago, SMonk said:Well now you have piqued my interest even more.So if I create a program (NOT Disabled) with an 'IF" statement that simply looks at a state variable (e.g. in my case the "Poll_Running" integer variable) - so for example "If Poll_Running = 1" - does that mean that this program will run whenever that variable gets set to 1 without specifically being called by another program?If so - does that not mean that the "else" portion of that program would be "true" almost all the time (except when Poll_Running = 1") and hence would be constantly "running"? I must be missing something here.....If so - that blows my mind - I had assumed that programs were only triggered either by looking at insteon device state or control statements when someone manually operates a switch OR when called by another program. Is this not the case - and that programs with a simple variable in the IF will be automatically triggered if that variable changes to the required value?I also remember someone telling me that programs that have Control/State "if" tests of insteon devices are only triggered by manual changes to a device and NOT by changes initiated by a program - so that would then kinda be in conflict with the above would it not?Or perhaps I just have made a leap of logic to somewhere that does not exist LOL....Please elaborate. This is extremely interesting......5 minutes ago, SMonk said:So if I create a program (NOT Disabled) with an 'IF" statement that simply looks at a state variable (e.g. in my case the "Poll_Running" integer variable) - so for example "If Poll_Running = 1" - does that mean that this program will run whenever that variable gets set to 1 without specifically being called by another programYes, IF the variable is a "state" variable. Integer variables are not triggers. Integer variable are used to affect the true/false status of a program when something else triggers it.5 minutes ago, SMonk said:If so - does that not mean that the "else" portion of that program would be "true" almost all the time (except when Poll_Running = 1") and hence would be constantly "running"? I must be missing something here.....No, if it is a state variable, it only triggers on a change of the value. Again, it is integer, it never triggers.5 minutes ago, SMonk said:If so - that blows my mind - I had assumed that programs were only triggered either by looking at insteon device state or control statements when someone manually operates a switch OR when called by another program. Is this not the case - and that programs with a simple variable in the IF will be automatically triggered if that variable changes to the required value?Yes, when it changes at all it will be a trigger, if it is a state variable. It is the change of the variable that is the trigger. For example,If$s.test is 1Thendo somethingElsedo something elseIn this case, if $s.test is currently 2 and it changes to 3, the program will trigger and go false. In the case it is 1 and some other programs sets it to 1 (so it doesn't change) nothing will happen. If it starts as 2 and changes to 1, it will trigger and run true.5 minutes ago, SMonk said:I also remember someone telling me that programs that have Control/State "if" tests of insteon devices are only triggered by manual changes to a device and NOT by changes initiated by a program - so that would then kinda be in conflict with the above would it not?Status in an if clause triggers the clause on any change in status. For example, if status is 25% will trigger on any change in the status of the switch. Say it was off and it turned on, that would trigger the program to run false. Status responds to any change in the switch no matter how it happened. It could be responding to a scene command, responding to a program, or responding to local control.Control in an if clause ONLY triggers on that exact thing happening on that device. For example, control switched on, means someone clicked the on button on a switch. Nothing else done to the switch triggers the program. Turning on because it responded to a scene or program does not trigger the program.17 minutes ago, SMonk said:Well now you have piqued my interest even more.So if I create a program (NOT Disabled) with an 'IF" statement that simply looks at a state variable (e.g. in my case the "Poll_Running" integer variable) - so for example "If Poll_Running = 1" - does that mean that this program will run whenever that variable gets set to 1 without specifically being called by another program?If so - does that not mean that the "else" portion of that program would be "true" almost all the time (except when Poll_Running = 1") and hence would be constantly "running"? I must be missing something here.....If so - that blows my mind - I had assumed that programs were only triggered either by looking at insteon device state or control statements when someone manually operates a switch OR when called by another program. Is this not the case - and that programs with a simple variable in the IF will be automatically triggered if that variable changes to the required value?I also remember someone telling me that programs that have Control/State "if" tests of insteon devices are only triggered by manual changes to a device and NOT by changes initiated by a program - so that would then kinda be in conflict with the above would it not?Or perhaps I just have made a leap of logic to somewhere that does not exist LOL....Please elaborate. This is extremely interesting......
19 hours ago19 hr Solution 48 minutes ago, SMonk said:Well now you have piqued my interest even more.So if I create a program (NOT Disabled) with an 'IF" statement that simply looks at a state variable (e.g. in my case the "Poll_Running" integer variable) - so for example "If Poll_Running = 1" - does that mean that this program will run whenever that variable gets set to 1 without specifically being called by another program?If so - does that not mean that the "else" portion of that program would be "true" almost all the time (except when Poll_Running = 1") and hence would be constantly "running"? I must be missing something here.....If so - that blows my mind - I had assumed that programs were only triggered either by looking at insteon device state or control statements when someone manually operates a switch OR when called by another program. Is this not the case - and that programs with a simple variable in the IF will be automatically triggered if that variable changes to the required value?I also remember someone telling me that programs that have Control/State "if" tests of insteon devices are only triggered by manual changes to a device and NOT by changes initiated by a program - so that would then kinda be in conflict with the above would it not?Or perhaps I just have made a leap of logic to somewhere that does not exist LOL....Please elaborate. This is extremely interesting......Yes, it will trigger the first time that the variable becomes true to your test . Similarly, an ELSE statement will execute the first time that the variable test becomes false (so no, it won't trigger continuously). There is an exception when it comes to variables: a test with more than one possible true value will test true again if the value changes, even when it was already true. For example "IF Variable x is > 1" will test true if the variable gets set to 2, and will test true again if it goes from 2 to 3, even though the test was already true. Variables are the common currency between programs, because you can set and test them at will. They become triggers, flags, etc, whatever you want.Your question about Control vs Status: Control tests true if the control event tests true, which by nature happens only once (eg: when the switch is actually pressed). So if you turn on a switch that was off, it's status will change and a logic test for Status On will trigger, and you will also get a Control On event. Now if you now press the On button again, the Status won't have changed because it was already on, but a program looking for a Control On will trigger again, since you pressed the button. So Control events are useful for things like counting how many times a switch has been pressed within time period, for example, or to activate a secondary action.
18 hours ago18 hr Author 1 hour ago, Guy Lavoie said:Yes, it will trigger the first time that the variable becomes true to your test . Similarly, an ELSE statement will execute the first time that the variable test becomes false (so no, it won't trigger continuously). There is an exception when it comes to variables: a test with more than one possible true value will test true again if the value changes, even when it was already true. For example "IF Variable x is > 1" will test true if the variable gets set to 2, and will test true again if it goes from 2 to 3, even though the test was already true.Variables are the common currency between programs, because you can set and test them at will. They become triggers, flags, etc, whatever you want.Your question about Control vs Status: Control tests true if the control event tests true, which by nature happens only once (eg: when the switch is actually pressed). So if you turn on a switch that was off, it's status will change and a logic test for Status On will trigger, and you will also get a Control On event. Now if you now press the On button again, the Status won't have changed because it was already on, but a program looking for a Control On will trigger again, since you pressed the button. So Control events are useful for things like counting how many times a switch has been pressed within time period, for example, or to activate a secondary action.Wow - Guy - thanks for all of this. This is really expanding my horizons about what I might be able to do and potentially simplify some of the things I have already done. Truly appreciated!!!Now.....about world peace.......
17 hours ago17 hr 1 hour ago, SMonk said:Now.....about world peace.......I'm working on that Persian Gulf plugin as fast as I can!
3 hours ago3 hr 13 hours ago, Guy Lavoie said:I'm working on that Persian Gulf plugin as fast as I can!Likely 240vAC and 50 Hz. and instructions will be in sandscript. Edited 3 hours ago3 hr by larryllix
1 hour ago1 hr @SMonk Yes, the power of the Eisy programing is ENORMOUS. Between state and integer variables, Nested IFs, ability to run other programs, if, then or else, from within a different program or even the same program, disabled programs on demand only, folders with conditions etc etc. I have yet to see any other "integrator" that is as powerful and yet "easy" to use, once you get the hang of it. One area people often get tripped up on are Waits and Repeats. These line will cause a retest of the IF upon completion which can often change the program from true to false, and therefore stopping it from completing.This forum is a great resource for help with programming. Best way to get help is to right click on a program in the AC and select copy to clipboard (at the bottom), and then paste into the forum. It preserves all the contextual elements of what is in the Eisy. This wiki explains a lot.. https://wiki.universal-devices.com/ISY-99i/ISY-26_INSTEON:Scope,_Precedence_and_Execution_OrderCheers!
11 minutes ago11 min One thing that's a bit frustrating is that when you're used to neatly organizing code for readability and logical flow (nesting, indentation, etc) you find that there's no way to neatly organize IoX programs. Other than putting them in folders, you can only view one If/then/else script at a time, and they organize themselves in alphabetical (ascii) order. It would be nice if eisy-ui offered a more customizable way of listing programs or even better: more than one at a time. Hint hint...
Create an account or sign in to comment