We have moved at community.getvera.com

Author Topic: CODE: Public Holiday virtual switch  (Read 56352 times)

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: CODE: Public Holiday virtual switch
« Reply #15 on: April 24, 2011, 01:08:52 pm »
Here comes a quick and dirty implementation of my feature request

Quote
Display a [complete] list of future holidays on the 'Control' tab (could be implemented via HTML injection via UPnP variable ...)

Offline iflyM3

  • Full Member
  • ***
  • Posts: 144
  • Karma: +0/-0
Re: CODE: Public Holiday virtual switch
« Reply #16 on: April 24, 2011, 06:13:20 pm »
@futzle,

Thank you kindly for creating this, the Holiday Virtual Switch is cool and most certainly useful.  It will def. be nice to bypass certain scenes if a holiday is near.



@Ap15e

I dig it, nice tweak.   :)
Vera 2 UI5 (1.5.622)... and too many Z-Wave/Ethernet/Wi-Fi devices to list.

Offline MNB

  • Hero Member
  • *****
  • Posts: 689
  • Karma: +4/-9
Re: CODE: Public Holiday virtual switch
« Reply #17 on: April 24, 2011, 07:51:02 pm »
@futzle, question the link in your quote is for Auzie holiday's is it possible to down load my countries holiday ical and reference it from my computer vs a URL?

@Ap15e thanxs for the update I like seeing future holidays, I notice that today did not turn On (Easter) might just be that I updated today?


5. Click the spanner/wrench and go to the Advanced tab.  Scroll to the bottom and in the calendar field, put the URL of the iCal file (e.g. http://www.vic.gov.au/ical/holidays.html).

« Last Edit: April 24, 2011, 07:52:50 pm by Michael_N_Blackwell »
Edge-1.7.2607, VRI06-1LX Dimr (6), VS05-1LX Sw (4), GE ZW3002 Dimr (1), HA01C Outlet (12), HA02C Sw (6), HA04C Sw (4), GE Sw (2), HA05 Sw (3), MiniMote Contr (5), HSM200/100 Sensor (2), ZW100A Sensor (8), Nest thermostat (1) & Protect Fire/CO (6) Kwikset Locks (3), F18918W (1) & IP3M-9 (6) Cam's

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: CODE: Public Holiday virtual switch
« Reply #18 on: April 24, 2011, 08:51:34 pm »
@futzle, question the link in your quote is for Auzie holiday's is it possible to down load my countries holiday ical and reference it from my computer vs a URL?

Absolutely.  You just need to be able to have an iCalendar-format file (*.ics) on a machine on your LAN that can serve web pages.  I'm in a Mac household, so I'd do something like this:
1. Set up Web Sharing on my computer, turning on the computer's built-in web server.  (This is the bit that would be most different for Windows users.  You could download Apache, or enable your computer's built-in IIS.  Perhaps an expert can chime in.)
2. Publish the calendar from iCal or Outlook, to a file inside the web server's directory (~UserName/Sites/my-calendar.ics).  Or, if I already have an externally-sourced *.ics file, just copy it to the same location.
3. Point the HolidayVirtualSwitch calendar variable at the file on the server (http://my-computer/~UserName/my-calendar.ics).

Related: There's a feature request from @Ap15e to make the plugin work with a local file on the Vera, which you'd copy over to it using SFTP.  I just haven't coded it up yet.

Quote
@Ap15e thanxs for the update I like seeing future holidays, I notice that today did not turn On (Easter) might just be that I updated today?

It needs two cycles of reloading the Luup engine to appear.  Nice addition, @Ap15e.  I will consider your hack the new official version :)

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.

Offline MNB

  • Hero Member
  • *****
  • Posts: 689
  • Karma: +4/-9
Re: CODE: Public Holiday virtual switch
« Reply #19 on: April 25, 2011, 12:46:06 pm »
Related: There's a feature request from @Ap15e to make the plugin work with a local file on the Vera, which you'd copy over to it using SFTP.  I just haven't coded it up yet.

