openHAB can integrate Google Calendars. The functionality is kind of limited, it can only see the current and the next calendar event, but in my case that is enough. More about the use case in another blog post.
There are three different calendar bindings available, let’s have a quick look:
- CalDAV Personal Binding: this is a v1 binding, which means it will no longer work in the soon-to-be-released openHAB v3. Apparently this works with Google calendars, but has performance issues. It can show the current and next event.
- Google Calendar Scheduler: also a v1 binding. Needs more work for presense simulation, and additional bindings.
- iCalendar Binding: v2 binding, should work with v3. It can show the current and next event. That’s the one I’m going to use.
Binding
In order to start using the icalendar binding, it must be installed. In my case that’s a job for Ansible:
|
|
More about this is described here.
iCal Calendar
Next comes the calendar data. Go to your Google calendar, click on the three dots next to the calendar you want to use.
And then click on Settings and sharing
. In the next window, scroll down to Integrate calendar
and copy the URL from the Private address in iCal format
field. That is the URL which needs to be added to the openHAB configuration.
openHAB configuration
The configuration needs a Thing
and Items
. Let’s start with the Thing
, which in my case is placed in calendar.things
. Since I deploy everything with Ansible, the file is a template:
|
|
The file credentials/reminders-calendar-ical.txt
holds the iCal URL which was copied from the calendar earlier. The result in /etc/openhab2/things/calendar.things
:
|
|
Once the Thing
is loaded, Items
can be deployed. No templating here, the file /etc/openhab2/items/calendar.items
has only a couple lines:
|
|
This defines a Presence switch, which indicates if one event is currently going on. And then the title, start time and end time of the current and next upcoming event. In my case I’m only interested in the presence switch, but I defined the other items anyway.