GCAL bindings - refreshed version

The doc is at

Feel free to improve it! Thanks.

Hello!

Since I couldnā€™t find it in the documentation, I suppose GCal binding does not support showing upcoming/active events in the OpenHAB. Or, am I missing something?

Best regards,
Davor

Itā€™s not actually a binding, itā€™s a service.that reads upcoming events from the Google calendar, and sets up internal jobs to update state or send commands at the times on the calendar. You can view the calendar as usual in Google to see whatā€™s ahead. There is no openHAB UI, since itā€™s all about Google calendar. :grinning:

Hello!

I supposed thatā€™s the case, but just wanted to be sure. I would use CalDAV binding, but I canā€™t make it connect to my Google Calendar (Iā€™ve posted about that in another topic). Thank you for the information.

Best regards,
Davor

Whatā€™s the status of the ā€œbindingā€ or ā€œioā€ or whatever itā€™s called? :wink:
Didnā€™t find it on cloudberry-jenkins anymore. Is the JAR in the first post the newest? somewhere in the middle it was stated, the newest is on Jenkins? :wink:

Thanks!

PS: If I read the Wiki (https://github.com/openhab/openhab1-addons/wiki/Google-Calendar-Scheduler) I see the need for specific code in the eventā€™s description. Is it possible to trigger actions on just names of the events? Itā€™s much more easy to just write ā€œHolidayā€ in the events name than

start {
  send Holiday_State ON
}
end {
  send Holiday_State OFF
} 

I mean, is it possible to access all metadate of a calendar event?

Ok - I just gave it a try, hereā€™s my story! :wink:

at first, I found it on the Jenkins and used this one:

console
I tried to install it via the console

bundle:install https://openhab.ci.cloudbees.com/job/openHAB1-Addons/lastSuccessfulBuild/artifact/bundles/io/org.openhab.io.gcal/target/org.openhab.io.gcal-1.10.0-SNAPSHOT.jar

it worked at first but with bundle:start I got

bundle:start 209
Error executing command: Error executing command on bundles:
        Error starting bundle 209: Invalid operation on a fragment.

so I uninstalled it again.

copy in addon
so, I copied it in the addons-folder

[20:56:53] pi@openHABian2:/usr/share/openhab2/addons$ sudo wget https://openhab.ci.cloudbees.com/job/openHAB1-Addons/lastSuccessfulBuild/artifact/bundles/io/org.openhab.io.gcal/target/org.openhab.io.gcal-1.10.0-SNAPSHOT.jar

Then I added in the gcal.cfg (got the Client_id and Client_secret from the Credentials-section of the API-Manager at https://console.developers.google.com/apis/credentials

client_id=xxx-yyy.apps.googleusercontent.com
client_secret=zzz
calendar_name=Familienkalender

after restarting OH2 Service I get These:
210 | Active | 80 | 1.10.0.201702240212 | openHAB Google Calendar

2017-02-24 20:57:21.740 [WARN ] [openhab.io.gcal.auth.GCalGoogleOAuth] - getCredential got exception: 401 Unauthorized
2017-02-24 20:57:21.742 [ERROR] [io.gcal.internal.GCalEventDownloader] - Cannnot obtain credential based on provided client_id/client_secret
2017-02-24 20:57:21.745 [ERROR] [org.apache.felix.configadmin        ] - [org.osgi.service.cm.ManagedService, id=341, bundle=210/file:/usr/share/openhab2/addons/org.openhab.io.gcal-1.10.0-SNAPSHOT.jar]: Updating property Credential error of configuration org.openhab.gcal caused a problem: Cannnot obtain credential based on provided client_id/client_secret
org.osgi.service.cm.ConfigurationException: Credential error : Cannnot obtain credential based on provided client_id/client_secret
	at org.openhab.io.gcal.internal.GCalEventDownloader.updated(GCalEventDownloader.java:557)[210:org.openhab.io.gcal:1.10.0.201702240212]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1461)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1417)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)[3:org.apache.felix.configadmin:1.8.12]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

I didnā€™t get the message @watou got in GCAL bindings - refreshed version

