GCAL bindings - refreshed version

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?

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.