Google calendar scheduler with Presence simulation will not be set up properly

I have installed the Google Calendar Scheduler and Google Calendar Presence Simulator through PaperUI. The former was either installed a week or so ago, or was installed by default, I don’t remember. The latter was installed recently.

I tried setting everything up according to the Wiki instructions, but it will not work.

I obtained the credentials successfully, made a new calendar called openhab, and put all the credentials and information in gcal.cfg (leaving filter and refresh commented out). I expected the log output with instructions and code, but have grepped and found nothing. So continuing, hoping it would appear after a while, I put the calendar name in gcal-persistence.cfg. I created a gcal.persist file in persistence/ with the following content:

Strategies {
    default = everyChange
}

Items {
    gPresenceSimulation* : strategy = everyChange
}

I added an item in an item file: Switch PresenceSimulation "Simulate presence" <man_3>

I created the group gPresenceSimulation and added an item to that group.

The expected message in the log still has not appeared, and nothing is being logged to my calendar.

I tried uninstalling Google Calendar Scheduler with PaperUI, hoping that I could install again and everything would work, but when I try to uninstall it, the spinning icon never stops spinning. The log outputs nothing, and if I refresh the UI, it’s still installed.

Right now I’m out of ideas. Does anyone have any suggestions on how to proceed?

This is probably because of the dependency gcal persistence has on gcal. I suspect that as long as gcal persistence is installed, you won’t be able to uninstall gcal. I’d suggest you uninstall gcal persistence until you get gcal working. The fewer moving parts, the better.

As for gcal, I would suggest you try stopping/starting gcal while tailing the openhab.log file. That way you’ll be able to see what gcal logs at startup. You also could try putting gcal into debug mode to see if it provides any clues.

The relevant Karaf console commands are:

bundle:stop org.openhab.io.gcal
bundle:start org.openhab.io.gcal

And

log:set DEBUG org.openhab.io.gcal
log:set INFO org.openhab.io.gcal

I uninstalled Google Calendar Presence Simulator, and then opened the console, with this result:

openhab> bundle:stop org.openhab.io.gcal
Error executing command: No matching bundles

I then tried to uninstall Google Calendar Scheduler again, now that the Presence Simulator is uninstalled, but it still just spins forever…

So that probably means it’s uninstalled. You can confirm by running:

list -s | grep gcal

If it’s uninstalled, you’ll see nothing.

If it’s installed you’ll see something like this.

235 │ Active   │  80 │ 1.12.0.201802180209    │ org.openhab.io.gcal

I see nothing, so it’s not installed. Strange that PaperUI claims that it is installed. How do I resolve this strangeness? Perhaps it’s as easy as installing it through the console? I’ll see if I can figure out how to do that.

Ok, I tried to install with the console, and got an error message. But then PaperUI started showing it as not installed. I installed it with PaperUI, and got no log output. I tried stopping and starting and changing logging in console, as shown above, but log still shows nothing.

But now, at least the console says it’s installed too:

openhab> list -s | grep gcal
229 │ Active   │  80 │ 1.11.0                 │ org.openhab.io.gcal

This is a bit confusing. I would expect it to output the instructions and code in the log now. The cfg files are still there, unchanged, with all the information.

With the binding in debug mode, you definitely should be seeing log file entries when you stop and start the binding.

But I don’t though. I even tried to restart the openhab2 service, and then did the following in the console:

openhab> log:set DEBUG org.openhab.io.gcal
openhab> log:set INFO org.openhab.io.gcal
openhab> bundle:stop org.openhab.io.gcal
openhab> bundle:start org.openhab.io.gcal

And this produces no new entries in openhab.log (nor events.log for that matter).

When i type this in the console it shows an error.

bundle:start org.openhab.io.gcal
Error executing command: No matching bundles

So lets dig in how the bundle is actually called.