So what type of OAUTH2 did you guys configure for your GCAL? I used ā€œWeb Applicationā€, but there are more Application types, perhaps this one is it?

  • Web application
  • Android
  • Chrome App
  • iOS
  • PlayStation 4
  • Other

Iā€™m pretty sure itā€™s a documentation issue youā€™re experiencing, but Iā€™m not able to diagnose it at the moment.

Please check your steps against the documentation and hopefully something can get sorted out by it.

1 Like

You have to create application type Other. Please follow the Wiki.
Regards

2 Likes

Just to be thorough: Is http://docs.openhab.org/addons/io/gcal/readme.html (originally from the wiki) OK as well? Its source file is openhab1-addons/bundles/io/org.openhab.io.gcal/README.md at main Ā· openhab/openhab1-addons Ā· GitHub.

Thanks, the Wiki must have slipped through, @sirad, for others like me, would be great to edit the original post and add the link to the wiki! :wink:

ok. now Iā€™m through with authentication (I hope), but the calendar seems not to be read out. is there some timeframe, the service looks for events? I just addes some 30mins in the future and the next day.
All I get after restarting OH2-service twice and restarting the GCAL-Service with bundle:restart is this in my openhab.log:

2017-02-25 10:06:43.609 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been started
2017-02-25 10:06:51.473 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been shut down

What I did was now according to the Wiki ():

  1. using new OAuth2 credentials with Application Type ā€œOtherā€ at Google API Manager
  2. getting this in my openhab.log:
017-02-25 09:18:25.689 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - ################################################################################################
2017-02-25 09:18:25.691 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # Google-Integration: U S E R   I N T E R A C T I O N   R E Q U I R E D !!
2017-02-25 09:18:25.692 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # 1. Open URL 'https://www.google.com/device'
2017-02-25 09:18:25.693 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # 2. Type provided code XXXX-YYYY
2017-02-25 09:18:25.694 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # 3. Grant openHAB access to your Google calendar
2017-02-25 09:18:25.695 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # 4. openHAB will automatically detect the permiossions and complete the authentication process
2017-02-25 09:18:25.696 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # NOTE: You will only have 1800 mins before openHAB gives up waiting for the access!!!
2017-02-25 09:18:25.697 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - ################################################################################################
  1. putting the Code in the URL
  2. getting this in the openhab.log:
2017-02-25 09:18:58.482 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been started
2017-02-25 09:18:59.235 [ERROR] [openhab.io.gcal.auth.GCalGoogleOAuth] - authentication I/O exception: 403 Forbidden
{
  "code" : 403,
  "errors" : [ {
    "domain" : "usageLimits",
    "message" : "Access Not Configured. Calendar API has not been used in project 12345 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar/overview?project=12345 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "reason" : "accessNotConfigured",
    "extendedHelp" : "https://console.developers.google.com/apis/api/calendar/overview?project=12345"
  } ],
  "message" : "Access Not Configured. Calendar API has not been used in project 12345 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar/overview?project=12345 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
}
  1. Granting Calendar API Access with the Project-ID (the OAuth-credentials)
  2. nothing happens
  3. restarting GCAL-service in OH2 console bundle:restart gave my this:
2017-02-25 09:20:59.545 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been started
2017-02-25 09:22:37.061 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been started
  1. nothing happened again
  2. restarted OH2 Service (sudo /etc/init.d/openhab2 restart)
  3. resulted in this:
(...)
2017-02-25 09:35:13.176 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2017-02-25 09:35:13.977 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been started
(...)
  1. again nothing happend
  2. bundle:restart the GCAL Service with now this in the openhab.log
2017-02-25 10:06:43.609 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been started
2017-02-25 10:06:51.473 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been shut down

Am I missing something?

Why are you referring continuing to refer to the wiki in the posts following mine? openHAB 2 users should heed the warning in the 1.x wiki as itā€™s not correct information for you.

