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.
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.
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.
The configuration needs a
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:
credentials/reminders-calendar-ical.txt holds the iCal URL which was copied from the calendar earlier. The result in
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.