openhab> feature:list |grep gcal
openhab-persistence-gcal                    │ 1.12.0.SNAPSHOT  │          │ Uninstalled │ openhab-addons-2.3.0-SNAPSHOT │ Google Calendar Presence Simulator
openhab-misc-gcal1                          │ 1.12.0.SNAPSHOT  │          │ Uninstalled │ openhab-addons-2.3.0-SNAPSHOT │ Google Calendar Scheduler

Try to install the persistence, i just installed both as i don’t know if they belong together.

openhab> feature:install openhab-persistence-gcal
openhab> feature:install openhab-misc-gcal1

When a grep i only get an error

openhab> log:display |grep gcal
grep: java.lang.ArrayIndexOutOfBoundsException: 119

But when I display the whole log i find plenty of gcal related loggings, but not the instructions.
I think this is because openhab restarted teh bundles after isntalling and so the logg was lost
Trying grep again after a while shows a little more.

openhab> log:display |grep gcal
[INFO ] [.internal.service.FeaturesServiceImpl] -     org.openhab.io.gcal/1.12.0.201802180209 (Bundle will be uninstalled)
[INFO ] [.internal.service.FeaturesServiceImpl] -     org.openhab.persistence.gcal/1.12.0.201802180209 (Bundle will be uninstalled)
[INFO ] [.internal.service.FeaturesServiceImpl] - Adding features: openhab-misc-gcal1/[1.12.0.SNAPSHOT,1.12.0.SNAPSHOT]
[INFO ] [.internal.service.FeaturesServiceImpl] -       mvn:org.openhab.io/org.openhab.io.gcal/1.12.0-SNAPSHOT
[INFO ] [.internal.service.FeaturesServiceImpl] -   mvn:org.openhab.io/org.openhab.io.gcal/1.12.0-SNAPSHOT
[INFO ] [.internal.service.FeaturesServiceImpl] -   org.openhab.io.gcal/1.12.0.201802180209
grep: java.lang.ArrayIndexOutOfBoundsException: 119

I don’t. No errors after I removed and reinstalled. Your error is likely because you don’t have it installed (before installing it after you got that message). And then there’s this:

openhab> feature:list | grep gcal
openhab-persistence-gcal                    │ 1.11.0           │          │ Uninstalled │ openhab-addons-2.2.0    │ Google Calendar Presence Simulator
openhab-misc-gcal1                          │ 1.11.0           │ x        │ Started     │ openhab-addons-2.2.0    │ Google Calendar Scheduler

So gcal is clearly installed. But it behaves weird. No log output when stopping and starting, and not the expected log output with the code as described in the Wiki.

persistence-gcal depends on gcal. But gcal alone should produce a log message with instructions and a code to use to grant openhab permissions to read and write my calendar. But it doesn’t.

As i sad i also didnt find the Massage.

I don’t what else to suggest. :confused:

When you do this

openhab> log:set DEBUG org.openhab.io.gcal
openhab> bundle:stop org.openhab.io.gcal
openhab> bundle:start org.openhab.io.gcal                                                             

At a minimum, you should be seeing this when you tail -f /opt/openhab2/userdata/logs/openhab.log (or wherever your openhab.log file is in your installation).

2018-02-25 07:11:21.017 [DEBUG] [org.openhab.io.gcal                 ] - BundleEvent STOPPING - org.openhab.io.gcal
2018-02-25 07:11:21.018 [DEBUG] [org.openhab.io.gcal                 ] - ServiceEvent UNREGISTERING - {org.osgi.service.cm.ManagedService}={service.pid=org.openhab.gcal, component.name=org.openhab.binding.gcal.eventdownloader, component.id=182, service.id=318, service.bundleid=219, service.scope=bundle} - org.openhab.io.gcal
2018-02-25 07:11:21.019 [DEBUG] [enhab.io.gcal.internal.GCalActivator] - Google Calendar IO has been stopped.
2018-02-25 07:11:21.019 [DEBUG] [org.openhab.io.gcal                 ] - BundleEvent STOPPED - org.openhab.io.gcal
2018-02-25 07:11:27.897 [DEBUG] [org.openhab.io.gcal                 ] - BundleEvent STARTING - org.openhab.io.gcal
2018-02-25 07:11:27.898 [DEBUG] [enhab.io.gcal.internal.GCalActivator] - Google Calendar IO has been started.
2018-02-25 07:11:27.898 [DEBUG] [org.openhab.io.gcal                 ] - BundleEvent STARTED - org.openhab.io.gcal
2018-02-25 07:11:27.900 [DEBUG] [org.openhab.io.gcal                 ] - ServiceEvent REGISTERED - {org.osgi.service.cm.ManagedService}={service.pid=org.openhab.gcal, component.name=org.openhab.binding.gcal.eventdownloader, component.id=346, service.id=736, service.bundleid=219, service.scope=bundle} - org.openhab.io.gcal

