CODE: Public Holiday virtual switch

@Ap15e “you da man (person)” ;D… many thanxs. Mike

It works great !

But i try with Google Calendar and the public ics link. I create an event, for the entire day, but i have nothing in status or futur holidays. Is there a special setting for events in Google Calendar ?

Hi cedriclocqueneux,

My code only handles a tiny subset of the full ics file format. Perhaps there’s something in the Google Calendar file that my code doesn’t recognize.

Are you able to post the text from the ics file here, so I can see how I need to change my code to support it? They’re just text files, so just open it up in a text editor and copy and paste it into a post.

Hi,

You can find example with this link, it’s a public calendar that i created: http://www.google.com/calendar/ical/locqueneux.com_t1gtpkp9khpee7dno2d50dbtg4%40group.calendar.google.com/public/basic.ics

I think there is a problem with recurrent event.
If i create lots of event one by one, all are listed on the Vera (on futur holidays)
If i create a recurrent event (for example each Wednesday or each year ), the plugin take only the first event, and ignore the other.

You’re plugin is great, and i want to use it for holidays, but also for birthdays, or also for rubbish collection day, per example. We can make lots of useful things :smiley: So, reccurent event will be very usefull.

Got it, thanks. Yes, recurring events are a known shortcoming. They are definitely on the to-do list. I’ll focus on the types of recurrences that I see in your ICS file (“every second Thursday”; “every day for 20 days”).

Super, thanks ! Do you have an idea when it will ok ?

Ask me how it’s going in a couple of weeks. This little project is just one of several I’ve got going at the moment, and I think I’d get in trouble if I ignored my family…

Ok, no problem. For the moment, i’ll create events individually :stuck_out_tongue:

Sorry, an other implementation that will be great: if there are more than one event this day, only the first is seen (not in the status or futur events). It will be good to concatenate entries from the day, maybe ? Useful for birthdays…

Day of week for future holidays …

Many thanxs @Ap15e works like a champ! I’ve notice that your in number of forums with various code submissions, question are you doing this part time or full time I’m assuming that your a programmer by trade? Mike

Tried installing this Virtual Switch and am getting an error about the D_HolidayVirtualSwitch1.xml file not being found (in /etc/cmh-lu). I’ve verified that the file is located in /etc/cmh-ludl though.

How do I include the path where the correct XML switch is actually located?

And in case it matters; I downloaded (and replace) the various files as they appeared through the thread. Lastly, I’m using UI4 (1.1.1267) at this stage.

The file must be compressed and be called D_HolidayVirtualSwitch1.xml.lzo (note double-barrel extension). Copying the file over SSH won’t compress it, so use the Vera UI to transfer the file or use the pluto-lzo command on the uncompressed file from the shell. Also, spelling and capitalization matters.

It should be in /etc/cmh-ludl not /etc/cmh-lu.

How do I include the path where the correct XML switch is actually located?

You don’t, and (I think) you can’t.

The file is in /etc/cmh-ludl, but according to the error message, it’s being looked for in /etc/cmh-lu

Files were transferred using the UI for upload with a “restart LUUP” at the end and then multiple restarts since. No difference & the device is presently “generic” with none of the variables visible.

That might be true, but then it may fall back to looking for the file in /etc/cmh-ludl, where it will find it. It’s in /etc/cmh-ludl on my Vera.

You say “error message”. Do you mean “line in Luup log file”? The log file is very chatty and just because it reports something doesn’t mean there’s a problem.

Sitting where I am, it looks like user error, so you’re going to have to list everything you did in excruciating detail so that I can see where things went wrong. With any luck, while doing that you’ll see the mistake and won’t need me. I see from your posting history that you’ve installed other plugins successfully.

(Note: I can’t vouch for the correctness of @Ap15e’s enhancements. I haven’t tried them all on my machine. I can only assure you that the first post in this topic has my versions of the files and they work for me, and presumably some other people.)

Steps taken:

Downloaded all 4 files from first forum post, then walked through forum and downloaded each of the files updated as they were listed (replacing the original/previous copy).

Uploaded all xml & json files (2 x .xml, 1x .json & 1x ical.lua) using the “MIOS Developers” → “Luup files” & checked “Restart Luup after upload”.

Restarted LUUP engine a couple of times.

Uploaded (using scp) ical.lua to /usr/lib/lua (just in case) & restarted the Luup engine again.

Get the following in the LuaUPnP.log file:

# tail -f /var/log/cmh/LuaUPnP.log
 --- SNIP ---
03	05/31/11 21:51:16.114	UserData::LoadUserData BuildVersion: *1.1.1267* SvnVersion: *Revision: 4582* Model: 2 SERCOMM NA401 flush: 0 changed: 0 resync: 5272 <0x400>
01	05/31/11 21:51:17.042	Device_LuaUPnP::LoadDeviceDoc can't load /etc/cmh-lu//D_HolidayVirtualSwitch1.xml. <0x400>
02	05/31/11 21:51:17.043	JobHandler_LuaUPnP::m_sMissingFile_set /etc/cmh-lu//D_HolidayVirtualSwitch1.xml. <0x400>
01	05/31/11 21:51:17.044	JobHandler_LuaUPnP::CreateDevice_LuaUPnP failed to load 104/D_HolidayVirtualSwitch1.xml. so device 104 is offline <0x400>
01	05/31/11 21:51:18.166	Device_LuaUPnP::CreateServices Aborting device 104 because the topmost device has no interface <0x400>
01	05/31/11 21:51:18.167	JobHandler_LuaUPnP::CreateAllServices failed to create 104 <0x400>