Iā€™m confused. The Wiki (http://docs.openhab.org/addons/io/gcal/readme.html) is for OH2? I understand, the GCAL Service is 1.10 Version, but my understanding is, that >1.9 versions of bindings are at least tested for use within OH2?
or do you mean something completely different? :wink:

Ah, ā€œthe wikiā€ as I use the term refers to the old 1.x wiki at https://github.com/openhab/openhab1-addons/wiki, which OH2 users should not use for add-on documentation (and refer to with great caution for the other pages there). The ā€œdocs siteā€ or ā€œopenHAB documentationā€ or similar term is what you find at http://docs.openhab.org. So we were using different terminology.

1 Like

all right! :wink: Iā€™ll think about it in future posts! :wink:

I played around a bit more, still the same gcal.cfg, and bundle:restarts bring up this in the log, log:set trace 210 doesnā€™t improve logging in that case:

2017-02-27 15:57:42.292 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been started
2017-02-27 15:57:50.059 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been shut down
2017-02-27 15:58:12.530 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been started
2017-02-27 15:59:12.516 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been shut down
2017-02-27 15:59:45.162 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been started
2017-02-27 16:01:13.031 [INFO ] [b.core.service.AbstractActiveService] - Google Calender Event-Downloader has been shut down

what bothers me, sometimes, the ā€œGoogle Calender Event-Downloaderā€ was shut down right in the instance, then I have 8secons or 90seconds! I donā€™t see a pattern here. Is there something I could do?

btw: @SirAd: could you Change the logging to ā€œGoogle Calendarā€ with an ā€œaā€ instead of an ā€œeā€, so it is easier to read and search in the logs, thanks!

I just added a pull request:

1 Like

Iā€™m new to Openhab and trying to get this set up. Iā€™m following the instructions and have managed to create my google credentials but cannot find the gcal.cfg file to put them in, nor do the instructions indicate where it should be created. I also looked for an openhab.cfg file mentioned at the very start of this thread.

Iā€™m running using an Openhabian installation on a Pine64. So far everything has been fairly smooth but Iā€™ve made the modifications through the UI. Unfortunately the google searches Iā€™ve done turn up only OH1 information that isnā€™t very helpful.

Assistance greatly appreciated!

hi Simon,

I assume, youā€™re running openHAB2, so please use the documentation on docs.openhab.org: http://docs.openhab.org/addons/io/gcal/readme.html
Second, some bindings automatically create configuration files, in this case, GCAL isnā€™t a ā€œbindingā€ so to speak, and still the present Installation (copyin JAR-files) doesnā€™t create files. So in that case - and in most bindings also - you must create the config files yourself. Just place them in the config-directory (usually on Linux this is /etc/openhab2/services).
There you find at least the ā€œaddons.cfgā€. In there you just create a new file gcal.cfg and paste your credentials and the other configurational stuff in.

After leaving OH2 to its own, since tonight at midnight, I get periodically (refresh-option in gcal.cfg) these errors:

2017-02-28 10:51:44.844 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread Google Calender Event-Downloader
java.lang.NullPointerException
	at org.openhab.io.gcal.internal.GCalEventDownloader.processEntries(GCalEventDownloader.java:276)[210:org.openhab.io.gcal:1.10.0.201702240212]
	at org.openhab.io.gcal.internal.GCalEventDownloader.execute(GCalEventDownloader.java:140)[210:org.openhab.io.gcal:1.10.0.201702240212]
	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173)[200:org.openhab.core.compat1x:2.1.0.201702202246]

So I guess, you just have to wait a little! :wink:

As Iā€™m about to leave for skiing today, I wonā€™t pursue this until next week, but I assume, I have to play around a bit with the calendar entries, I guess.

The documentation references the services folder. If you are using openHAB 2, refer to docs.openhab.org as the primary source of accurate information. Installation and configuration has changed in openHAB 2, as well as the addition of new features. The old 1.x wiki still has lots of useful information, but most of it is oriented towards users of the openHAB 1.x runtime.

Thanks for your suggestions @watou, @binderth.

Apologies for not mentioning the version, I am using OpenHab 2. Indeed, I was referring to the OH2 documentation and saw that it references a services folder, but my openhabian installation does not have any services folder. In my openhab root (this appears to be at /var/lib/openhab2) a search (find . -name services) turns up nothing.

There is a config directory and an etc directory. Based on the input from @binderth Iā€™m going to try creating /var/lib/openhab2/etc/services and dropping the gcal.cfg file into there.

Will let you know how I get on! (Took delivery of a handful of z-wave devices today, so have a strong motivation to do something with them)