define <name> Calendar ical url <URL> [<interval>]
define <name> Calendar ical file <FILENAME> [<interval>]
https://
, the perl module IO::Socket::SSL must be installed
(use cpan -i IO::Socket::SSL
).https://
and the perl module IO::Socket::SSL is not installed on your system, you can
replace it by http://
if and only if there is no redirection to the https://
URL.
Check with your browser first if unsure.interval
is the time between subsequent updates
in seconds. It defaults to 3600 (1 hour).define MyCalendar Calendar ical url https://www.google.com/calendar/ical/john.doe%40example.com/private-foo4711/basic.ics define YourCalendar Calendar ical url http://www.google.com/calendar/ical/jane.doe%40example.com/private-bar0815/basic.ics 86400 define SomeCalendar Calendar ical file /home/johndoe/calendar.ics
set <name> update
interval
seconds later.get <name> full|text|summary|location|alarm|start|end <reading>|<uid> [max]
max
limits
the number of returned lines.get <name> find <regexp>
In case of multiple alarm times for a calendar event, only the earliest alarm time is kept.
Recurring calendar events are currently supported to an extent: FREQ INTERVAL UNTIL COUNT are interpreted, BYMONTHDAY BYDAY BYMONTH WKST are recognized but not interpreted. The module will get it most likely wrong if you have recurring calendar events with unrecognized or uninterpreted keywords.
A calendar event is identified by its UID. The UID is taken from the source calendar. All non-alphanumerical characters are stripped off the UID to make your life easier.
A calendar event can be in one of the following states:
new | The calendar event was first seen at the most recent update. Either this was your first retrieval of the calendar or you newly added the calendar event to the source calendar. |
known | The calendar event was already there before the most recent update. |
updated | The calendar event was already there before the most recent update but it has changed since it was last retrieved. |
deleted | The calendar event was there before the most recent update but is no longer. You removed it from the source calendar. The calendar event will be removed from all lists at the next update. |
A calendar event can be in one of the following modes:
upcoming | Neither the alarm time nor the start time of the calendar event is reached. |
alarm | The alarm time has passed but the start time of the calendar event is not yet reached. |
start | The start time has passed but the end time of the calendar event is not yet reached. |
end | The end time of the calendar event has passed. |
A calendar device has several readings. Except for calname
, each reading is a semicolon-separated list of UIDs of
calendar events that satisfy certain conditions:
calname | name of the calendar |
all | all events |
modeAlarm | events in alarm mode |
modeAlarmOrStart | events in alarm or start mode |
modeAlarmed | events that have just transitioned from upcoming to alarm mode |
modeChanged | events that have just changed their mode somehow |
modeEnd | events in end mode |
modeEnded | events that have just transitioned from start to end mode |
modeStart | events in start mode |
modeStarted | events that have just transitioned to start mode |
modeUpcoming | events in upcoming mode |
stateChanged | events that have just changed their state somehow |
stateDeleted | events in state deleted |
stateNew | events in state new |
stateUpdated | events in state updated |
When a calendar event has changed, an event is created in the form
changed: UID mode
with mode being the current mode the calendar event is in after the change.
Usage scenarios
get MyCalendar full all
2767324dsfretfvds7dsfn3e4dsa234r234sdfds6bh874googlecom known alarm 31.05.2012 17:00:00 07.06.2012 16:30:00-07.06.2012 18:00:00 Erna for coffee
992hydf4y44awer5466lhfdsrgl7tin6b6mckf8glmhui4googlecom known upcoming 08.06.2012 00:00:00-09.06.2012 00:00:00 Vacation
text 20 60 { fhem("get MyCalendar text modeAlarmOrStart") }
07.06.12 16:30 Erna for coffee
08.06.12 00:00 Vacation
get MyCalendar find .*Erna.*
2767324dsfretfvds7dsfn3e4dsa234r234sdfds6bh874googlecom
define ErnaComes notify MyCalendar:modeStarted.*2767324dsfretfvds7dsfn3e4dsa234r234sdfds6bh874googlecom.* set MyLight on
define LogErna notify MyCalendar:modeAlarmed.*2767324dsfretfvds7dsfn3e4dsa234r234sdfds6bh874googlecom.* { Log3 %NAME, 1, "ALARM name=%NAME event=%EVENT part1=%EVTPART0 part2=%EVTPART1" }
define SwitchActorOn notify MyCalendar:modeStarted.* {
my $reading="%EVTPART0";;
my $uid= "%EVTPART1";;
my $actor= fhem("get MyCalendar summary $uid");;
if(defined $actor) {
fhem("set $actor on")
}
}
define SwitchActorOff notify MyCalendar:modeEnded.* {
my $reading="%EVTPART0";;
my $uid= "%EVTPART1";;
my $actor= fhem("get MyCalendar summary $uid");;
if(defined $actor) {
fhem("set $actor off")
}
}
define LogActors notify MyCalendar:mode(Started|Ended).* { my $reading= "%EVTPART0";; my $uid= "%EVTPART1";; my $actor= fhem("get MyCalendar summary $uid");; Log 3 %NAME, 1, "Actor: $actor, Reading $reading" }