Output from ssh shell to validate location of files/etc:

root@MiOS_12592:/etc/cmh-ludl# pwd
/etc/cmh-ludl
root@MiOS_12592:/etc/cmh-ludl# ls -l *Holiday*
-rw-r--r--    1 root     root         1123 May 30 08:21 D_HolidayVirtualSwitch1.json.lzo
-rw-r--r--    1 root     root          740 May 30 08:38 D_HolidayVirtualSwitch1.xml.lzo
-rw-r--r--    1 root     root         2912 May 30 08:38 I_HolidayVirtualSwitch1.xml.lzo
root@MiOS_12592:/etc/cmh-ludl# cd /etc/cmh-lu/
root@MiOS_12592:/etc/cmh-lu# ls -l *Holiday*
ls: *Holiday*: No such file or directory
root@MiOS_12592:/etc/cmh-lu# 

I can reproduce this error message by having garbage text after the device filename in the device’s Advanced tab. My theory is that your device has a dot or space after the “.xml” in that field.

Uploaded all xml & json files ([...] ical.lua) using the "MIOS Developers" -> "Luup files" & checked "Restart Luup after upload".

Don’t upload the *.lua file that way (instead, scp it to /usr/lib/lua as you did). It should be harmless, but for correctness you should delete the file from /etc/cmh-ludl.

futzie
I created the holiday switch as per the list, but I’m unable to follow step #1, in the “To Install”
The reason is, I have no clue what to do. I can search for the WinSCP, but even then I won’t know how to use it, or how to find the directory on Vera, in which to paste it.
Assuming that I’m blank here, is there some hand holding for me??
P.S. I created the switch and now I have an ERROR in my UI stating:
Error in lua for scenes and events
Holiday Switch[55]:
Lua Engine failed to start

Is that because I didn’t have the ical.lua file in my user directory?
Thanks for your help,

[quote=“futzle, post:1, topic:168188”]Here’s another virtual device for your MiOS-meddling pleasure… It presents itself as a binary switch, which is

[ul][li] ON if today is a public holiday, and[/li]
[li]OFF it today is not.[/li][/ul]

For “public holiday” you can substitute anything which can be represented as all-day events in an iCalendar (*.ics) accessible over HTTP. Some ideas for using this device:

[ul][li]Use it as an inhibitor for the excellent WakeupRamp plugin so you can sleep in on holidays. (This is why I wrote the plugin.)[/li]
[li]Publish your vacation dates to an iCalendar file, and set scenes to start when you go away, and scenes to stop when you come back from your trip.[/li]
[li]Feed it with Jewish holidays from http://www.hebcal.com/ and use it for a sunset scene Luup Event condition.[/li][/ul]

To install:

  1. Use SSH (Unix scp or WinSCP or another tool) to copy ical.lua to /usr/lib/lua.
  2. Add D_HoildayVirtualSwitch1.xml, D_HolidayVirtualSwitch1.json and I_HolidayVirtualSwitch1.xml to MiOS Developers > Luup Files.
  3. Create a new Luup device with UpnpDevFilename D_HolidayVirtualSwitch1.xml. Set the Description to whatever you want to name the device.
  4. Save, wait, then reload, then wait. (It seems to take two Luup restarts for the variables to appear.)
  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. [b]http://www.vic.gov.au/ical/holidays.html[/b]).
  6. Optional: change the offset field to 1 if you want the device to represent tomorrow’s holidays (-1 for yesterday, 7 for next week, etc.).
  7. Close the dialog and Save.[/quote]

[quote=“RastusB2, post:58, topic:168188”]The reason is, I have no clue what to do. I can search for the WinSCP, but even then I won’t know how to use it, or how to find the directory on Vera, in which to paste it.
Assuming that I’m blank here, is there some hand holding for me??[/quote]

The important bits of information you need when connecting are:

[ul][li]The remote host: this is the IP address of the Vera[/li]
[li]The user name: root[/li]
[li]The password: unless you changed it, this is the words-and-numbers string printed on a sticker underneath your Vera[/li][/ul]

If there are other options, the defaults are probably good enough.

This should bring up a window showing the files in a directory on the Vera. Go to the Vera directory /usr/lib/lua (this directory already exists). You will see some subdirectories and some *.lua files. Drag and drop a copy of ical.lua to the /usr/lib/lua directory.

I can’t really give more detailed instructions than that. I don’t actually use WinSCP (not a Windows household). Perhaps an actual user of WinSCP can chime in, or you can do this with the Google results for “How To Use WinSCP” in one window…

(Update on this plugin for those interested: I’m working on a plan to make this plugin less memory- and CPU-intensive. I’m also planning to switch the HTML-injection hack for some JavaScript tabs. Also some prettier icons.)

What about UI5, any updates planned?