My primary justification for getting into Indigo and Insteon was to make it easier for me to get up on time for work, with the lights already being on. I've been refining this as I go along, and it's all still quite rough around the edges. As for other justifications... well, does it really need justifying?
Yesterday was a work holiday (columbus day). Having the lights come on at 6:45am when I didn't have to get up was a bit annoying, but prompted me to spend some time solving that problem today.
At work, our email system has a calendar component that supports CalDAV. I've subscribed to my CalDAV account from iCal on my Indigo server. In that calendar, we have a shared calendar just for office events. All the holidays are in there in the format of "Holiday: Columbus Day", and are listed as "all day" events. So, the data needed to make this work was available, and I just needed a simple way to interface that into Indigo. You could just as easily use a local calendar, or export a .ics from some system and import it into iCal, or whatnot.
I've set up a time/date action, to fire at 12:30am (midnight:30) every day called "Daily tasks" for doing daily housekeeping routines. Currently, it runs an external applescript, which talks to iCal, and sets the Indigo variable. That variable is used by other actions to make decisions. I don't have any other actions yet, but can easily add more.
Here's the script.
- Code: Select all
set myDate to date string of (current date)
set theCalendar to "Holiday Events" -- the calendar you're checking
set holidayVariable to "workHoliday"
on setVariable(theVariable, theValue)
-- borrowed from http://www.perceptiveautomation.com/wiki/doku.php?id=applescript_snippit
tell application "IndigoServer.app"
if variable theVariable exists then
set value of variable theVariable to theValue
else
make new variable with properties {name:theVariable, value:theValue}
end if
end tell
end setVariable
-- presume a day isn't a holiday by default
setVariable(holidayVariable, "false")
tell application "iCal"
set theEvents to every event of calendar theCalendar
repeat with thisEvent in theEvents
if date string of (get start date of thisEvent) is equal to myDate then
if allday event of thisEvent then
if (summary of thisEvent) contains "Holiday" then
-- this day must be a holiday
tell me to setVariable(holidayVariable, "true")
end if
end if
end if
end repeat
end tell
Perhaps this might be of use to someone else.
My original version was using curl to set the variable. However, when I realized I could really *only* run this script on the Indigo server itself, I used the more elegant snippet from the wiki.
jim