17 hours ago17 hr 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?
17 hours ago17 hr 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 17 hours ago17 hr by hart2hart
17 hours ago17 hr You can't have an IF statement in the THEN or ELSE statementYou can split it up into two programs Edited 17 hours ago17 hr by Techman
13 hours ago13 hr 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'.
5 hours ago5 hr 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
1 hour ago1 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.
58 minutes ago58 min 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.
54 minutes ago54 min 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.
44 minutes ago44 min 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.
37 minutes ago37 min 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?
Create an account or sign in to comment