Mahon Posted February 21, 2011 Posted February 21, 2011 I have the following program called "On_DrivewayLights": If ( Status 'Driveway_Motion1-Sensor' is On Or Status 'Driveway_Motion2-Sensor' is On Or Program 'On_DrivewayLights' is True ) And From Sunset To Sunrise (next day) Then Set 'Driveway_LightsPath' On Wait 9 minutes and 30 seconds Set 'Driveway_LightsPath' Off Else - No Actions - (To add one, press 'Action') I would like it to only turn on the lights if at night and stay on for 10 minutes (the motion sensor has a 30 second reset). I had to add the "Or Program On_DrivewayLights is True" in case any of the conditions change while the timer is running, the lights would never get turned off. It works fine for turning on the lights when motion is sensed. The problem is that the motion sensing is still turning on the lights even during the day. It doesn't happen all the time. Everything seems to work fine in the afternoons, but the lights will still come on when motion is sensed at 10AM (sunrise at 7AM). Is there something I've programmed incorrectly here?
oberkc Posted February 21, 2011 Posted February 21, 2011 While I am not sure I would use your motion conditions as stated, I doubt this has anything to do with coming on during the day. The only thing that I can think is that your clock is, somehow, in the wrong time zone or set incorrectly. You don't have any scenes in which the motion sensor and lights are part of, do you?
Mahon Posted February 21, 2011 Author Posted February 21, 2011 The motion sensors and the lights are not part of any scenes; only the program I posted above. I've also verfied that the location and the time in my ISY is correct. I even have it configured to synch every 24 hours to pool.ntp.org. I also checked that the sunrise and sunset times are correct, and they are.
Michel Kohanim Posted February 21, 2011 Posted February 21, 2011 Hello Mahon, The next time this happens, please go to Program Summary tab and check the last runtime column. Is it as you suspect (say in the morning at 10:00 AM)? Also, when the motion sensor turns on the light, does ISY show the correct state for both the motion sensor and the light? If not, then the problem is perhaps residual links in your Motion Sensor responding to some unrelated event. With kind regards, Michel
Mahon Posted February 21, 2011 Author Posted February 21, 2011 When the lights turn on during the day, all the states in the ISY are correct. The program last run time is the time that the lights just turned on and the state of the program is "Running" (counting down on the timer in the True statement). I have also checked the device and ISY link tables for the lights and they both show nothing. Is it possible for the lights to have links that the ISY is not showing? The "lights" are an Insteon ToggleLink. The motion sensor is triggered during the day numerous times. However, I thought I had written the program so that even if the motion sensor was triggered that the light would not turn on during the day.
oberkc Posted February 21, 2011 Posted February 21, 2011 However, I thought I had written the program so that even if the motion sensor was triggered that the light would not turn on during the day. I agree that this program is written such that it should not trigger anything during the day. Is it possible that you have another program that is calling the "then" statement of this program? I believe it is also possible that a light triggered less than 9m30s before sunrise would stay on until after the next sunset. Is it possible this is what you are experiencing?
Mahon Posted February 22, 2011 Author Posted February 22, 2011 I've gone through the rest of my programs to make sure nothing is setting the lights or calling my lights program. I don't have many programs, so this was easy. In response to your second question, would the "Or On_DrivewayLights is True" in the If statement take care of that situation? For example, if the lights come on less than 9.5 minutes before sunrise...then sunrise happens...then the if statement is reevaluated and since it is already running, it continues to run the if statement, but restarts the 9.5 minutes...eventually it times out and turns off the lights.
oberkc Posted February 22, 2011 Posted February 22, 2011 In response to your second question, would the "Or On_DrivewayLights is True" in the If statement take care of that situation? Not in my estimation. You condition requires BOTH the parenthetical condition and the sunrise/sunset condition to be true (because of the AND statement). When sunrise occurs, forcing an evaluation of your program's "if" condition, it will evaluate as false, because it is not between sunset and sunrise. This is the case, even if the parenthetical-grouped-or condition is true for any reason. In fact, is this not exactly how you designed it? You do not want it to trigger ("then") between sunrise and sunset, correct? Is this not the sole purpose for having the sunset/surnise condition? Therefore, any evaluation peformed between sunrise and sunset will, by design, be false, and run the "else" path. Alternatively, what do you expect to happen if the motion sensor detects motion at sunrise + 1 second? Would you expect the program to evaluate as true, or false? Why?
Mahon Posted February 23, 2011 Author Posted February 23, 2011 I think you are correct in that if the motion sensor is triggered at 9.5 minutes or less before sunrise the lights will not turn off until the next sunset. The following code should fix that: If ( ( Status 'Driveway_Motion1-Sensor' is On Or Status 'Driveway_Motion2-Sensor' is On ) And From Sunset To Sunrise (next day) ) Or Program 'On_DrivewayLights' is True Then Set 'Driveway_LightsPath' On Wait 9 minutes and 30 seconds Set 'Driveway_LightsPath' Off Else - No Actions - (To add one, press 'Action') However, I find it unlikely that the motion sensors have been triggered at exactly 9.5 minutes or less before sunrise so many times. Once, or twice I could believe, but this has happened at least 4 days that I'm aware of. The objective of this code is to turn on the lights for 10 minutes when motion is sensed, but only at night (e.g. after sunset and before sunrise).
TJF1960 Posted February 23, 2011 Posted February 23, 2011 It doesn't seem to me that with the addition of that last condition that the program will ever turn false, unless forced. Also,just to make sure, in the original program is the parenthesis an And or an Or statement? Tim
oberkc Posted February 23, 2011 Posted February 23, 2011 I suspect that you will find that new coding to be faulty, as well. While you don't believe that this is the cause of your problem, I can think of no better theory at this point, so perhaps it is worth an experiment. If you are up for it, try something like: If ( Control 'Driveway_Motion1-Sensor' is switched On or Control'Driveway_Motion2-Sensor' is switched On ) And From Sunset To Sunrise (next day) Then run "new program" (then path) Else - No Actions - (To add one, press 'Action') Create a second program, called "new program" (or whatever you want): if then Set 'Driveway_LightsPath' On Wait 10 minutes Set 'Driveway_LightsPath' Off else See if this solves your problems. Don't forget to get rid of your other program.
Mahon Posted February 23, 2011 Author Posted February 23, 2011 Thanks. I'll give those programs a try. Just curious, what is your reasoning behind why you think the 2 programs will work better?
Michel Kohanim Posted February 23, 2011 Posted February 23, 2011 Hello Mahon, We tested your exact program here and it always worked fine. This is a little strange because, although a great idea (using Control vs. Status), I do not think it's going to solve the problem you are having! With kind regards, Michel
Mahon Posted February 23, 2011 Author Posted February 23, 2011 Hi Michel, When you say that you tested the program, which program did you test? Was it the program posted in the original post, my revised program, or the program posted by Oberkc?
oberkc Posted February 23, 2011 Posted February 23, 2011 Just curious, what is your reasoning behind why you think the 2 programs will work better? When breaking the timer portion into a separate program without conditions, the timer continues to run even if the first program turns false (such as at sunrise). Given my suspicions that your program will not work as you desire, I guess this makes it "better". Could it be done with one program? Maybe. I just find the two-program solution to be simple and elegant. If you want a single program, you might try: ( Control 'Driveway_Motion1-Sensor' is switched On or Control'Driveway_Motion2-Sensor' is switched On ) And From Sunset To Sunrise (next day) Then Set 'Driveway_LightsPath' On Wait 10 minutes Set 'Driveway_LightsPath' Off Else - Set 'Driveway_LightsPath' Off The difference with the two-program and single-program approaches it when the light comes on less than ten-minutes before sunrise. The two-program approach will keep the light on for the full ten-minute countdown. The one-program approach shuts the light off at sunrise, regardless of how long it has been on. BTW, if asked what is the most common programming question on this forum, I would guess it to be related to motion sensors. It is well worth a search and review. There is also a good article in the wiki.
Michel Kohanim Posted February 24, 2011 Posted February 24, 2011 Hello Mahon, I tried the original program but I really do not think status vs. control is going to make any difference. With kind regards, Michel
Sub-Routine Posted February 24, 2011 Posted February 24, 2011 I use an Off program outside of any folders with Conditions. The Conditional folders have time and light constraints. So the light levels are appropriate. The Off program always calls the same scene Off. It doesn't matter what level the lights were on. The Ramp Rate in the scene is consistent.
Recommended Posts