jim_ Posted December 15, 2014 Posted December 15, 2014 Trying to write a wakeup program that compares Sunrise and a wakeup time taking into account the season. Let’s say high summer, Sunrise is before wakeup time and I don't want the lights on, but in winter, wakeup is long before Sunrise, so turn the lights on until Sunrise turns them off. Given that Wakeup is fixed at 6:00AM during weekdays and Sunrise varies every day, how does one create the logic (Sunrise is false and time is 6:00 AM) = True, turn light on … else do nothing If On Mon, Tue, Wed, Thu, Fri Time is NOT Sunrise And On Mon, Tue, Wed, Thu, Fri Time is 6:00:00 AM Then Set 'Wakeup Light' On
stusviews Posted December 15, 2014 Posted December 15, 2014 I use four programs that depend on the season. This is the first year I'm doing this and need to experiment with the offsets. I chose to start with the dates midway between each equinox and solstice. Here's the current (winter) sunset program: If From 12:01:00AM on 2014/11/06 To 11:59:00PM on 2015/02/02 And Time is Sunset - 15 minutes Then Run Program 'Sunset Lighting' (If) Run Program 'Sunset Shading' (Then Path) Else - No Actions - (To add one, press 'Action') Note: the dates are year/month/day
cmccartney Posted December 16, 2014 Posted December 16, 2014 I use this logic to set a flag (a state variable) and another program to actually do the work: If From 4:45:00AM To Sunrise (same day) And ( On Mon, Tue, Wed, Thu, Fri Time is 4:45:00AM Or On Sat Time is 6:00:00AM Or On Sun Time is 6:30:00AM ) And $i.Holiday is not 1 Then $s.Dawn = 9 $s.Dawn Init To $s.Dawn Else - No Actions - (To add one, press 'Action') This program sets the Dawn flag in order to turn on some lightsjust before we normally rise and shine, except on holidays. The first IF in this program will only set the flag if itis still dark (pre-sunrise) i.e., not during the summer months,especially on weekend mornings. The 'Init' function maintains the variable's state over ISY restarts.
Xathros Posted December 16, 2014 Posted December 16, 2014 Jim- Try this: Define an integer variable: i.Daylight Program: Daylight If From Sunrise To Sunset (same day) Then $i.Daylight = 1 Else $i.Daylight = 0 Program: Wakeup If Time is 6:00:00AM And $i.Daylight is 0 Then Set Scene 'MBR Lights' On Else - No Actions - (To add one, press 'Action') Hope this helps. -Xathros
jim_ Posted December 17, 2014 Author Posted December 17, 2014 Quick Thank You for your suggestions, Good samples to learn from ...
apostolakisl Posted December 17, 2014 Posted December 17, 2014 (edited) Trying to write a wakeup program that compares Sunrise and a wakeup time taking into account the season. Let’s say high summer, Sunrise is before wakeup time and I don't want the lights on, but in winter, wakeup is long before Sunrise, so turn the lights on until Sunrise turns them off. Given that Wakeup is fixed at 6:00AM during weekdays and Sunrise varies every day, how does one create the logic (Sunrise is false and time is 6:00 AM) = True, turn light on … else do nothing If On Mon, Tue, Wed, Thu, Fri Time is NOT Sunrise And On Mon, Tue, Wed, Thu, Fri Time is 6:00:00 AM Then Set 'Wakeup Light' On You almost had it. If On Mon, Tue, Wed, Thu, Fri From 6:00:00AM To Sunrise (same day) Then Set Scene 'Wakeup Light' On Else This program only runs true at 6am if the sun hasn't risen. If sunrise happened before 6am, it runs false at 6am. It also runs false at sunrise. So if you want to also use the else clause, keep those things in mind. In a "from to" program, if the "to" is before the "from", it will be false. Both the "from" time and "to" times will trigger the program no matter what, just at some times of the year both triggers will run false and at other times the "from" will be true. Edited December 17, 2014 by apostolakisl
Xathros Posted December 17, 2014 Posted December 17, 2014 You almost had it. If On Mon, Tue, Wed, Thu, Fri From 6:00:00AM To Sunrise (same day) Then Set Scene 'Wakeup Light' On Else This program only runs true at 6am if the sun hasn't risen. If sunrise happened before 6am, it runs false at 6am. It also runs false at sunrise. So if you want to also use the else clause, keep those things in mind. In a "from to" program, if the "to" is before the "from", it will be false. Both the "from" time and "to" times will trigger the program no matter what, just at some times of the year both triggers will run false and at other times the "from" will be true. Nice! Clean and simple. Why didn't I think of this... -Xathros
oberkc Posted December 17, 2014 Posted December 17, 2014 Nice! Clean and simple. Why didn't I think of this... -Xathros I am equally upsdt that I did not think of this approach.I would have taken your approach, except for the variables (use program status instead...variables seem unnecessary for this application). As one who sees elegance in simplicity, my admiration goes out to apostolakisl.
apostolakisl Posted December 17, 2014 Posted December 17, 2014 I am equally upsdt that I did not think of this approach.I would have taken your approach, except for the variables (use program status instead...variables seem unnecessary for this application). As one who sees elegance in simplicity, my admiration goes out to apostolakisl. Well, I am not sure I invented this approach. I did have to run some experiments to find out what happens when the "from" time is after the "to" time, but I was probably discovering something that was already known. To be fair, using variables for "daylight hours" has advantages as well. Mostly, it opens up when you want to have more complex conditions that don't trigger on the "from" and "to" times and also it allows you to use the else clause.
oberkc Posted December 17, 2014 Posted December 17, 2014 Well, I am not sure I invented this approach. I did have to run some experiments to find out what happens when the "from" time is after the "to" time, but I was probably discovering something that was already known. To be fair, using variables for "daylight hours" has advantages as well. Mostly, it opens up when you want to have more complex conditions that don't trigger on the "from" and "to" times and also it allows you to use the else clause. True, there could be a global use for "daylight hours", but (being the fan of simplicity that I am) there is no need for variables in some cases: If Time is from sunrise To sunset Then Nothing Else Nothing This program will be either true or false, based on time of day, and could be used as a program conditon as well (no variable needed). If, however, one wanted a program condition that was not a program trigger, then the variable has an advantage, yes.
apostolakisl Posted December 17, 2014 Posted December 17, 2014 True, there could be a global use for "daylight hours", but (being the fan of simplicity that I am) there is no need for variables in some cases: If Time is from sunrise To sunset Then Nothing Else Nothing This program will be either true or false, based on time of day, and could be used as a program conditon as well (no variable needed). If, however, one wanted a program condition that was not a program trigger, then the variable has an advantage, yes. Yes, I actually have that very program. I wrote it before variables existed. That program will be a trigger when it changes conditions, so in that respect, you might still prefer an integer variable for certain applications. But as far as the OP's needs are concerned, it is a no-brainer to just use the simple program.
Recommended Posts