[Updated] 'Holiday Switch' Driver - Now an app too!

Background

I wanted to restrict some of my automations to not happen when it's a national holiday (We call them Bank Holidays in the UK) like that early morning weekday 'Wake up!' announcement

So, now all these types of automations are restricted by 'Holiday Switch'

How it works
Using a free API key from https://calendarific.com this switch turns on when there is a national holiday and off when there isn't!

Configuration & Use
To use this driver, sign up to get your free api key then just create a new virtual device and assign this driver to it then add your configuration before saving

You can configure it for most countries and the following holiday types:

  • National
  • Local
  • Religious

USA guys can also specify state in the country configuration for use with Local & National holidays
(e.g. US will return all US holidays, US-FL will return holidays in Florida, US-NY will return holidays in New York state)

The following Religious holiday types are configurable too:

  • Buddhism
  • Christian
  • Hinduism
  • Muslim
  • Hebrew

For religious holidays, you need to save the device after selecting 'Religious' from the drop down holiday type list, then save and open again to configure which religion you want to switch upon

If there is a religion I have missed (which calendarific provide) then I will happily add this

Future is here...
I'm releasing the parent/child app that gives you the ability to add your own holidays to the mix, switching on during your holiday, off when it finishes
Here:
https://github.com/CobraVmax/Hubitat/tree/master/Apps/Holiday%20Switch

Install the parent child code then create a new child app..

Select your 'Holiday' virtual switch device
image

Next bit is pretty obvious..

Then name the holiday and the child app (Holiday name will be shown when this holiday is active)
image

This now means that during this time the switch will be turned on.. irrespective on any national holidays

Driver
This driver is released as 'open source' (although the app isn't) and you can find it here:
https://github.com/CobraVmax/Hubitat/tree/master/Drivers/HolidaySwitch

Many thanks (as always) to @Royski for his patient beta testing

And yes. I'm off to watch the Hungarian Grand Pix in August :slight_smile:

Hope y'all find it useful!

Andy

11 Likes

Hi @Cobra
Just thought I'd let you know that my Holiday switch turned on today at midnight.
image
Thanks again for this.

3 Likes

That’s brilliant!

Mine didn’t :slight_smile:
I am in Paris for the weekend so mine automatically turned on friday afternoon. Hopefully it will turn off on tuesday afternoon when I should be getting home :slight_smile:

I’m testing a new app that works for your configured holidays and will override bank holidays if they are in the middle of another holiday. (The switch will still be on though)

I’ll release it when I get home sometime this week probably.

Andy

3 Likes

Happy to confirm the app worked as it should.
I’ll finish it off and release it soon :slight_smile:

Andy

3 Likes

Ok..
so app is now released..
Check out the 1st post for details..

Andy

I was going to explore this Holiday Switch driver but ran into the following error when trying to install the Parent Driver.

No signature of method: Script1.definition() is applicable for argument types: (java.util.LinkedHashMap) values: [[name:Holiday Switch, namespace:Cobra, author:Andrew Parker, ...]]

I am running Hubitat firmware 2.1.0.123

Any ideas on what might be wrong?

FYI, I also tried installing the child driver and got the same result. :expressionless:

Doh! Never mind! Argghhhh!?!?!?!

I really confused the installation of the driver and app code. Bottom line, once I sorted out the driver code into the drivers section and the app code into the app section, everything installed successfully.

Sorry for the false alarm.

1 Like

We have all done it!

@Cobra is this all i need to do for country? Then off it will go?

1 Like

I have GB in lower case and National selected as you have and it works OK for me.
Don't think its case sensitive though.

2 Likes

The country code doesn’t seem to be case sensitive at all.

Andy

1 Like

Can this app work without the external web service?
Had a look at the calendarific site, but it didn't look particularly helpful for Australia (lots of non-holiday days, and no state based ones), so I didn't sign up.

I manually created a holiday for today (about a week ago), but the switch has not turned on.
Nothing in the logs other than a 12am message about being up to date. Scheduled job resetMsg says previous run was at 1am this morning.
Edit: actually there was a log under the child app, missed that:

2019-06-10 00:00:02.842 errorjava.lang.IllegalArgumentException: Command 'OverrideOn' is not supported by device. on line 170 (switchNow1)

The app might work but was designed to work with the virtual switch driver which has the ‘overrideOn’ command built in.
The error msg looks like you are trying to use it with something else.

If you just want to turn on/off a switch without using the wbsite I would suggest my ‘Scheduled Switch’ app
This will do what you want for any switch.

Andy

Right, ok, I misunderstood somewhere - I had it set to the HolidaySwitch device driver (from the top of this thread, listed under the heading Driver).

Sounds perfect, I'll check it out, thanks!

That's the driver I meant..
Hmmm..
I'll have a look again at the error and the app

Andy

I've just tested a couple of times and cannot reproduce the error at all

I had a quick look and the line to define the OverrideOn command is commented out in the driver, could that be the issue? (it matches the github though)

I have setup Scheduled Switch instead anyway - I'll declare a new holiday later this week to test it :laughing:

You are perfectly correct!

I had not updated the driver code from my version here.
Updated code now on github
Version 1.2.0 of the driver code.
This version also gives you the ability to reverse the switch.. so the switch if OFF during a holiday rather than ON

Sorry about that

Andy

Hi @Cobra, thanks for the switch, its a great idea.

Is there a way we can view which dates it'll switch on??

Not currently.
It just queries the website to see if it need to turn on today

2 Likes