Setting schedule for holidays

Posted on
Mon Jul 04, 2016 6:10 am
BruceP offline
Posts: 285
Joined: Sep 06, 2004

Setting schedule for holidays

On US holidays I wish to change some schedules vis variables , as we are home most on the day on a usual work day.
July 4 is an easy one since it is a set date.
Labor Day and Memorial Day are not so easy since the dates move. Is there a way to change a variable at 00:05 the day of a holiday?
I have yet to master any scripts, so I am sure this limits my choices.

Thanks all

Posted on
Mon Jul 04, 2016 7:32 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Setting schedule for holidays

Why not just have a variable that says "Holiday" that you can set via a button on a control page when you get up on that day? That way you can just trigger action groups that enable/disable schedules based on that variable. I do something similar but I have a "Holiday/Vacation Start" scheduled item and a "Holiday/Vacation End" scheduled item that enables and disables my various schedules - that way I can lay it out in advance and set the exact date and time I want it to start and end.

As far as "knowing" that today is a holiday and at 5 minutes past midnight (00:05) you want things to change then that will require scripting.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Mon Jul 04, 2016 8:02 am
johnpolasek offline
Posts: 911
Joined: Aug 05, 2011
Location: Aggieland, Texas

Re: Setting schedule for holidays

Or if you want to get fancy, you could create a file that you update once a year which lists the holidays YOU observe and their dates for the upcoming year and have a script to read the file at midnight + 1 second each night and do whatever setup you want if a holiday date matches now()... the problem with using an internet source to get the dates is that the sources list of holidays may not coincide with the days you observe... case in point, Texas A&M does not observe Labor Day as a holiday; but pretty much every holiday list does.... And at a company I once worked for in Louisiana, the Monday after the opening of alligator season WAS a company holiday because so many of the operators were out checking their lines.

Posted on
Mon Jul 04, 2016 12:52 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Setting schedule for holidays

I realize that the OP said he has yet to master scripts, but I also offer that there is a Python Holidays package. It has a few more holidays than you might want (which can easily be ignored), and provides examples to show how you can add additional custom holidays (like Alligator season.)

Code: Select all
>>> import holidays
>>> from datetime import date
>>> date(2016, 7, 4) in holidays.US()
True
>>>

Screen Shot 2016-07-04 at 1.40.08 PM.png
Screen Shot 2016-07-04 at 1.40.08 PM.png (76.59 KiB) Viewed 5157 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jul 04, 2016 1:17 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Setting schedule for holidays

Good find, Dave.

Install the holiday package:

Code: Select all
sudo pip install holidays


Create a variable called "isHoliday" (or whatever you want, really).

Create a schedule that runs this script right after midnight. Change the ID in the script to the one for your variable.

Code: Select all
# indigo.variables[1315142287] # "isHoliday"

from datetime import date
import holidays

indigo.variable.updateValue(1315142287, value="False")

us_holidays = holidays.UnitedStates()  # or holidays.US()

if date.today() in us_holidays:
   indigo.variable.updateValue(1315142287, value="True")


joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jul 04, 2016 2:48 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Setting schedule for holidays

If you want to also grab the name of the holiday, you can use:

Code: Select all
indigo.variable.updateValue(another_variable_ID, us_holidays.get(date.today()))

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Jul 05, 2016 5:45 am
Japple55 offline
Posts: 224
Joined: Sep 26, 2015
Location: NE Tennessee

Re: Setting schedule for holidays

I, too, was rudely reminded yesterday morning that I needed to set up a holiday schedule. Not being a coder, I took a more simplistic approach by just using Indigo's schedules. No iCal, python, or Applescript needed. It seems so simple that maybe I'm missing something...is there any reason this won't work going forward?

1. Create the variable "holiday."
2. Create a schedule to set the variable to "true." (Holiday Mode - Start)
3. On the Conditions tab, add a match rule for each date whose holiday you wish to observe. (mine only has 9)
3. Set the schedule to run every day at 12:01 AM to test for a holiday match.
4. Create another schedule to run every day at 11:59 PM to reset the variable back to "false." (Holiday Mode - End)

Granted, the condition dates need to be updated once per year for those holidays that aren't static, but I set a calendar task to remind me before the end of the year.

Jim

Posted on
Tue Jul 05, 2016 5:51 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Setting schedule for holidays

Japple55 wrote:
I, too, was rudely reminded yesterday morning that I needed to set up a holiday schedule. Not being a coder, I took a more simplistic approach by just using Indigo's schedules. No iCal, python, or Applescript needed. It seems so simple that maybe I'm missing something...is there any reason this won't work going forward?

1. Create the variable "holiday."
2. Create a schedule to set the variable to "true." (Holiday Mode - Start)
3. On the Conditions tab, add a match rule for each date whose holiday you wish to observe. (mine only has 9)
3. Set the schedule to run every day at 12:01 AM to test for a holiday match.
4. Create another schedule to run every day at 11:59 PM to reset the variable back to "false." (Holiday Mode - End)

Granted, the condition dates need to be updated once per year for those holidays that aren't static, but I set a calendar task to remind me before the end of the year.

Jim

I think that this would work well. The only downside is that part about remembering to update the holidays that aren't static. I'm lucky if I remember to put on pants.

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Jul 05, 2016 5:56 am
Japple55 offline
Posts: 224
Joined: Sep 26, 2015
Location: NE Tennessee

Re: Setting schedule for holidays

I'm lucky if I remember to put on pants.

Hilarious, Dave! :)

Posted on
Tue Jul 05, 2016 5:58 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Setting schedule for holidays

Japple55 wrote:
I'm lucky if I remember to put on pants.

Hilarious, Dave! :)

I had to double-check, but I remembered.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Jul 05, 2016 9:53 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Setting schedule for holidays

I believe if you move the logic back to the schedule itself, you can probably create a recurring event that only fires on the specific date you're looking for. This only works with holidays that are calculable (and no weird exceptions), but I think most are.

For instance, Memorial Day in the US is defined as the last Monday in May. You can create a schedule that runs every year on that day thusly:

  • Set the Time of the schedule to 12:01
  • Set the Date to "on the last Monday"
  • set Repeat to Every 12 months
  • set Start on to May 1st 2016

If you then inspect that schedule in a python shell, you'll see the nextExecution property is set to "2017-05-29 00:01:00".

I'm not positive that every conceivable scenario is possible with just the UI, but I suspect most are.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 05, 2016 11:21 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Setting schedule for holidays

I'm not positive that every conceivable scenario is possible with just the UI, but I suspect most are.

The biggest issue is likely Easter if that applies to each person's particular religious calendar. I believe I've read that it is based on lunar calendar/cycles, but based on the dates each year I am about 99% sure this is a conspiracy and it is actually based on a roll of a magic 8-ball somewhere.

I started to write a calendar plugin a while back... with this Holiday module, this could be super simple. Hmm...

Posted on
Tue Jul 05, 2016 4:24 pm
BruceP offline
Posts: 285
Joined: Sep 06, 2004

Re: Setting schedule for holidays

Wow, thank you all.
We had a little medical emergency in the family and just returned to look at the posts. Wonderful suggestions.

Time now is tight for this issue, but please understand I will be looking at this soon.

Again thanks.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests