MikeB Posted November 19, 2007 Posted November 19, 2007 I have a couple KPL secondary buttons in my theater room that set a few devices to particular levels. I want those buttons to light if the scene is set, and turn off if anything about the scene changes. I created these programs to do it, but I'm wondering if there may be a more effective way to do the same thing. Here is one as an example. I have a scene called "TheaterParty" that sets "TheaterControls1A-Table" to 50%, "TheaterMain1" to 50%, and "TheaterMain2" to 50%. Here is the code I use to execute that scene: If Control 'TheaterControls1H' is switched On Then Set Scene 'TheaterParty' On Else - No Actions - (To add one, press 'Action') The button is in non-toggle mode, so when the button is pressed, the light goes on. Here is the code to keep the button status correct: If -( | Status 'TheaterControls1A-Table' is not 50% | Or Status 'TheaterMain1' is not 50% | Or Status 'TheaterMain2' is not 50% -) And Status 'TheaterControls1H' is not Off Then Wait 1 seconds Set Scene 'TheaterPartyStatus' Off Else - No Actions - (To add one, press 'Action') I found I had to include the "wait 1 second", otherwise when I pressed the button to turn the scene on, and my lights would ramp up, this program would kick in and turn the button light off. Adding the wait seems to give the lights a chance to ramp up to their proper levels before this program tries to turn the button light off. Can anyone think of a more efficient way to do this? Thanks... Quote
Michel Kohanim Posted December 3, 2007 Posted December 3, 2007 Hi Mike, This post of yours got lost ... anyway, apologies for the tardy reply. Few comments: The following code does not make sense: If -( | Status 'TheaterControls1A-Table' is not 50% | Or Status 'TheaterMain1' is not 50% | Or Status 'TheaterMain2' is not 50% -) And Status 'TheaterControls1H' is not Off Then Wait 1 seconds Set Scene 'TheaterPartyStatus' Off Else - No Actions - (To add one, press 'Action') If your TheaterControls1H is non-toggle off, then this should never change and, if it does, then we do have larger problems to worry about: that button should be in a scene and controlled ONLY but other non-toggle-off buttons. With kind regards, I have a couple KPL secondary buttons in my theater room that set a few devices to particular levels. I want those buttons to light if the scene is set, and turn off if anything about the scene changes. I created these programs to do it, but I'm wondering if there may be a more effective way to do the same thing. Here is one as an example. I have a scene called "TheaterParty" that sets "TheaterControls1A-Table" to 50%, "TheaterMain1" to 50%, and "TheaterMain2" to 50%. Here is the code I use to execute that scene: If Control 'TheaterControls1H' is switched On Then Set Scene 'TheaterParty' On Else - No Actions - (To add one, press 'Action') The button is in non-toggle mode, so when the button is pressed, the light goes on. Here is the code to keep the button status correct: If -( | Status 'TheaterControls1A-Table' is not 50% | Or Status 'TheaterMain1' is not 50% | Or Status 'TheaterMain2' is not 50% -) And Status 'TheaterControls1H' is not Off Then Wait 1 seconds Set Scene 'TheaterPartyStatus' Off Else - No Actions - (To add one, press 'Action') I found I had to include the "wait 1 second", otherwise when I pressed the button to turn the scene on, and my lights would ramp up, this program would kick in and turn the button light off. Adding the wait seems to give the lights a chance to ramp up to their proper levels before this program tries to turn the button light off. Can anyone think of a more efficient way to do this? Thanks... Quote
MikeB Posted December 3, 2007 Author Posted December 3, 2007 If your TheaterControls1H is non-toggle off, then this should never change and, if it does, then we do have larger problems to worry about: that button should be in a scene and controlled ONLY but other non-toggle-off buttons. Sorry, there was a bug in my original message. The button is in TOGGLE mode. This code seems to be working well for me. Quote
MikeB Posted December 11, 2007 Author Posted December 11, 2007 Just an update to this. I decided to add an "off" trigger so that if my KPL secondary button is pressed OFF, it will also turn all lights associated with the scene off. Here's sample code from my kitchen. This trigger activates my scene when a KPL secondary is pressed. If Control 'KitchenControls1G' is switched On Then Set Scene 'KitchenBreakfast' On Else - No Actions - (To add one, press 'Action') "KitchenControls1G is a KPL secondary button. "KitchenBreakfast" is a scene that sets my kitchen lights to the appropriate levels. Here is the trigger that turns everything in the scene off: If Control 'KitchenControls1G' is switched Off Then Set Scene 'KitchenBreakfast' Off Else - No Actions - (To add one, press 'Action') Here is my "cleanup" code that will turn the KPL secondary button off if any light set by the scene changes in any way: If ( Status 'KitchenBar1' is not 90% Or Status 'KitchenMain1' is not 50% Or Status 'KitchenTable1' is not Off ) And Status 'KitchenControls1G' is not Off Then Wait 2 seconds Set Scene 'KitchenBreakfastStatus' Off Else - No Actions - (To add one, press 'Action') The scene "KitchenBreakfastStatus" contains only the KPL secondary "KitchenControlsG". I go through all this trouble because I want my scene-controlling KPL secondaries to accurately depict if my scene is set. If it is not precisely set (someone dims a light slightly more, or changes anything else part of the scene), I want my KPL secondary to show 'off'. I'm curious what everyone else is doing with their 'scenes', so please chime in! Quote
MikeB Posted January 2, 2008 Author Posted January 2, 2008 Just a quick followup. I've combined my scene on and scene off programs into one. Here is an example: If Control 'KitchenControls1G' is switched On And Control 'KitchenControls1G' is not switched Off Then Set Scene 'KitchenBreakfast' On Else Set Scene 'KitchenBreakfast' Off I still have my status program which keeps the LED accurate: If ( Status 'KitchenBar1' is not 90% Or Status 'KitchenMain1' is not 50% Or Status 'KitchenTable1' is not Off ) And Status 'KitchenControls1G' is not Off Then Wait 2 seconds Set Scene 'KitchenBreakfastStatus' Off Else - No Actions - (To add one, press 'Action') Quote
jdva Posted January 2, 2008 Posted January 2, 2008 Mike, I have a suggestion for you which I suppose is a matter of style more than anything else but I find it useful. I actually started a thread on this and then deleted it, not sure why? The suggestion has to do with this code: If ( Status 'KitchenBar1' is not 90% Or Status 'KitchenMain1' is not 50% Or Status 'KitchenTable1' is not Off ) And Status 'KitchenControls1G' is not Off Then Wait 2 seconds Set Scene 'KitchenBreakfastStatus' Off Else - No Actions - (To add one, press 'Action') It seems like your intent is to resolve the question "Is the Breakfast Scene Set?" While your program works, it seems to use "Inverse" logic. The result being that the "status" of the program does not follow your intent although your button does. The program will be "True" when the scene is NOT set. I actually haven't tested this so I could be wrong here but, it reads that way to me. The "status" is not really a functional requirement but it may save you some confusion later on if it is managed consistently. It is often helpful if the button and the staus follow the intent. Here is another way to do this: If Status 'KitchenBar1' is 90% and Status 'KitchenMain1' is 50% and Status 'KitchenTable1' is Off Then Wait 2 seconds Set Scene 'KitchenBreakfastStatus' On Else Wait 2 seconds Set Scene 'KitchenBreakfastStatus' Off In this case all is well. If the scene is set then the LED will be lit and the programs staus will be true to indicate it. If not, it all goes false. A variation on this might be to put the "then" logic in the condition. You can do this if you don't want to turn the button on in your program. I haven't actually tested this program, I am using it as an example but I hope what I am trying to say makes sense. Enjoy, -jeff Quote
MikeB Posted January 5, 2008 Author Posted January 5, 2008 Thanks for the reply Jeff. What you say makes sense, but unless I'm missing something there's no way to for me to do that without creating some redundant powerline traffic (which I'm always trying to avoid). The basic premise is that the only way my scene is set is if the appropriate KPL button is pressed. If that button is pressed, then it is already on. That's why I focus on turning that button off rather than turning it on. I believe the code you have here would work OK: If Status 'KitchenBar1' is 90% and Status 'KitchenMain1' is 50% and Status 'KitchenTable1' is Off Then Wait 2 seconds Set Scene 'KitchenBreakfastStatus' On Else Wait 2 seconds Set Scene 'KitchenBreakfastStatus' Off The only thing I don't like is that if this scene is set, then I've pressed the KPL button and it s already on. Your code above would then, 2 seconds later, send a 2nd on command to it. I could add a check to see if the button is on already, like this: If Status 'KitchenBar1' is 90% and Status 'KitchenMain1' is 50% and Status 'KitchenTable1' is Off and Status 'KitchenControls1G' is not On Then Wait 2 seconds Set Scene 'KitchenBreakfastStatus' On Else Wait 2 seconds Set Scene 'KitchenBreakfastStatus' Off ..but then the program would loop and my status light would keep turning on and off. I do see what you're saying though. Quote
Algorithm Posted January 5, 2008 Posted January 5, 2008 How about taking Jeff's code, and simply removing the lines from the Then, so that the Then is empty? So when the If becomes Not True, the Else is triggered. And if you like you could add the 'KitchenControls1G is not Off' clause. That way, you've completely inverted the logic of your original code, so that the end result is the same. Quote
MikeB Posted January 5, 2008 Author Posted January 5, 2008 How about taking Jeff's code, and simply removing the lines from the Then, so that the Then is empty? So when the If becomes Not True, the Else is triggered. And if you like you could add the 'KitchenControls1G is not Off' clause. That way, you've completely inverted the logic of your original code, so that the end result is the same. I believe that would work, but the ISY would process this program any time a light contained in that scene was adjusted. Quote
Algorithm Posted January 5, 2008 Posted January 5, 2008 I believe that would work, but the ISY would process this program any time a light contained in that scene was adjusted. Perhaps my understanding is failing me. I believe your statement is true, but does not the ISY also process your original program any time a light contained in the scene is adjusted? Quote
MikeB Posted January 5, 2008 Author Posted January 5, 2008 No, because I'm also checking to see if the KPL button is on. If it's not on, then the progam won't run. Quote
Algorithm Posted January 5, 2008 Posted January 5, 2008 But that test could also be included in the revamped code, as I mentioned. If that were done, the program would be 'evaluated' when conditions changed, but not 'run', just as your original code. Quote
MikeB Posted January 5, 2008 Author Posted January 5, 2008 Maybe I'm missing something, but I don't think that's the case. This code: If ( Status 'KitchenBar1' is not 90% Or Status 'KitchenMain1' is not 50% Or Status 'KitchenTable1' is not Off ) And Status 'KitchenControls1G' is not Off ..will only run the THEN if my status light is on, AND one of the scene contained lights is adjusted. If it's adjusted, the status light will go off and not run again unless the scene is re-activated. So ISY traffic is minimized. This code: If Status 'KitchenBar1' is 90% And Status 'KitchenMain1' is 50% And Status 'KitchenTable1' is Off ..is false any time any of those lights are adjusted. This code: If Status 'KitchenBar1' is 90% And Status 'KitchenMain1' is 50% And Status 'KitchenTable1' is Off And Status 'KitchenControls1G' is On ..is also false any time any of those lights are adjusted. Adding an additional conditional doesn't make it any less likely to be false. Unless I'm not grasping what you're suggesting? Which is possible, because I'm pretty tired. Quote
Algorithm Posted January 5, 2008 Posted January 5, 2008 Maybe I'm missing something, but I don't think that's the case. No, you're not missing something-you're right! A thousand pardons! Any logic can, as Jeff suggested, be reversed. But when you add in the traffic/program requirements, I believe that to accomplish your same end result would in this case require two programs--which rather negates the benefit of reversing the logic for easier reading. Thanks so much for taking the time to write out the examples. That may be of help to other readers as well! Quote
Sub-Routine Posted January 5, 2008 Posted January 5, 2008 Wouldn't checking the status light first obviate the need to check the light statuses? If Status 'KitchenControls1G' is not Off And ( Status 'KitchenBar1' is not 90% Or Status 'KitchenMain1' is not 50% Or Status 'KitchenTable1' is not Off ) Rand Quote
Mark Sanctuary Posted January 5, 2008 Posted January 5, 2008 Why don't we re-request the enhancement for the ISY that would simplify this. I have done this several times and it would be nice if it was easier. Status Scene Quote
MikeB Posted January 5, 2008 Author Posted January 5, 2008 Wouldn't checking the status light first obviate the need to check the light statuses? Thanks! That's a good suggestion. Do we know for certain that the order of the conditions matters? Does the ISY evaluate the entire IF no matter what, or does it process the conditions line by line and stop if a line makes it false? Why don't we re-request the enhancement for the ISY that would simplify this. I have done this several times and it would be nice if it was easier. I'm all for it. Quote
IndyMike Posted January 5, 2008 Posted January 5, 2008 MikeB, Could you use a "program control" as a lockout? I'm not sure this whether this would accomplish your goal... Program "Party" If Control 'TheaterControls1H' is switched On Then Set Scene 'TheaterParty' On Else - No Actions - (To add one, press 'Action') TheaterControl Program with "Party" lockout If PROGRAM 'PARTY' is off (Lock out while party program is active) And Status 'TheaterControls1H' is not Off And -( | Status 'TheaterControls1A-Table' is not 50% | Or Status 'TheaterMain1' is not 50% | Or Status 'TheaterMain2' is not 50% -) Then Set Scene 'TheaterPartyStatus' Off Else - No Actions - (To add one, press 'Action') Rand - excellent catch on the execution flow (Homer slap on this end). I've already modified my programs accordingly. IM Quote
MikeB Posted January 5, 2008 Author Posted January 5, 2008 Could you use a "program control" as a lockout? I'm not sure this whether this would accomplish your goal... Maybe.. but my head is spinning and my programs are working well, so I think I'm going to leave them as-is for now. Rand - excellent catch on the execution flow (Homer slap on this end). I've already modified my programs accordingly. I'm going to go through mine today as well. Quote
Sub-Routine Posted January 5, 2008 Posted January 5, 2008 Rand - excellent catch on the execution flow (Homer slap on this end). I've already modified my programs accordingly. IM Thank you. A millisecond here, a millisecond there... Rand Quote
jdva Posted January 5, 2008 Posted January 5, 2008 The basic premise is that the only way my scene is set is if the appropriate KPL button is pressed. If that button is pressed, then it is already on. That's why I focus on turning that button off rather than turning it on. Mike, You are absolutely right. I knew I should have tested that before I opened my big mouth. I was actually wrong on two counts. I was trying to make the point that the staus should always reflect the correct state. If fact it does in your program because, as soon as the button goes out, the staus goes to false. Second, You intent is not to determine if the scene is true, your intent is to turn the button off if it's NOT. It was a good, although, painful lesson for me. I have been programming for a long time but I have found that when dealing with the ISY, it is better to throw that experience out the door and test, test, test. LOL -jeff Quote
MikeB Posted January 6, 2008 Author Posted January 6, 2008 Well thanks for the suggestion. We're all learning here, and I'll often change my programs 3 or 4 times based on other people's ideas and optimizations. That's why I like posting what I'm using for programs. These threads benefit everyone! Quote
MikeB Posted February 14, 2008 Author Posted February 14, 2008 Just an update related to the newer KPLs - now that v1.5+ (I've tested with v1.65) KPLs allow secondary buttons to set different on-levels for the load, and the ISY 2.6.1 beta firmware supports this, I've been able to eliminate the 'control' part of this program. I simply create a lighting scene and make the KPL secondary a controller of that scene. To keep the KPL status 'accurate', I still keep my status programs. For example, my Living Room Reading scene status program: If Status 'LivingRoomControls1G' is not Off And ( Status 'LivingRoomControls1A' is not 90% Or Status 'LivingRoomMain1' is not 30% ) Then Set Scene 'LivingRoomReadStatus' Off Else - No Actions - (To add one, press 'Action') The program first checks if the KPL secondary is already OFF. If it's not OFF, it checks the status of the lights. If they're not set at my scene levels, the program turns the KPL secondary LED off. Doing this has also allowed me to remove the WAITs I needed before setting the status LED. Feels like a much cleaner solution, and KPL use is much much snappier. 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.