lgilsenberg Posted August 14, 2020 Posted August 14, 2020 I am trying to set up a series of programs to turn on different scenes at different times of day based on 1) Motion in the Room (3 Motion Detectors in the room due to odd shape) 2) Time of Day (3 scenes) 3) Last light set (if somebody selects a specific scene on the 6 button controller, then I want to have the motion detector turn that scene back on within a 30 minute window, in case the lights go off because the motion detector didn't see us in the room) So, My thoughts and questions are: 1) setting a variable based on the current light level. (For example, If First_Floor_Light_Level = 1, then turn scene 1 on). - I'm not sure how to do that unless I set a unique setting in each scene and test for it (For example, pendant = 21% in movie scene, 22% in party scene, etc) - is there a way to set a variable in a scene? 2) I would also like to kick off scenes automatically based on time of day. - If I am in the room and the TOD hits then do a 5 minute fade to that new scene. - Each scene has 30+ devices in it and I'm concerned about changing the ramp rate in the scene twice a day. - Would it make sense to copy the scene and change the ramp rate in the new scene? Is there an easy way to copy a scene? 3) has anybody done something like this or am I biting off too much?
larryllix Posted August 14, 2020 Posted August 14, 2020 (edited) I use a State variable to control lighting inside my Gathering Room. I also use about 15 Integer variables to define constants to make it more user friendly. eg. $cPARTY, $cDIM, $cBRIGHT. $cOFF etc.These contain many coloured scene themes as well. my lighting is a mix of RGBW strips, RGBW bulbs, Insteon, etc.. Each value/constant contains a permanent value of say 11,12,13 etc.. anything will do. I have defined a bank of scene handlers/programs based on that state variable and hidden them inside a folder. eg. If $sGathRm.lighting = $cBRIGHT Then set Insteon scene xxx on set WiFi bulbs to 100% set LEDenet strips to white, 100% Else ----- Once this is done you can have many programs, conditions and Alexa vocals controlling that single state variable that controls all the lighting in that room. Much easier. Also, if you want to "borrow" a light for something...eg flash a bulb because a garage door is left open. You just save the value of the state variable, and then restore it back to the original value, after "borrowing" it, and all is back to where you left off again. Confused yet? Just ask!! Edited August 14, 2020 by larryllix 1
lgilsenberg Posted August 14, 2020 Author Posted August 14, 2020 (edited) I love the integer variables to make the program more readable. Excellent idea. How are you setting the state variable $sGathRm.lighting. Is there a way to set the state variable based on a scene that is turned on? Edited August 14, 2020 by lgilsenberg
larryllix Posted August 14, 2020 Posted August 14, 2020 (edited) 1 hour ago, lgilsenberg said: I love the integer variables to make the program more readable. Excellent idea. How are you setting the state variable $sGathRm.lighting. Is there a way to set the state variable based on a scene that is turned on? Using Integer variables as constants. $sGathRm.lighting = $cBRIGHT $sGathRm.lighting = $cOFF $sGathRm.lighting = $cRED I also use an old de facto standard from other languages, using all caps to denote constants. Don't forget to set all" init to" variables to the same value so they are not forgotten in power outages. I also define constants for room numbers so when I record motion, leak detector batteries, or other events I have a method of marking the room the even happened in. Now we just need ISY to support a string substitution function in notification outputs so a real piece of text can sub back in for the names/strings we can use inside programs. Edited August 14, 2020 by larryllix
lgilsenberg Posted August 14, 2020 Author Posted August 14, 2020 I like the all CAPS CONSTANTS. Nice touch. Imagine the following scenario: 1) I walk into the Gathering Room in the morning and my motion sensor turns on the "Morning Gathering Room Scene" 2) I'm working a project so I need a little more lighting. I push the button on keypad "Party Scene" and I now have brighter lighting. 3) I step out for a few minutes, so the motion detector sees no motion and turns off the lights. 4) I walk back in and the motion sensor will turn on "Morning Gathering Room Scene" when I would really like it to turn on "Party scene" I know how to change the scene that the sensor will turn on. I don't know how to tell it that I turned on the Party scene from either the button or Alexa so it will turn the "Party Scene" on instead of the Morning Scene. Does that make sense?
larryllix Posted August 15, 2020 Posted August 15, 2020 5 hours ago, lgilsenberg said: I like the all CAPS CONSTANTS. Nice touch. Imagine the following scenario: 1) I walk into the Gathering Room in the morning and my motion sensor turns on the "Morning Gathering Room Scene" 2) I'm working a project so I need a little more lighting. I push the button on keypad "Party Scene" and I now have brighter lighting. 3) I step out for a few minutes, so the motion detector sees no motion and turns off the lights. 4) I walk back in and the motion sensor will turn on "Morning Gathering Room Scene" when I would really like it to turn on "Party scene" I know how to change the scene that the sensor will turn on. I don't know how to tell it that I turned on the Party scene from either the button or Alexa so it will turn the "Party Scene" on instead of the Morning Scene. Does that make sense? Not sure I can completely understand the logic there but...you seem to be very logically equipped so..... For my deck lights I have 13 WiFi bulbs controlled by my own NRbridge software, driven by ISY NR commands. I have them divided into three groupings, for scenes that I can control from ISY similar to Insteon Scenes, to avoid the popcorn effects, display three different colours, and animate them in a rotational looking effect when desired. I use a single State Variable to control the scenes, exactly the same way as my Gathering room example above. In another folder, I have a bank of programs that all install a scene source variable with the various colour scenes for the deck ceiling potlights, based on the date. Each day at a neutral time I set the controlling source variable to $cDIM so that my deck night lights program uses a copy of $cDIM to illuminate my deck and porch. On festive occasion dates, at a time just a few minutes later than the usual dim white setting, I override the deck lights source variable to festive themes. eg. Canada Day, Christmas, Easter, Halloween, Independence Day, etc... When the main program (sunset + XXX minutes) until 11:00 PM day of week dependent, I copy the scene source variable into the deck light scene control variable causing whatever colours I want to show up around my home.
dbwarner5 Posted August 15, 2020 Posted August 15, 2020 19 hours ago, lgilsenberg said: I like the all CAPS CONSTANTS. Nice touch. Imagine the following scenario: 1) I walk into the Gathering Room in the morning and my motion sensor turns on the "Morning Gathering Room Scene" 2) I'm working a project so I need a little more lighting. I push the button on keypad "Party Scene" and I now have brighter lighting. 3) I step out for a few minutes, so the motion detector sees no motion and turns off the lights. 4) I walk back in and the motion sensor will turn on "Morning Gathering Room Scene" when I would really like it to turn on "Party scene" I know how to change the scene that the sensor will turn on. I don't know how to tell it that I turned on the Party scene from either the button or Alexa so it will turn the "Party Scene" on instead of the Morning Scene. Does that make sense? you could set a variable for each scene you want, then the variable gets controlled either by time of day or whatever button is pushed on keypad. so Morning may be 1, day 2, etc, party 5, etc.. then based on the variable whenever the motion detector triggers, you run a series of programs, each testing for the varilabe state and then turns the lights on accordingly... So a series of programs that set the variable based on time of day..... a series of programs that set it b tased on the keypad settings, then a series of programs that get run whenever the motion detector triggers. you can then build in resets etc. prog1: if var =1, then morning light settings prog 2; if var =2, then set lights for day e let me know if you need more details along this thought process, but it is pretty straight forward and would work well. etc.
lgilsenberg Posted August 15, 2020 Author Posted August 15, 2020 @dbwarner5 - I was thinking along the same path but then I came across a few issues: 1) "How do I determine which scene is currently on so I can set the variable" I don't know how to base a condition on a scene either having a status of on or turned on. I was thinking of basing it on the status light of a keypad. I'm not sure if it will only execute when I physically push the button or will it hopefully execute when Alexa executes the scene that turns on the button. 2) If I set the variable based on the light status of the button, then the motion sensor will have to turn the scene off without changing the button lights. I believe I will have to create a generic scene off command for the room. 3) Is there an easy way to duplicate an existing scene? When the program changes scenes based on time of day, I'd like a longer ramp rate.
larryllix Posted August 15, 2020 Posted August 15, 2020 1 hour ago, lgilsenberg said: @dbwarner5 - I was thinking along the same path but then I came across a few issues: 1) "How do I determine which scene is currently on so I can set the variable" I don't know how to base a condition on a scene either having a status of on or turned on. I was thinking of basing it on the status light of a keypad. I'm not sure if it will only execute when I physically push the button or will it hopefully execute when Alexa executes the scene that turns on the button. 2) If I set the variable based on the light status of the button, then the motion sensor will have to turn the scene off without changing the button lights. I believe I will have to create a generic scene off command for the room. 3) Is there an easy way to duplicate an existing scene? When the program changes scenes based on time of day, I'd like a longer ramp rate. 1) You don't. Scenes do not have a status and cannot be determined with any accuracy. If you want to know what the last scene was use a variable as I suggested in a previous post. 2.) I don't know what buttons you are referring to. If they are KPL buttons or other Insteon buttons, they do not have a useful status. Their status is always Off but they generate events that can trigger ISY programs. You variable can remember their last operation. 3.) I am not sure if you can copy a scene but you can create a scene very easily inside the admin console. It's most;y a drag and drop process. I only use a few Insteon scenes but I use dozens of different room lighting scenes, all controlled by one state variable. If you want to remember which lighting scene was on for some temporary usage, save the state variable into another variable and when you are done save that variable back into the state variable. As describe previously, all lighting is controlled by that one state variable. The first thing that usually happens with newbies to ISY is "OMG! it takes so many programs!". That is the nature of the beast. Each program is one basic logic statement unlike linear program languages. Most developed systems use hundreds of programs and hundreds of variables. It is not costly for the system. Best of luck. Keep experimenting.
lgilsenberg Posted August 15, 2020 Author Posted August 15, 2020 @larryllix I am having a blast experimenting . . . can't say the same for my wife. On setting the variable based on scene, found I was able to set the variable based on the KPL Button. The scene incorporates the button as both a controller and a responder so I can test on it. I set up the following programs: [FOLDER] What Lights are on [PROGRAM} Kitchen High If Status 'Keypad - Kitchen' is not Off Then $Kitchen_Lighting = $KITCHEN_HIGH [PROGRAM] Kitchen Medium If Status 'Keypad - Party' is not Off Then $Kitchen_Lighting = $KITCHEN_MEDIUM [PROGRAM] Kitchen Low If Status 'Keypad - Movie' is not Off Then $Kitchen_Lighting = $KITCHEN_LOW ---------------------------- I found that Kitchen_Lighting changed correctly whether I changed the scene via a program, a call from Alexa or by pushing a button. Yeah!!!! ----------------------------- Here's my latest problem: I created conditional folder and several programs underneath it. I assumed that if the both the folder condition and the program conditions were true that the program would execute. So far . . . not so much. [FOLDER] Turn on Lights If Status 'Kitchen Sensor' is on and Status 'Kitchen' is off [PROGRAM] Kitchen High IF $Kitchen_Lighting is $KITCHEN_HIGH then Set Scene 'Kitchen High' On [PROGRAM] Kitchen Medium IF $Kitchen_Lighting is $KITCHEN_MEDIUM then Set Scene 'Kitchen Medium' On [PROGRAM] Kitchen Low IF $Kitchen_Lighting is $KITCHEN_LOW then Set Scene 'Kitchen Low' On --------------------------- I have found that the Folder Program shows green (I'm assuming it is now calling the programs under it). The Program Kitchen high shows green on the left but never turns on the light. Have I misunderstood the capabilities of the folder IF?
lgilsenberg Posted August 15, 2020 Author Posted August 15, 2020 I think I just figured out the answer to my own question. In order for the program to execute within a conditional folder, the condition within the program must have just changed. So . . . . I changed the structure to: FOLDER] Turn on Lights If Status 'Kitchen' is off (Removed the Sensor Status check from the conditional folder and put it in the Program condition since that is what is changing) [PROGRAM] Kitchen High IF $Kitchen_Lighting is $KITCHEN_HIGH AND Status "Kitchen Sensor" is on then Set Scene 'Kitchen High' On [PROGRAM] Kitchen Medium IF $Kitchen_Lighting is $KITCHEN_MEDIUM AND Status "Kitchen Sensor" is on then Set Scene 'Kitchen Medium' On [PROGRAM] Kitchen Low IF $Kitchen_Lighting is $KITCHEN_LOW AND Status "Kitchen Sensor" is on then Set Scene 'Kitchen Low' On ------- It's a bit cumbersome to repeat the Sensor test in every program but it seems to work (so far) --------
larryllix Posted August 15, 2020 Posted August 15, 2020 (edited) 3 hours ago, lgilsenberg said: I think I just figured out the answer to my own question. In order for the program to execute within a conditional folder, the condition within the program must have just changed. So . . . . I changed the structure to: FOLDER] Turn on Lights If Status 'Kitchen' is off (Removed the Sensor Status check from the conditional folder and put it in the Program condition since that is what is changing) [PROGRAM] Kitchen High IF $Kitchen_Lighting is $KITCHEN_HIGH AND Status "Kitchen Sensor" is on then Set Scene 'Kitchen High' On [PROGRAM] Kitchen Medium IF $Kitchen_Lighting is $KITCHEN_MEDIUM AND Status "Kitchen Sensor" is on then Set Scene 'Kitchen Medium' On [PROGRAM] Kitchen Low IF $Kitchen_Lighting is $KITCHEN_LOW AND Status "Kitchen Sensor" is on then Set Scene 'Kitchen Low' On ------- It's a bit cumbersome to repeat the Sensor test in every program but it seems to work (so far) -------- Nice! I do use folder conditions for a few purposes (night security zone enable, security MS zones enable, permanently disabling monitoring programs) but they have a few drawbacks. - they are hard to debug, programs underneath cannot be manually tested while the folder is false - they can stop a program midstream and leave devices turned on or off - they are obscure/hard to see and not something I would look for when debugging algorithms. Once you have a bank of basic device/scene/level handlers in a folder the triggering programs get much simpler without the rest of the code. Some of mine turn on Insteon scenes, along with MagicLight controls via NRs through custom software, sometimes three different colours or more, all from one master scene number inserted into the control variable. Divorcing the two sides of the process across a variable works very well to simplify the thinking. Another nice thing about the isolation via a variable is you can pound the variable as many times as you like but unless the value changes none of the devices get pounded with useless Ons or Offs. Edited August 15, 2020 by larryllix
Recommended Posts