Creating a scene based upon a holiday season — help needed

Good morning,
I’m trying to figure out if there is a way to set up a Reactor condition that will be enabled between a floating date and a specific date. Specifically, I want to enable a condition between Thanksgiving, which of course is a floating holiday, as a start date, and Ephipany, which is January 6th (fixed date), for Christmas lights. I know of course I could just set it up to start December 1st, or manually go in once a year and set for Thanksgiving, but I’m trying to figure out if I can do it using the Gcal plugin. I know I can have the holidays in Gcal, but I don’t know if I can use that date somehow as a start date in Reactor somehow.

Any ideas/advice?

Thanks.

Calculating the date of thankgiving is fairly easy. Using expressions and luaxp.

28 - 6 - tonumber(strftime('%w', date( timepart().year , 11, 1))) + 4
or
26 - tonumber(strftime('%w', date( timepart().year , 11, 1))) 

But i see no way to enter the result in to the date field, maybe @rigpapa will enlighten us.

Edit/
Ok thought about this and think it can be done with this expression
named ‘thanksgiving’

date(timepart().year, 11,(26 - tonumber(strftime('%w', date( timepart().year , 11, 1))))) < date()  && date(timepart().year + 1,1,6) > date()

and these conditions

1 Like

A simpler, less accurate solution would be to use week numbers. You would start at week 48 and end at week 2.

I use that for my exterior lights seasonal adjustments. A constantly wobbling start time irritates me more than the lights being on +/-30m from optimal as I am constantly thinking the event is busted.

Break it down and think of it as three time periods:

  1. From Thanksgiving through the end of the month of November;
  2. The entire month of December;
  3. The part of January before the 6th.

Thanksgiving is the fourth Thursday in November. That’s resolvable with a Weekday condition as a single-day test. To get the period through the end of the month, we’ll play a little date trick: the earliest date that can be the fourth Thursday of November in any year is the 22nd, so the longest range of time from the fourth Thursday of November to the end of month would be from 11/22 to 11/30. If we AND those two conditions together, they will only be true on the fourth Thursday, that one day. But, if we latch the Weekday condition, then once it goes true on the fourth Thursday, it stays true. It will stay true as long as the other (Date/Time) condition in the same group remains true. So that covers Thanksgiving through the end of the month.

Tests 2 and 3 are easy, just date ranges. Now, if you think about it, ranges 2 and 3 can be combined into a single Date/Time range from 12/1 to 1/6. Easy.

We could stop there and just implement it like that in an OR group, but it turns out, we can even combine the last Date/Time condition (12/1 - 1/6) with the earlier one paired with the Weekday condition. We really only need our two conditions in an AND group to do the whole thing.

The result is so simple to implement (but maybe not think about/dream up) that I think you’re going to be blown away:

Make sure you make (only) the Weekday condition latching.

Now, since we’re past Thanksgiving already, this condition can’t trigger immediately, so we need to give it a little help. After setting up the conditions and saving, go to the Tools tab, and set the “Test Date” to Thanksgiving Day (which was 11/26). Then go to the Status tab, and very important when asked if you want to restart the RS, click Cancel. Then, go back to the Tools tab and turn off the “Test Date” checkbox, go back to Status, and again, click Cancel when asked if you want to restart the RS. The group should hold true in the status at this point, and you’re in real time. It should be good this year until 1/6, unless you restart somehow otherwise (then just go through the Test Date machinations to get it back on). Left to itself, next year, it should go true on Thanksgiving Day.

To add control of lights or other devices at specific times, use a Group State condition specifying this group, and AND it with whatever time restrictions you need to place on the devices.


Additional Theory of Operation

The Date/Time group will obviously go true and stay true from 11/22 to 1/6. Because it’s in an AND group, the group itself cannot go true until the Weekday condition is met. Because we made the Weekday condition latching, once it goes true, it stays true, and it will stay true until the group its in goes false. The group can only go false when the Date/Time condition goes false (midnight on 1/6). At that point, the latch reset. Since the conditions are false, the group will be false, until next year…

1 Like

Wow, that’s pretty ingenious Patrick. I’ll get this set up and let you know how it works out. Much less hassle than setting up a Google Calendar and having to deal with the logic from there.