GCAL Binding stopped working (org.openhab.io.gcal-1.9.0-SNAPSHOT.jar with OH 1.8.3)

Hi Juerg,

I believe the underlying issue is that the Google Calendar Scheduler was written with the assumption that the only entries in the calendar referenced by the gcal:calendar_name configuration parameter are those that should be interpreted by openHAB. The interpretation of calendar entries that have an empty description is to exclude time ranges given. But since your event named Neujahrstag is an all-day event, it has no explicit start or end date/time, which the Google Calendar Scheduler expects to have been specified.

I recommend that you create a new calendar explicitly for events to be interpreted by openHAB, with no holidays or other events on it that do not comply with the wiki, and change your gcal:calendar_name to refer to that calendar.

I have updated and renamed the wiki page to better reflect this assumption by the Google Calendar Scheduler.

Hi John,
thanks a lot for your findings. it seems like your last finding is correct and it does the trick if i use an empty calendar for openhab only. Since then i had no further issue. I’ll keep an eye on it. thanks again for your help. appreciate it.

Hi
I think I’m getting same issue. I was running gcal binding for at least couple of weeks without any problems until today.
Today in the night it thrown exception and since then does the same:

2017-02-17 23:41:19.937 [ERROR] [.service.AbstractActiveService] - Error while executing background thread Google Calender Event-Downloader
java.lang.NullPointerException: null
	at org.openhab.io.gcal.internal.GCalEventDownloader.processEntries(GCalEventDownloader.java:276) ~[na:na]
	at org.openhab.io.gcal.internal.GCalEventDownloader.execute(GCalEventDownloader.java:140) ~[na:na]
	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]

Why it started to appear? I have separate home automation calender, where there is only one event:

start {
 send Temperature_Setpoint_Day 20.5
}
end {
 send Temperature_Setpoint_Day 19
}

Could the problem be in the event Name - I have it in Cyrillic letters?

If we’re talking about the same state of the source code (which I think we are), this line describes an old feature that probably isn’t well documented, where a calendar entry with no content must have start and end dates, and is used to “black out” a time range so calendar actions are suppressed during that time.

        // find all events with empty content - these events are taken to modify
        // the scheduler
        for (Event event : entries) {
            String eventContent = event.getDescription();
            String eventTitle = event.getSummary();

            if (StringUtils.isBlank(eventContent)) {
                logger.debug(
                        "found event '{}' with no content, add this event to the excluded TimeRangesCalendar - this event could be referenced by the modifiedBy clause",
                        eventTitle);

                if (!calendarCache.containsKey(eventTitle)) {
                    calendarCache.put(eventTitle, new TimeRangeCalendar());
                }
                TimeRangeCalendar timeRangeCalendar = calendarCache.get(eventTitle);
/* line 276 */  timeRangeCalendar.addTimeRange(new LongRange(event.getStart().getDateTime().getValue(),
                        event.getEnd().getDateTime().getValue()));

            }
        }

So this code can only be entered if there was no content in the description field of the calendar entry. Any chance there was some entry in the calendar with no content? The code then assumes a few things (and the problem is the defenseless assumptions that are leading to an NPE). This, with logs, deserves a new issue to be opened preferably with DEBUG logs.