C Martin Posted November 12, 2007 Posted November 12, 2007 Just Another Joe, and anyone else, This is how I use my Flags Programs. Now that I understand Program Status I can use them as Flags for other things. Thanks to Alf for the Program Status Explaination. and Clarification. Since the Program Status is dependent on the conditions within the program code, I can now use the "True"/ "False" status as a Flag. Here are some examples that I use: This is my Daytime FLag Pgm: It is used to indicate that it is daytime. If From Sunrise To Sunset (same day) Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') This is my Evening Flag Pgm: It is used to indicate that it it after Sunset but befor 11:25 PM. If From Sunset To 11:25:00PM (same day) Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') This is my GoodNite Flag Pgm: It idicates that my systems is flagged for things that could or should happen between about 10:00 PM and Sunrise. If From 10:00:00PM To Sunrise (next day) Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') The Great thing about these Flag Programs is that I don't have to reset the Flags. They are dynamicaly reset by the conditions with which they were set. I can now use their "True / Flalse" valuse in my programs. This is my 10 minute all lights on Program: This program only runs during the time that the GoodNite flag is set. - between 10:00 PM and Sunrise. If ( Program 'GoodNite Flag Pgm' is True And Control 'Front Walkway Light' is switched Fast On ) Then Wait 2 seconds Set Scene 'All On Scene' On Wait 10 minutes Set Scene 'Good Nite Scene' On Else - No Actions - (To add one, press 'Action') It also Great for Motion Detection during the GoodNite Hours. I keep all of my Flag Programs in a Flags Folder. That way they are easier to find. Quote
C Martin Posted November 12, 2007 Author Posted November 12, 2007 I found one mistake in my earlier post. In the GoodNite Flag Pgm, the code for Sunrise should be "Same Day". If From 10:00:00PM To Sunrise (same day) Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') Quote
Chris Jahn Posted November 12, 2007 Posted November 12, 2007 C Martin, Actually, I think it should be Next Day because you would want on any given day, Friday for example, to go from 10:00:00 PM Friday, to Sunrise on Saturday. Quote
C Martin Posted November 12, 2007 Author Posted November 12, 2007 I tested this today and it is Same Day. I would have thought Next Day also but it proved to be wrong. Quote
Chris Jahn Posted November 12, 2007 Posted November 12, 2007 C Martin, Looks like you discovered a bug ... its in a complex area of the code that affects all schedules using sunrise/sunset, so I'm not sure if we will fix it with the official release coming up so soon. In cases where the 'From' time is greater than the 'To' time, 'Same Day' is behaving the same as 'Next day'. I tested this today and it is Same Day. I would have thought Next Day also but it proved to be wrong. Just for clarification, are you saying you tried 'Next Day' and it didn't work, or that you are using 'Same Day' and never tried using 'Next Day'. I would suggest using 'Next day' because I believe this bug will be fixed at some point in the future. Quote
C Martin Posted November 12, 2007 Author Posted November 12, 2007 No, I used the Next Day value and this morning it was wrong, so I changed the Value to Same Day. I will check again tomorrow by chnging values again. Quote
Sub-Routine Posted November 13, 2007 Posted November 13, 2007 C Martin, Thank you for the examples. I spent a few minutes Saturday trying to make an "Away" button on my KPL but I could not get it to function properly. Now that I have read about 2.4.13 not deleting all the old links I realize why the ISY is not seeing the button state and the lamp keeps changing with the button Thanks again, Rand Quote
Algorithm Posted November 13, 2007 Posted November 13, 2007 Just Another Joe, and anyone else,This is how I use my Flags Programs. Clarence, thank you! Flags ala your programs will alleviate a lot of problem areas, pending the introduction of genuine variables. Well done! Quote
C Martin Posted November 13, 2007 Author Posted November 13, 2007 I will try to post some more examples later this week. I have a rain Switch that enables my folder that has my irrigration controller programs. It can diable the folder for a set amount of time and then send reminders. Doing a Flags program for scenes will be a little harder because scenes allow for more unit values for lighting levels than the Staus event in the IF progam area can evaluate. It requires the use of greater than (>) or less than (<) to capture an Insteon's set level. More later! Quote
Algorithm Posted November 13, 2007 Posted November 13, 2007 In all the examples above, the conditions which control the Flag program are all time events. Is there any action statement one can place in a separate program [without actually turning some Insteon device on/off] which would cause a Flag program to change state? Quote
Chris Jahn Posted November 13, 2007 Posted November 13, 2007 C Martin, No, I used the Next Day value and this morning it was wrong, so I changed the Value to Same Day. I will check again tomorrow by chnging values again. I took another look at the code and decided to make the fix for this; in the next drop, "Same Day" will mean same day. Quote
Chris Jahn Posted November 13, 2007 Posted November 13, 2007 In all the examples above, the conditions which control the Flag program are all time events. Is there any action statement one can place in a separate program [without actually turning some Insteon device on/off] which would cause a Flag program to change state? Whenever a program runs, it is either set True ('Then' path) or False ('Else' path), therefore you can use any conditions in your 'If' to set a program to True or False. You can use Actions to explicitly set flags as well; create an empty program named 'Flag 1', and in other programs use the 'Program' 'Run' 'Flag 1' action to set 'Flag 1' true, and use 'Program' 'Run Else' 'Flag 1' to set Program 'Flag 1' false. Quote
C Martin Posted November 13, 2007 Author Posted November 13, 2007 Chris, I thought that I had seen the Flag program status change during calls by other programs. In matter of fact I was doing calls to my Flags Progams but changed from that. After your post I re-tested doing the progam calls and I find that to be a more reliable way of asurring that the flag programs are either set or re-set. This way I can depend on my Sunset Program to set my evening Flag Program rather than just looking at the IF statements. Two questions though - Do the program statuses otherwise change only when there is program activity on the ISY? If not, any idea how long it my take to see a status change? - just curious... Thanks, Clarence Quote
Chris Jahn Posted November 13, 2007 Posted November 13, 2007 Clarence, Actually, I think the way you had it is good, and how it was intended to be used. Basically create programs such as 'Evening', 'Daytime', 'Office Hours', 'Holidays' etc. containing 'If' conditions only, and then have other programs reference those programs directly. As for when the True/False state is changed ... The only time the True/False status is changed for a program is when that program is run. The first step in running a program is to set the True/False status, it then begins to perform the actions in either the 'Then' or 'Else'. Nothing else changes the True/False status of a program. Quote
Chris Jahn Posted November 13, 2007 Posted November 13, 2007 You can also nest program refererences as deeply as you like. For example, you can have a bunch of holiday programs 'Christmas', 'Thanksgiving', etc. and then have program that references them called 'Days Off'. Program: Days Off If Program 'Christmas' is True Or Program 'Thanksgiving' is True Or Program 'Vacation' is True Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') Program Vacation If From 5:30:00PM on 2007/12/21 To 9:00:00AM on 2008/01/07 Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') Program Christmas If From 12:00:00AM on 2007/12/25 For 24 hours Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') Program Thanksgiving If From 12:00:00AM on 2007/11/22 For 24 hours Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') Quote
C Martin Posted November 13, 2007 Author Posted November 13, 2007 Chris, That's great info. I wil be refining my programs. Thanks, Clarence Quote
Algorithm Posted November 14, 2007 Posted November 14, 2007 In all the examples above, the conditions which control the Flag program are all time events. Is there any action statement one can place in a separate program [without actually turning some Insteon device on/off] which would cause a Flag program to change state? Whenever a program runs, it is either set True ('Then' path) or False ('Else' path), therefore you can use any conditions in your 'If' to set a program to True or False. You can use Actions to explicitly set flags as well; create an empty program named 'Flag 1', and in other programs use the 'Program' 'Run' 'Flag 1' action to set 'Flag 1' true, and use 'Program' 'Run Else' 'Flag 1' to set Program 'Flag 1' false. Super! Thanks, Chris, that's exactly what I was looking for. Quote
sceaton Posted November 30, 2007 Posted November 30, 2007 I'd like to have a flag program that resets itself after X time. I tried making a test program with just a "Wait 15 seconds" in the "Then" but after I "Run" the program, it doesn't change to "False" after the 15 seconds. I just added the Run Else line and it works as expected: Program "test wait" If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 15 seconds Run program 'test wait' (Else Path) Else - No Actions - (To add one, press 'Action') Any problems with having a program stop itself like this? Quote
Chris Jahn Posted November 30, 2007 Posted November 30, 2007 You are corrrect, the program should work as you described it. I just tested this program, and it is working correctly on my system. Are all of your programs still showing 'True' in the Program Summary? If so, please follow the steps in this thread: http://forum.universal-devices.com/viewtopic.php?t=584 Quote
Chris Jahn Posted November 30, 2007 Posted November 30, 2007 One other possibility is that after 15 seconds, the program turns False, but another program immediately runs it again using the 'Then' path, making it appear as though it never stops. Easiest way to test this is to make a copy of this program, and run this copy directly from the program summary screen, it should show 'Running Then'/True for 15 seconds, then 'Idle'/False. Quote
sceaton Posted November 30, 2007 Posted November 30, 2007 I just retested and indeed if the program has ONLY the wait action in the "Then" and is run manually, the interface blinks "Running Then" in red, then goes back to "idle" and the status changes to and stays "True" indefinitely. It will only revert to False if I explicitly set it to "run else" after the "wait". (and yes, i was using an old gui before ... that's all better now, thanks!) cheers! ~shawn Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.