[Solved] - Google Calendar Scheduler - no response or error logs

Hi,

Is anyone successfully using this with 2.2.0-1? I have tried to set it up following the wiki but do not get any log messages or changes to my item states? The only response I see in the log viewer is:

[INFO ] [b.core.service.AbstractActiveService] - Google Calendar Event Downloader has been started

and sometimes a shutdown message, but nothing more.
I can see regular traffic to the calendar API on the Google Dashboard, all with 200 response codes.

Do I need to change any of the settings for my Calendar to allow O2auth to access it correctly?

Thanks,
Jon

The binding doesn’t log much unless there are errors. You could try putting the binding into debug mode to better see what it’s doing.

From the Karaf console:

log:set DEBUG org.openhab.io.gcal

Thanks Mark,

That has gone some way to highlighting the issue (didn’t realise you could enable extra logging in this way). I am now getting:

[DEBUG] [io.gcal.internal.GCalEventDownloader] - gcal feed contains no events …

But I can see my events in the calendar, and I am following the description format from the Wiki?

Does the event need to start and finish within the interval time? Will the event be detected even if the description is incorrect (I am wondering whether it’s to do with the formatting of the description)?

Thanks again,
Jon

Try putting an event in your calendar that’s close to the current time (within 10 minutes or so) and watch the log file to see if it downloads.

If the description is badly formatted, it still will download the event, then throw an error when it tries to execute it at the scheduled time. Make sure you turn off all formatting of the description. If any of it is formatted, the downloaded description will include HTML tags and the command will fail to execute.

BTW, I didn’t mention above but you turn off debug mode by entering

log:set INFO org.openhab.io.gcal

One thing I noticed in my gcal.cfg… I changed my refresh interval to 5 minutes (default is 15 minutes). I vaguely recall that it might only download events that are scheduled to occur during the refresh interval. But I’m not at all certain of that. I’ll go look at the code to see what it does.

# Refresh interval in milliseconds (optional, defaults to 900000 [15 minutes])
refresh=300000

Ahh… Here you go. I was close. It’s 2x the refresh interval.

     * @return the corresponding Events or <code>null</code> if an error
     *         occurs. <i>Note:</i> We do only return events if their startTime lies between
     *         <code>now</code> and <code>now + 2 * refreshInterval</code> to reduce
     *         the amount of events to process.

Awesome. I have had it running at 5 minute intervals too, and the default, so I might just have missed all of the start times somehow. I’ll set it for several hours and see if it catches anything.

Thanks,
Jon

Happy Christmas all,

Unfortunately still no joy. Keep getting no events found. Even tried using primary calendar.

Looking at the code I can see downloadEventFeed() function being called before the no events error fires, but in the function downloadEventFeed()

private static Events downloadEventFeed() {
        // TODO: teichsta: there could be more than one calendar url in openHAB.cfg
        // for now we accept this limitation of downloading just one feed ...

        if (StringUtils.isBlank(calendar_name)) {
            logger.warn("Login aborted no calendar name defined");
            return null;
        }
        // authorization

        CalendarListEntry calendarID = GCalGoogleOAuth.getCalendarId(calendar_name);

        if (calendarID == null) {
            return null;
        }

        DateTime start = new DateTime(new Date(), TimeZone.getTimeZone(calendarID.getTimeZone()));
        DateTime end = new DateTime(new Date(start.getValue() + (2 * refreshInterval)),
                TimeZone.getTimeZone(calendarID.getTimeZone()));
        logger.debug("Downloading calendar feed for time interval: {} to  {} ", start, end);

        Events feed = null;
        try {
            Credential credential = GCalGoogleOAuth.getCredential(false);

            // set up global Calendar instance
            Calendar client = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                    .setApplicationName("openHAB").build();
            Calendar.Events.List l = client.events().list(calendarID.getId()).setSingleEvents(true).setTimeMin(start)
                    .setTimeMax(end);

            // add the fulltext filter if it has been configured
            if (StringUtils.isNotBlank(filter)) {
                l = l.setQ(filter);
            }
            feed = l.execute();
        } catch (IOException e1) {
            logger.error("Event fetch failed: {}", e1.getMessage());
        }

        try {

            if (feed != null) {
                checkIfFullCalendarFeed(feed.getItems());
            }

            return feed;
        } catch (Exception e) {
            logger.error("downloading CalendarEventFeed throws exception: {}", e.getMessage());
        }

        return null;
    }

there are several debug calls that do not appear in my openhab.log file. This one in particular I think should appear.

logger.debug("Downloading calendar feed for time interval: {} to  {} ", start, end);

Which makes me wonder if it is a problem with how the time or date is being called on my pi?

Thanks,
Jon

Unless there’s an issue with this call…

CalendarListEntry calendarID = GCalGoogleOAuth.getCalendarId(calendar_name);
if (calendarID == null) {
    return null;
}

Which could be due to the credentials not being set up correctly as described here

Pretty sure that side is set up correctly. I get the correct calendar ID listed under debug log, which I don’t think I would get without O2auth going through. Also I can see the requests under developer API console getting successs (200) responses.

I haven’t done anything with the persistence part of the wiki. I didn’t think it was required for triggering items?

Thanks,
Jon

Correct. That’s not required.

Sometimes with the OH1 bindings, I find it necessary to restart OH in order to resolve some issues, as a stop/start of the binding doesn’t always do the trick. Not sure if you tried stopping/starting the gcal binding (from the Karaf console), or if you tried restarting OH.

Unfortunately tried both :frowning:

Haven’t tried removing completely and starting again, but if it’s nothing else obvious I might have to try that next.

Jon

Solved it.

Turns out that it would only work if a filter was added to gcal.cfg.

Thanks for all the help.
Jon