IT Solutions Posted February 13, 2021 Posted February 13, 2021 I have the following program: It is not disabled. I see the Zone the status change in the ISY Event Viewer for the Laundry zone. I right click on the program and select Run Then. The variable IFHLaundry NEVER changes. The value does not change, and the time Last Changed does not change. I want the Then to run every time the zone becomes violated. It should at least change when I right click and select Run Then, right? What am I missing here? Thank you.
jfai Posted February 13, 2021 Posted February 13, 2021 Is there any other program that also changes the variable? (Programs > Details > Context menu > Find/Replace)
MrBill Posted February 13, 2021 Posted February 13, 2021 1 hour ago, IT Solutions said: I have the following program: It is not disabled. Is it in a folder that has a folder condition which evaluates to false? It must be, that about the only reason that 'run then' wouldn't run. PS - if you care about the actual count be sure to set the init value as well, otherwise the count will reset to zero when the ISY restarts. 2
IT Solutions Posted February 13, 2021 Author Posted February 13, 2021 @MrBill At this point I am just trying to get the program to run. I will need to run programs at start up check the zone statuses and set the values correctly. There are no conditions on the folder, but I did find a condition on the main "My Programs" folder, which explains a lot. It is now working. Thank you for your help with this.
MrBill Posted February 13, 2021 Posted February 13, 2021 30 minutes ago, IT Solutions said: @MrBill At this point I am just trying to get the program to run. I will need to run programs at start up check the zone statuses and set the values correctly. There are no conditions on the folder, but I did find a condition on the main "My Programs" folder, which explains a lot. It is now working. Thank you for your help with this. ? My apologies, I guess I should have worded it slightly differently "a folder above the program must have a folder condition evaluating it to false" However technically the question I did ask was correct "Is it in a folder that has a folder condition which evaluates to false?" the program is technically in the "my programs" folder, there just also happens to be one or more folders between the two.
IT Solutions Posted February 13, 2021 Author Posted February 13, 2021 @MrBill Thank you. While your instructions may not have been "perfect", they did assist me with finding the problem. Much appreciated.
IT Solutions Posted February 14, 2021 Author Posted February 14, 2021 @MrBill I am ready to set the value at startup as you noted. I need to check the "current state" of an output and set the variable based on the current state. A regular If Elk Output is ON in ISY only runs when the Output changes from OFF to ON. How does one check the current state of an output, or anything else? We need something like: If ISY just started up And Output is On Then set to $zone.value to 1 Set $zone.counter += 1 Else Set $zone.value to 0 This should run once when the ISY boots up, then never again until it boots up again. Ideas on how to do this? Thank you.
DennisC Posted February 14, 2021 Posted February 14, 2021 1 hour ago, IT Solutions said: @MrBill I am ready to set the value at startup as you noted. I need to check the "current state" of an output and set the variable based on the current state. A regular If Elk Output is ON in ISY only runs when the Output changes from OFF to ON. How does one check the current state of an output, or anything else? We need something like: If ISY just started up And Output is On Then set to $zone.value to 1 Set $zone.counter += 1 Else Set $zone.value to 0 This should run once when the ISY boots up, then never again until it boots up again. Ideas on how to do this? Thank you. What you are looking for is called run on start up. Instructions can be found here: https://wiki.universal-devices.com/index.php?title=ISY-99i/ISY-26_INSTEON:Program_Summary_Tab 1
IT Solutions Posted February 14, 2021 Author Posted February 14, 2021 @DennisC Thank you. Yes I am familiar with "Run at startup". The question is, how does one get a program to run ONLY at startup, and never again.
DennisC Posted February 14, 2021 Posted February 14, 2021 6 minutes ago, IT Solutions said: @DennisC Thank you. Yes I am familiar with "Run at startup". The question is, how does one get a program to run ONLY at startup, and never again. I am not sure I understand what you are trying to accomplish, but just to answer your question, select at start up and only test for the condition you want to be true. You can also disable a program through a program. I thought from your original question you wanted the program to check an Elk output on start up and then have a variable set and follow the on/off of the output?
IT Solutions Posted February 14, 2021 Author Posted February 14, 2021 Yes, that is correct. I want to check the current status of an output and set an ISY variable to 1 if it is on, and 0 if it is off. I have a different progam that changes the variable as the output changes. In traditional programming, which I have been doing for almost 50 years (I taught myself how to program when I was in elementary school in the 70s), an if statement (which ISY calls a program) executes each time the program passes through that part of the code. In ISY, everything is interrupt driven, so the the statement does not execute until something changes to trigger the statement to execute. I need to capture the current state; can't wait until the state changes to know what it is. One could do it like this: If $a = $a And if Output is on Then set $b= 1 Else set $b = 0 and set this program to run at startup. One could then have it disable itself to keep it from running all the time, but then it would not run at start up next time the ISY starts up. I think the solution might be: Create a State Variable $a and have $a configured to be 0 at startup, then run as above, and set $a to 1 so it won't run again until the next startup. Incrementing $a by one would be a way to control the exact order startup programs run at startup which can be very important.
IT Solutions Posted February 14, 2021 Author Posted February 14, 2021 I think I have the solution. However, we have a rule: "If you haven't tested it; it doesn't work." I will need to reboot the ISY to test this. $S.Startup.Programs inits to 0. The first program, Garage, is set to Run At Startup; the rest are not. The first program adds one to S.Startup.Programs, which triggers the second program, which adds one and triggers the third program, etc. They all run at startup, and only run once. This also allows one to control the exact order the programs run at startup. In this case, it does not matter, but in other cases it will. Thanks to everyone that gave me ideas on how to do this. Now I just need to test it by rebooting the ISY.
larryllix Posted February 14, 2021 Posted February 14, 2021 (edited) If your linesand Elk Zone 'XXXXXXX' is violated are edge triggered logic, "Run at startup" will always run Else. Edited February 14, 2021 by larryllix 1
DennisC Posted February 14, 2021 Posted February 14, 2021 All you need is one simple program that changes the variable to 1 when the Elk output is on in the then portion and when off, then set variable to 0 in the else portion. Set the program to run at start up and you are done.
IT Solutions Posted February 14, 2021 Author Posted February 14, 2021 @larryllix I tested it, and it is working correctly as written. I am not understanding your post. Please explain. Thank you.
IT Solutions Posted February 14, 2021 Author Posted February 14, 2021 @DennisCOne simple program would be better than the two I have (per zone). How would you write that one program so it works correctly under all conditions? Thank you.
DennisC Posted February 14, 2021 Posted February 14, 2021 8 minutes ago, IT Solutions said: @DennisCOne simple program would be better than the two I have (per zone). How would you write that one program so it works correctly under all conditions? Thank you. If Elk Output x is On Then VariableX = 1 Wait 5 seconds VariableX Init To VariableX Else VariableX = 0 Wait 5 seconds VariableX Init To VariableX Enable run at start up for this program. Whenever Elk output x is on, variable will be set to 1, when Elk output x is off, variable will be set to 0. In addition, you are setting the Init variable to the same value as the Variable (wait of 5 seconds just makes sure variable has been set) so on start up, the variable will have the same value as when the ISY shutdown, but the program will run shortly after start up to set variable to current state of Elk output. It is also good practice (but not necessary) to begin variable names with the type of variable it is, for example: $s_ISY_Home (State Variable) or $i_ISY_Home (Integer Variable). This helps for troubleshooting down the road. It reminds you of what type of variable it is.
IT Solutions Posted February 14, 2021 Author Posted February 14, 2021 @DennisC Thank you for the idea. If you look at my post above, you will see that I do start variables with I or S as another suggested on this forum. While I am new to ISY, and its "programming language" is substantially different from most others I have used, it is somewhat similar to programming an ELK M1 which I have done for over a decade. ISY is a lot more powerful than the programming in the ELK. ELK is also a lot easier to follow because of the way to displays code on the screen. It WAS also my understanding that your code would not run unless the output changed from OFF to ON, but further testing suggests it will run every time there is a change, in either direction. If Run at Startup is the same as right click and Run If, then it should run at start up without there being a change to the output. @Michaelwould you please help clarify how these two things work. If ISY displayed its code on the screen like this: Whenever there is a change to Zone 30 and it is Violated: ..................... .................... Else .................. ................. following the code would be a lot easier for someone not already an ISY expert. This is my latest understanding of how ISY works, but we are still learning the ISY system. Not sure why you have the Wait 5 seconds in there, but that will definitely not work as the Output could change in those 5 seconds. Using the Variable Init will set that variable at startup to what is was at shut down, but that could also change between shut down and startup, so we really NEED it to check the status at startup. Since we are checking the status at startup, I don't see what the Variable Init does for us, but maybe I am missing something. The programs I posted are working correctly, but I needed to add more startup programs to get the correct zone count, and get other things set correctly. If the code If Zone is Violated runs every time the zone status changes, and runs at startup (when set to), that will greatly simplify tracking the current zone status. I would really like to find a way to track zone counts (number of zones violated) without assigning a variable to each Zone, but so far the only solution I have some up with to do that is even more complicated than what I have now. I also need to be able send an email showing the status of each Zone.
DennisC Posted February 14, 2021 Posted February 14, 2021 11 minutes ago, IT Solutions said: It WAS also my understanding that your code would not run unless the output changed from OFF to ON, but further testing suggests it will run every time there is a change, in either direction. If Run at Startup is the same as right click and Run If, then it should run at start up without there being a change to the output. @Michaelwould you please help clarify how these two things work. The code will run anytime the If statement is evaluated, which happens when ever the If is changed. Therefor, it will run with a change from On to Off and from Off to On. 14 minutes ago, IT Solutions said: Not sure why you have the Wait 5 seconds in there, but that will definitely not work as the Output could change in those 5 seconds. Using the Variable Init will set that variable at startup to what is was at shut down, but that could also change between shut down and startup, so we really NEED it to check the status at startup. Since we are checking the status at startup, I don't see what the Variable Init does for us, but maybe I am missing something. While not necessary, I usually give a brief pause when updating variables one after the other. The Init is very handy when there is a sudden reboot of the ISY, like a power failure. It will restore the variable to what it was before the power failure. The run at start up might take a few seconds or a minute or two to run, depending on how big your system is and how many run at start up there are. This way covers all possibilities and as soon there is a change registered by the If portion of the program, the ISY updates. 20 minutes ago, IT Solutions said: If the code If Zone is Violated runs every time the zone status changes, and runs at startup (when set to), that will greatly simplify tracking the current zone status. Correct 20 minutes ago, IT Solutions said: I would really like to find a way to track zone counts (number of zones violated) without assigning a variable to each Zone, but so far the only solution I have some up with to do that is even more complicated than what I have now. I also need to be able send an email showing the status of each Zone. Custom notifications are available, there should be examples in the ISY Cookbook, or you can read about it here: https://wiki.universal-devices.com/index.php?title=ISY-994i_Series:EMail_and_Networking_Substitution_Variables So, you can write something like the following: ${elk.zone.#.name} will give you the name of the Elk zone that caused the program to run. The # allows the zone that caused the Elk program to run to substitute its name for the # sign. Like wise, ${elk.zone.#.status} will return the status of the zone that caused the program to run. In the near future, there will be an Elk Nodeserver so tif using that, the names would change slightly, but the principle will be the same. The collective group might be able to give you more direct and specific programing examples if you start a new post and explain clearly what you are trying to accomplish. When the concepts are piece meal it is hard to get the big picture. There are a lot of folks here who already have Elk programing and notifications in ISY working. Many are willing to share.
jfai Posted February 14, 2021 Posted February 14, 2021 The Wait commands between consecutive variable assignments are not necessary. Run at Startup runs the whole program starting with the condition. 1
Recommended Posts