CODE: Public Holiday virtual switch

Here comes a version with an implementation of my feature request

Display a warning message if there are no future holidays in the ics file.
Question to the community: does anyone have examples of published holiday *.ics files that use recurrence rules? I have a feeling I should support them, and need real-world samples. All the examples I've seen so far are one-off all-day events.

http://dl.erweiterungen.de/kalenderdateien/Feiertage_2009-2013_DE.ics

… and a version with an implementation of my feature request

Use a local ics file

[tt]scp[/tt] the [tt]ics[/tt] file to [tt]/etc/cmh-ludl[/tt], set the variable [tt]calendar[/tt] to the name of your [tt]ics[/tt] file (without path) and restart the Lua engine.
Do not use ‘MiOS developers’ → ‘Luup files’ to upload the [tt]ics[/tt] file to your Vera.
If the variable [tt]calendar[/tt] contains [tt]http://[/tt], PHVS will use the remote file.

[quote=“Ap15e, post:23, topic:168188”]… and a version with an implementation of my feature request

Use a local ics file
[/quote]

Thanks for that. I will probably change the plugin to use proper URI syntax (“file:/etc/cmh-ludl/calendar.ics”) when referencing local files, because as it stands you’ve accidentally broken it for HTTPS.

Brilliant, thanks for that specimen. I’ve been reading the RFC on icalendar format, and I’m a bit apprehensive, it’s got so many special cases. Having some real-world examples helps me to target the parts of the spec that are actually used in the wild.

Thanks for that. I will probably change the plugin to use proper URI syntax ("file:/etc/cmh-ludl/calendar.ics") when referencing local files, because as it stands you've accidentally broken it for HTTPS.

Yes, please implement the proper URI syntax.

The attached file fixes the [tt]https[/tt] bug.

@Ap15e, loaded the latest “I”.xml file, place my ICS file in proper Vera Directory and was able to get a working Holiday device. The only issue is that my future holiday’s seem to be out of sequence (see below) any clues?

Holiday:
Future holidays:
20111101-20111102 Election Day
20110619-20110620 Father’s Day
20111010-20111011 Columbus Day
20111124-20111125 Thanksgiving
20110905-20110906 Labor Day
20110704-20110705 Independence Day
20111031-20111101 Halloween
20110508-20110509 Mother’s Day
20111106-20111107 Daylight Saving Time Ends
20111224-20111225 Christmas Eve
20110505-20110506 Cinco de Mayo
20111108-20111109 Election Day
20111111-20111112 Veterans Day
20110530-20110531 Memorial Day
20110529-20110530 John F. Kennedy’s Birthday
20111225-20111226 Christmas

The current [tt]“I”.xml[/tt] file doesn’t sort the future holidays. If the holidays in the [tt]ics[/tt] file are unsorted, so are the holidays on the ‘Control’ tab. Please ask futzle to implement your feature request.

Yeah, I thought it was oddly convenient that our samples sorted the holidays by date, because the ICS file format is under no requirement to do so.

It’ll be a little more complicated than just sorting when I implement support for recurrence rules, so be warned that I can’t grant your wish immediately. In the mean time, you can hand-edit the ICS file (it’s just text) and move blocks of lines from BEGIN: to END: around until the file is in the order you want.

It affects the order list in the display, not the end result, is this correct ?

Correct. Purely visual.

As always I can’t figure the easy stuff out.
Installed it all. Created a calendar on my web server. Holidays show up.
Go to use it in a scene. Events - add - device (select holiday device) - “what type of event is the trigger” just says “please select” and I have no other choices.
What silly thing am I doing wrong?

What silly thing am I doing wrong?

You’re using UI4 … :slight_smile:

@futzle
Please add the event list to the [tt]json[/tt] file to support events for UI4 (http://forum.micasaverde.com/index.php?topic=3801.msg18984#msg18984).

[quote=“Ap15e, post:33, topic:168188”]@futzle
Please add the event list to the [tt]json[/tt] file to support events for UI4 (http://forum.micasaverde.com/index.php?topic=3801.msg18984#msg18984).[/quote]

Yes UI4. Can’t get to the link you posted. :frowning:

The relevant part from http://forum.micasaverde.com/index.php?topic=3801.msg18984#msg18984 is:

UI2 scenes/events definitions are not compatible with UI3/4, since after UI2 json data wasn't stored in xml files anymore. You need to create a json file with sceneList and eventList which were previously stored in xml file, [...]

[quote=“Ap15e, post:35, topic:168188”]The relevant part from http://forum.micasaverde.com/index.php?topic=3801.msg18984#msg18984 is:

UI2 scenes/events definitions are not compatible with UI3/4, since after UI2 json data wasn't stored in xml files anymore. You need to create a json file with sceneList and eventList which were previously stored in xml file, [...]
[/quote]

…not quite sure what that means…

[quote=“Ap15e, post:28, topic:168188”]The current [tt]“I”.xml[/tt] file doesn’t sort the future holidays. If the holidays in the [tt]ics[/tt] file are unsorted, so are the holidays on the ‘Control’ tab. Please ask futzle to implement your feature request.[/quote] Thanxs @Ap15e, I will manually sort the ICS file as suggested, as it’s a “purely visual” issue, many thanxs to both your self and @futzle for the capability and features. Mike

[quote=“markbannister, post:36, topic:168188”][quote=“Ap15e, post:35, topic:168188”]The relevant part from http://forum.micasaverde.com/index.php?topic=3801.msg18984#msg18984 is:

UI2 scenes/events definitions are not compatible with UI3/4, since after UI2 json data wasn't stored in xml files anymore. You need to create a json file with sceneList and eventList which were previously stored in xml file, [...]
[/quote]

…not quite sure what that means…[/quote]

It’s aimed at me. The D_* files I’ve supplied were hacked from a Vera UI2 original, and the file format has changed a bit for UI4.

I’ll stick it on my to-do list for the plugin. It’s getting quite long… Meanwhile you can make the scene conditional on the Status of the device, by making a scene run every day at x o’clock, and putting this into the scene’s “Luup” tab:

-- Replace 74 with your Holiday device's id. -- "1" means run this scene only on holidays. Use "0" for inverse. return luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status" ,74) == "1"

@futzle

You definitely have your work cut out for you. lol. Take your time, man. No rush. Thanks again for this useful plugin and I look forward to the updated versions. Don’t stop and keep up the good work!!! :slight_smile:

I really have to learn how to create plugins myself so that I can assist, I’m slowly warming up to Lua. lol. I’ll get there one of these days.

… and here comes my final contribution to the PHVS with a fix for the order of future holidays.