Yes please, in my humble opinion it makes better sense rather than trying to find web servers to link to (although suggest keeping the capability).

@Ap15e I'm not clear as to recurrence rules is this holidays that re-occur from year to year or is this a holiday that expand more than one day?
Edge-1.7.2607, VRI06-1LX Dimr (6), VS05-1LX Sw (4), GE ZW3002 Dimr (1), HA01C Outlet (12), HA02C Sw (6), HA04C Sw (4), GE Sw (2), HA05 Sw (3), MiniMote Contr (5), HSM200/100 Sensor (2), ZW100A Sensor (8), Nest thermostat (1) & Protect Fire/CO (6) Kwikset Locks (3), F18918W (1) & IP3M-9 (6) Cam's

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: CODE: Public Holiday virtual switch
« Reply #20 on: April 25, 2011, 01:30:03 pm »
Here comes a version with an implementation of my feature request

Quote
Display a warning message if there are no future holidays in the ics file.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: CODE: Public Holiday virtual switch
« Reply #21 on: April 25, 2011, 05:22:17 pm »
Quote
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

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: CODE: Public Holiday virtual switch
« Reply #22 on: April 25, 2011, 05:34:12 pm »
... and a version with an implementation of my feature request

Quote
Use a local ics file

scp the ics file to /etc/cmh-ludl, set the variable calendar to the name of your ics file (without path) and restart the Lua engine.
Do not use 'MiOS developers' -> 'Luup files' to upload the ics file to your Vera.
If the variable calendar contains http://, PHVS will use the remote file.
« Last Edit: April 25, 2011, 05:36:38 pm by Ap15e »

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: CODE: Public Holiday virtual switch
« Reply #23 on: April 25, 2011, 07:27:07 pm »
... and a version with an implementation of my feature request
Quote
Use a local ics file

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.

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: CODE: Public Holiday virtual switch
« Reply #24 on: April 25, 2011, 07:29:08 pm »
http://dl.erweiterungen.de/kalenderdateien/Feiertage_2009-2013_DE.ics

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.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: CODE: Public Holiday virtual switch
« Reply #25 on: April 26, 2011, 05:30:57 am »
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.

Yes, please implement the proper URI syntax.

The attached file fixes the https bug.

Offline MNB

  • Hero Member
  • *****
  • Posts: 689
  • Karma: +4/-9
Re: CODE: Public Holiday virtual switch
« Reply #26 on: April 26, 2011, 09:23:09 pm »
@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
Edge-1.7.2607, VRI06-1LX Dimr (6), VS05-1LX Sw (4), GE ZW3002 Dimr (1), HA01C Outlet (12), HA02C Sw (6), HA04C Sw (4), GE Sw (2), HA05 Sw (3), MiniMote Contr (5), HSM200/100 Sensor (2), ZW100A Sensor (8), Nest thermostat (1) & Protect Fire/CO (6) Kwikset Locks (3), F18918W (1) & IP3M-9 (6) Cam's

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: CODE: Public Holiday virtual switch
« Reply #27 on: April 27, 2011, 04:15:56 am »
The current "I".xml file doesn't sort the future holidays. If the holidays in the ics file are unsorted, so are the holidays on the 'Control' tab. Please ask futzle to implement your feature request.

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: CODE: Public Holiday virtual switch
« Reply #28 on: April 27, 2011, 05:31:34 am »
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.

Offline huogas

  • Sr. Member
  • ****
  • Posts: 301
  • Karma: +0/-0
Re: CODE: Public Holiday virtual switch
« Reply #29 on: April 27, 2011, 06:28:01 am »
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 affects the order list in the display, not the end result, is this correct ?
Vera2 UI4(1.1.1245/3.2), Kwikset x1, HM-DW001 x1, ZRP100 x1, HA-04WD x1, ZDP100 x6, HSM100 x2, VRI06-1LX x8, ZW5301 x1, HM-FS001 x2, ZRW103W x1, GE 45606 x2, HA05C x1, TED5000 x1