GCAL bindings - refreshed version

Does it download events from google calendar immediately or is there some pooling time?
It looks like that if there are events in the calendar already when openhab starts then it downloads events correctly. However if I add something additional after openhab is online then nothing happens.

I pulled the PR build to test this out. It worked; however, I saw something in the log that I havenā€™t seen before. The very last line where it says the Event-Downloader has been shut down. Not sure why thatā€™s occurring.

2016-12-03 09:10:45.672 [DEBUG] [io.gcal.internal.GCalEventDownloader] - found 1 calendar events to process
2016-12-03 09:10:45.673 [DEBUG] [io.gcal.internal.GCalEventDownloader] - created new startJob 'null' with details 'SchedulerJob [jobKey=o5qeihsh85ptpm5tfql808i0kc@google.com_start, jobGroup=gcal, 1 triggers=[Sat Dec 03 09:12:00 EST 2016], content=start {
    send PS15Z_Switch ON
}
end {
    send PS15Z_Switch OFF
}
'
2016-12-03 09:10:45.673 [DEBUG] [io.gcal.internal.GCalEventDownloader] - created new endJob 'null' with details 'SchedulerJob [jobKey=o5qeihsh85ptpm5tfql808i0kc@google.com_end, jobGroup=gcal, 1 triggers=[Sat Dec 03 09:17:00 EST 2016], content=start {
    send PS15Z_Switch ON
}
end {
    send PS15Z_Switch OFF
}
'
2016-12-03 09:12:00.002 [DEBUG] [gcal.internal.util.ExecuteCommandJob] - Command [send, PS15Z_Switch, ON, ] has been sent
2016-12-03 09:12:00.088 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been shut down

I believe the event downloader runs every 15 minutes.

I have the GCAL binding installed at a clientā€™s site, it operates their gate. Will the old binding continue to work in the same way, or will I need to use OAUTH some time in the future? Itā€™s installed on OH1.8.3

Hmm I wonder why isnā€™t it configurable?

Now that GCal works in OH2, does it need to be added as a feature so that it shows up in PaperUI?

I will work on a PR, unless you would prefer!

Ok. I just did the PR, if you could check when you get a minute.

1 Like

I will review your PR. Thanks!

Actually, it does appear to be configurable, although I havenā€™t tried it (yet). This parameter in the cfg fileā€¦

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

Iā€™m implenting the gcal connection with OH2.
At first sight, it runs (I was just missing a bit a step to create a seperate google calendar in the wiki).

When I check my logs, everything runs, but the commands arenā€™t executed. :blush:

The logs are saying that it will be run, but nothing happens.

2017-01-13 11:32:39.699 [DEBUG] [io.gcal.internal.GCalEventDownloader] - found 1 calendar events to process
2017-01-13 11:32:39.700 [INFO ] [io.gcal.internal.GCalEventDownloader] - created new startJob 'Light_BU_Parking' with details 'SchedulerJob [jobKey=xxxxxxxxxxxxxxxxx@google.com_start, jobGroup=gcal, 1 triggers=[Fri Jan 13 11:35:00 CET 2017], content=start {
2017-01-13 11:32:39.701 [INFO ] [io.gcal.internal.GCalEventDownloader] - created new endJob 'Light_BU_Parking' with details 'SchedulerJob [jobKey=xxxxxxxxxxxxxxxxx@google.com_end, jobGroup=gcal, 1 triggers=[Fri Jan 13 11:40:00 CET 2017], content=start {
2017-01-13 11:35:00.002 [TRACE] [gcal.internal.util.ExecuteCommandJob] - going to parse command 'send Light_BU_Parking ON'
2017-01-13 11:35:00.002 [TRACE] [gcal.internal.util.ExecuteCommandJob] - read value send from the given command
2017-01-13 11:35:00.002 [TRACE] [gcal.internal.util.ExecuteCommandJob] - read value Light_BU_Parking from the given command
2017-01-13 11:35:00.003 [TRACE] [gcal.internal.util.ExecuteCommandJob] - read value ON from the given command
2017-01-13 11:35:00.003 [TRACE] [gcal.internal.util.ExecuteCommandJob] - read value  from the given command
2017-01-13 11:35:00.004 [DEBUG] [gcal.internal.util.ExecuteCommandJob] - About to execute CommandJob with arguments [send, Light_BU_Parking, ON, ]

It might be that there is one or more spaces after the word ON in the calendar event description, and this is confusing the code. Please check. If thatā€™s it, I will submit a PR to trim whitespace.

Correction: I think itā€™s similar but not exactly as described. I will do some testing and report back.

OK, what I find odd is that your log has

2017-01-13 11:35:00.004 [DEBUG] [gcal.internal.util.ExecuteCommandJob] - About to execute CommandJob with arguments [send, Light_BU_Parking, ON, ]

But I canā€™t find where in the code this log message is being generated. Can you tell me which build you are using, and also the output of

openhab> bundle:list | grep gcal

The return is ā€˜emptyā€™. Iā€™ve got a return with ā€˜alendarā€™:

202 | Active   |  80 | 1.9.0.201611071438    | openHAB Google Calendar

It looks like you are running a build thatā€™s too old to work. The Google Calendar Scheduler was made compatible with OH2 with a pull request on 29th November 2016.

1 Like

Right!
When I download this version, it works perfectly!

I never understood the architecture about ā€˜latest versionsā€™, github, cloudbeeā€¦Guess it would be a nice feature for the openhab site to have a ā€˜latestā€™ version category.

Thanks!

Next step, move my own ā€˜cronrulesā€™ into the google calendar.
And explain others how easy they can turn things on/off with the calendar. :wink:

1 Like

@watou does the GCal binding (on OH2) allow us to write future-dated events to the Google calendar, without using the presence simulation? In other words, letā€™s say I wanted to schedule an event for a specific time/date in my calendar - can I do that through an openHAB rule instead of manually through my Google Calendar?

No, but itā€™s a nice idea!

The only programmatic way to do so presently is with the Google Calendar Presence Simulator, which is in reality a persistence service that writes incoming state changes at some fixed interval into the future (default two weeks) as commands. It might make sense to make an action service that uses the same infrastructure as the Google Calendar Presence Simulator to write future events, but this should be thought through first, because the next thought would likely be to remove/cancel or modify future events from rules as well. All of that is starting to sound fairly involved! :smile:

Yes, the amending/deleting will need to be carefully thought through, but if such an Action is do-able, I think it would fill an important gap in openHAB, in that we can then have a proper calendar support.

For OH2, do we have a clear set of instructions for how to set this binding up?

If not, could I get someone to work with me and Iā€™ll generate the documentation as I go?