robandcathy1 Posted November 1, 2011 Posted November 1, 2011 If Time is sunset (after) and Time is sunrise -1 second (before) and Status motion sensor is switched on then ...... This should be a simple program, I see in the main tab that the motion sensor is working, but in program summary it shows false like it never received request. The next lines turn a light on but it will never happen as lng as the status shows false. I'm using the latest beta, but this has been a issue for a while so its not a beta problem. (probably my code). Any hints where (I'm being stupid at?) On another note I could never get (after sunset, before sunrise) to work without adding a +1 Second, if i use just defaults without the +- 1 sec. the sunrise part alll ways goes back to (after). Any help would be great. Thank Rob FYI I also tried if (control) is on in place of (status), and +- in various combos for sunset/sunrise. The status of motion sensor all ways reads correctly when tripped in main tab. my first thought was sensor was not working.
LeeG Posted November 1, 2011 Posted November 1, 2011 Robandcathy Use the From/To to define a range of time rather than two individual times. Be sure to use (next day) on To value. Note that Status works if not using On Only. If using On Only Control must be used. If From Sunset To Sunrise - 1 second (next day) And Control 'Motion Sensor 3-Sensor' is switched On Then Set 'LampLinc 6' 80% Else - No Actions - (To add one, press 'Action') Lee
apostolakisl Posted November 1, 2011 Posted November 1, 2011 What Lee said. The program as you wrote it will never be true. You are asking for it to be two different times at the same time. The "before" and "after" sunrise/sunset are to define a point in time before or after sunrise, not all times before/after. For example "sunrise - 15 minutes" means that if sunrise is 7:15 that day, the program will trigger at 7:00 You can also use a variable. If From Sunrise To Sunset (same day) Then $iSunshine = 1 Else $iSunshine = 0 Then in programs, use "if $iSunshine = 1" for something you want to happen while the sun is up. There is a subtle but important difference here. If you use an integer variable (not state), then the program will not trigger at sunrise and sunset, it will only trigger when some other "if" clause triggers it. This makes it possible to use the "else" clause in a program and not have that else clause potentially happen at sunrise and sunset. For example If $iSunshine is 0 And Status 'Overhead L' is On Then Set 'Closet L' On Else Set 'Closet L' Off The above program will only run the when someone changes the status of 'Overhead L'. If From Sunrise To Sunset (same day) And Status 'Overhead L' is On Then Set 'Closet L' On Else Set 'Closet L' Off The above program will not only run when someone changes the status of 'Overhead L' but also at sunrise and sunset, running the "then" or "else" clause at that time, even though no one did anything to 'Overhead L' switch.
Recommended Posts