I understand. But it’s not happening… I get no error messages in the console, but there are no new entries produced in the log either. It’s like the binding is completely dead. :frowning: I used the openhabianpi image, so I can’t really imagine having done something terribly wrong during installation.

Can you assit. Still getting the below error.

2019-04-15 14:48:42.472 [DEBUG] [openhab.io.gcal.auth.GCalGoogleOAuth] - device refresh_token: 1/b0dsEBfnM2RpR6vKVELqWX8YcisPs2KELGG8A_XXXX
2019-04-15 14:48:42.472 [DEBUG] [openhab.io.gcal.auth.GCalGoogleOAuth] - device expires_in: 1555283378768
2019-04-15 14:48:42.472 [INFO ] [b.core.service.AbstractActiveService] - Google Calendar Event Downloader has been started
2019-04-15 14:48:42.472 [WARN ] [ient.util.store.FileDataStoreFactory] - unable to change permissions for everybody: C:\openHAB2\userdata\gcal
2019-04-15 14:48:42.472 [WARN ] [ient.util.store.FileDataStoreFactory] - unable to change permissions for owner: C:\openHAB2\userdata\gcal
2019-04-15 14:48:42.472 [DEBUG] [openhab.io.gcal.auth.GCalGoogleOAuth] - Loaded credential
2019-04-15 14:48:42.472 [DEBUG] [openhab.io.gcal.auth.GCalGoogleOAuth] - device access token: ya29.GlvsBiCY93974UH2cus0jBR5bwdc9kLwXmQBrmy91gM4Dk3EgfgQyrIVjv9pUL1_ZnNxcuZnm4L_P1lvPbTj1bHobRzHSOvQ1raa9qvdRtbLcyGLv6EV2IIVXXX
2019-04-15 14:48:42.472 [DEBUG] [openhab.io.gcal.auth.GCalGoogleOAuth] - device refresh_token: 1/b0dsEBfnM2RpR6vKVELqWX8YcisPs2KELGG8A_XXX
2019-04-15 14:48:42.472 [DEBUG] [openhab.io.gcal.auth.GCalGoogleOAuth] - device expires_in: 1555283378768
2019-04-15 14:48:42.581 [ERROR] [openhab.io.gcal.auth.GCalGoogleOAuth] - authentication failed: 401 Unauthorized

2019-04-15 15:06:26.388 [DEBUG] [openhab.io.gcal.auth.GCalGoogleOAuth] - device refresh_token: 1/b0dsEBfnM2RpR6vKVELqWX8YcisPs2KELGG8A_XXXX
2019-04-15 15:06:26.388 [DEBUG] [openhab.io.gcal.auth.GCalGoogleOAuth] - device expires_in: 15552833787XX
2019-04-15 15:06:26.481 [ERROR] [openhab.io.gcal.auth.GCalGoogleOAuth] - authentication failed: 401 Unauthorized
2019-04-15 15:06:26.481 [ERROR] [gcal.internal.GCalPersistenceService] - creating a new calendar entry throws an exception: null

I’ve made Progress!!!

I can see the re request comming in but nothing in my calendar yet.

calendar.calendarList.list 1 0
calendar.events.insert 21 0
calendar.events.list 39