GregE Posted December 31, 2010 Posted December 31, 2010 Been working on getting my ISY99 going. It's been pretty painless. I would like to have a program so I use a button on my KPL switch when I am gone. Then one of my lights in the house would go on and off. It would come on at Sunset and then off at different times in the evening. I wrote a program but I;n mot sure my logic is good. I would copy the program and show it by I can't get into the ISY from my Mac. Can somebody give me an example program so I know I have it written correctly?
oberkc Posted December 31, 2010 Posted December 31, 2010 Sounds like you need a PC. Those darn Macs aren't much good for anything! Why do you suspect your logic is no good? Is your program not working? How about the following: if status KPL button is on and From Sunset To 10:00:00PM (same day) Then Set 'one of my lights' On Else Wait 30 minutes (Random) Set 'one of my lights' Off There are several ways to do this. The example above may suffer a shortcoming that you may or may not care about. If you turn the KPL button off with the light on, the program will cease and not turn it off automatically. Try things out. You may find that you have preferences in how you do things. Enjoy!
GregE Posted December 31, 2010 Author Posted December 31, 2010 I wasn't sure if I had my and or's correct for multiple days. Here is what I have (although I have every day listed): If Status KPL Button is On And On Sat From Sunset + 20 minutes To 10:30pm (same day) Or On Sun From Sunset + 36 minutes To 10:43pm (same day) Or On Mon From Sunset + 16 minutes To 10:25pm (same day) Or On Tue From Sunset + 5 minutes To 10:49pm (same day) Then Set 'Kitchen Pendants' 70% Else Set 'Kitchen Pendants' Off Are my and/or's correct or would I need parenthesis?
LeeG Posted December 31, 2010 Posted December 31, 2010 You need parens to AND the first If condition with all the others If Status KPL Button is On And ( On Sat From Sunset + 20 minutes To 10:30pm (same day) Or On Sun From Sunset + 36 minutes To 10:43pm (same day) Or On Mon From Sunset + 16 minutes To 10:25pm (same day) Or On Tue From Sunset + 5 minutes To 10:49pm (same day) ) Then Set 'Kitchen Pendants' 70% Else Set 'Kitchen Pendants' Off
art Posted January 1, 2011 Posted January 1, 2011 Just chiming in. I think we all use something similar. Here are some more examples: This is my main security night time program that simulates people moving about the house: If From Sunset + 15 minutes To 11:50:00PM (same day) And Status 'Living Room / Living Room Fan / Away - KPL- A' is On Then Wait 1 hour (Random) Repeat 8 times Send X10 'H1/On (3)' Wait 20 minutes (Random) Send X10 'H1/Off (11)' Wait 5 seconds Send X10 'H5/On (3)' Wait 10 minutes (Random) Send X10 'H5/Off (11)' Else - No Actions - (To add one, press 'Action') This one also runs in parallel to simulate someone going into our guest bedroom to get something: If From Sunset + 3 hours To 11:00:00PM (same day) And Status 'Living Room / Living Room Fan / Away - KPL- A' is On Then Wait 30 minutes (Random) Set 'Bedroom #2 / BR2 Table Lamp' Fast On Wait 1 minute (Random) Set 'Bedroom #2 / BR2 Table Lamp' Fast Off Wait 45 minutes (Random) Set 'Bedroom #2 / BR2 Table Lamp' Fast On Wait 2 minutes (Random) Set 'Bedroom #2 / BR2 Table Lamp' Fast Off Else - No Actions - (To add one, press 'Action') This one simulates me feeding the livestock and runs in parallel with the two programs above: If On Mon, Tue, Wed, Thu, Fri From Sunset To 11:50:00PM (same day) And Status 'Living Room / Living Room Fan / Away - KPL- A' is On Then Wait 15 minutes Wait 2 hours (Random) Set 'Shed / Barn Lights' On Wait 12 minutes Wait 10 minutes (Random) Set 'Shed / Barn Lights' Off Else - No Actions - (To add one, press 'Action') This are my favorite two programs: If Status 'Living Room / Living Room Fan / Away - KPL- A' is On And From Sunset + 1 hour and 15 minutes For 2 seconds Then Wait 10 seconds (Random) Run Program 'Flood Flasher' (Then Path) Else - No Actions - (To add one, press 'Action') The program above runs a flood light flasher program only 20% of the time. The flasher program (below) turns all of my outside floodlights on for a brief period as if we were home and were looking outside at something or we hit the wrong light switch. If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 2 hours (Random) Set 'Outside House / Flood Light Override' On Wait 15 seconds (Random) Set 'Outside House / Flood Light Override' Off Else - No Actions - (To add one, press 'Action') and FINALLY, a program to turn off the mess when I come home and switch off the away button called "home" it also gives some audible feedback when away is set and chirps the KPL every 30 minutes as a reminder to turn it off when I am at home. This way nothing stays on if I switch off the away button when one of its branch programs, which immediately terminate, have a light turned on. If Status 'Living Room / Living Room Fan / Away - KPL- A' is On Then Set 'Living Room / Living Room Fan' 1 (Beep Duration) Set 'Living Room / Living Room Fan' 1 (Beep Duration) Repeat Every 30 minutes Set 'Living Room / Living Room Fan' 1 (Beep Duration) Else Run Program 'Off ice Server Lights' (Else Path) Run Program 'Foyer Lights' (Else Path) Set 'Shed / Barn Lights' Off Set 'Bedroom #2 / BR2 Table Lamp' Off
oskrypuch Posted January 1, 2011 Posted January 1, 2011 That is some nice code examples, art! I like that shrewd move to step around the lack of a random number generator in the program. * Orest
GregE Posted January 3, 2011 Author Posted January 3, 2011 Thanks for the examples. Lots of good stuff there. I might have to do something like that next time I am at the house. I still have some more switches to add so I can do things like that. Is there a way to make the time the program runs have a random start and end time? I kind of do that by using lots of "OR"s but would rather just have the ISY do it.
fitzpatri8 Posted January 3, 2011 Posted January 3, 2011 Is there a way to make the time the program runs have a random start and end time? I kind of do that by using lots of "OR"s but would rather just have the ISY do it. Random Timer Trigger: If On Mon, Wed, Fri Time is Sunset Then Run Program 'Random Timer' (Then Path) Else - No Actions - (To add one, press 'Action') And Random Timer: If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 1 hour (Random) Set Scene 'Living Room Scene' On Wait 2 hours Wait 1 hour (Random) Set Scene 'Living Room Scene' Off Else - No Actions - (To add one, press 'Action') Notice how you can combine Wait statements, first with a set wait followed by a random wait. In this case, the scene always stays on for a random period between 2 and 3 hours.
GregE Posted January 3, 2011 Author Posted January 3, 2011 Any reason why you have it as 2 programs and not all in 1?
fitzpatri8 Posted January 3, 2011 Posted January 3, 2011 When an ISY program hits a Wait or Repeat statement, it will normally abort the program without completing if the trigger conditions become false. This housekeeping both gives the user a way to stop a program in its tracks and avoids the ISY running duplicate instances of the same program if the trigger action occurs multiple times. (An example of this might be a bathroom light timer--you wouldn't want the light to turn out if someone is still moving around in the room when a timer expires, nor would you want the light to turn out if someone went in, activated the timer, left the room, then someone else went in and just turned the light on as the first timer was about to expire.) In your case, however, this logic presents a challenge. If you trigger the program with a time, then the program hits a wait statement, the time will be different so the program would abort. By splitting the program in two, there's no wait in the first program and the second program has no conditions that will cause it to abort while waiting.
oberkc Posted January 3, 2011 Posted January 3, 2011 If you trigger the program with a time, then the program hits a wait statement, the time will be different so the program would abort. But, I thought that the time condition, in this case, would only evaluate once per day (at sunset). I see no other trigger condition forcing an evaluation that could result in a false condition, halting the program. (You are not suggesting that the "wait" statement, itself, triggers an evaluation, are you?) I expect this program to be "true" indefinitely...and that a single program would work here.
fitzpatri8 Posted January 3, 2011 Posted January 3, 2011 But, I thought that the time condition, in this case, would only evaluate once per day (at sunset). I see no other trigger condition forcing an evaluation that could result in a false condition, halting the program. I expect this program to be "true" indefinitely...and that a single program would work here. You may be right in the case of sunrise/sunset, I haven't spent the time testing it. I do know my way works.
oberkc Posted January 4, 2011 Posted January 4, 2011 I do know my way works. Yes, of that I am sure. For what it is worth, in support of another thread I ran a quick experiment with the following program: If Control 'Basement/Garage / SW GRS Garage Exterior Sconse' is not switched On And Time is 7:44:00PM Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') At 7:44, the status of this program changed from false to true. It remained so until I switched the sconse on, at which point it went false. This tends to support the theory that time-based conditions themselves only trigger an evaluation at the specified time. This is consistent with my understanding and tends to support the GregE's apparent suspicion that this particular example can be accomplished as a single program. It sounds as if GregE has the same personality as me....deriving some irrational pleasure in minimizing lines of code. I think, however, it may be good general practice to break them into two programs, just in case of something we were not smart enough to foresee. That is, unless we specifically want to take advantage of the ISY ability to halt programs midstream (such as certain motion sensor programs).
GregE Posted January 4, 2011 Author Posted January 4, 2011 oberkc, that probably comes from my RPG programming. I can go with the 2 programs though just to make sure. Instead of it running for between 2 to 3 hours using the wait, is there a way to do another random timer trigger to end the program. Something like this? If On Mon, Wed, Fri Time is 10:30:00PM And Status KPL Button is On Then Run Program 'Random Timer 2' (Then Path) Else - No Actions - (To add one, press 'Action') and If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 15 minutes (Random) Set Scene 'Living Room Scene' Off Else - No Actions - (To add one, press 'Action') The original program you wrote would, of course, be modified to only turn the lights on. I'm not at the house with the equipment or I would try it.
fitzpatri8 Posted January 4, 2011 Posted January 4, 2011 Sure, if you aren't interested in a minimum time, you can use just one Wait Random.
oberkc Posted January 4, 2011 Posted January 4, 2011 Instead of it running for between 2 to 3 hours using the wait, is there a way to do another random timer trigger to end the program. Something like this? If you are asking whether lights can be turned on with one program and off with a second, I believe the answer is a confident "YES".
Recommended Posts