Has anyone tried using the Google Calendar API?

Question is in the title :slightly_smiling_face: Link is below...

Simon

There's a project that uses this that I use over on ST.

Would love if someone could port to ST.

1 Like

That looks interesting... I haven't ported code from ST before, is there anything in particular I would need to do? Or is it a case of trial and error?

There are many things that you would have to do to convert it. But if you're not familiar with Groovy, then I wouldn't start trying with something as complicated as this.

It looks like someone ported either this or a very similar app...

It is about 3/4 way down the page, author cometfish.

1 Like

I've written half a dozen or so drivers, some more complicated than others, but the GCal search would be a step up again. I might be better starting from scratch, taking small steps and using this as a reference.

It appears that the version linked to doesn't work based on the last comments on that thread.

Thanks @neonturbo, I'll take a look. Though @Ryan780 is right that some have had trouble getting it to work.

I got the HE version working on my hub many months ago shortly after it was ported. But I will admit I have modified the code quite a bit since then for my own use case. The ST and HE ported version have both presence and switches and I wanted things simple with just a switch to turn on/off based on a calendar entry. I also wanted the ability to query for several strings versus just one per switch. I found the search query via Google API didn’t work all the time and a wrong calendar entry may cause a switch to toggle so I moved all that processing to my hub.

My version does a single query of today’s calendar events, parses the results into a state variable and caches them for a set number of minutes because I have 5 child apps looking for various calendar entries where I thought 5 queries was silly.

The way I use this app is by creating all day calendar entries for school/work holidays, vacations, guests arriving, etc. I query the calendar once a day early morning to set the value of the virtual switches, some turn on and other turn off based on a preference in the switch. Then various rules check value of these virtual switches to perform or not perform actions.

My version may not work for everyone and the ST or ported HE version may be better but happy to share if anyone is interested.

1 Like

Thanks @ritchierich. I would be interested to see the code and try it out. I may still end up trying to write something myself, but it does look a little daunting, so having a reference that works is always helpful. Others may also find it useful.

Simon

I am interested in this. I really only want to turn on certain light switches, or run certain rules depending upon calendar events.

I would be willing to give it a try and see if it does what I would like it to...

Following back up on this post... Here is my version:

1 Like

I looked into writing an app to talk to the calendar API but in the end I was able to do what I needed using multiple calendars and IFTTT. I wasn't jazzed about another IFTTT requirement but it was so much quicker than figuring out authentication/OAuth/etc. that I just rolled with it.

2 Likes

If I'm understanding the recent posts in that thread, google may have changed something on their end that prevents new connections to the API if you have a free google account (i.e. not a G Suite account).

If it's already connected to google, the app still works fine in Hubitat.

Bummer.

1 Like

No, that is not the case. I am using the SmartThings App just fine. And I do not have a GSuite account.

Yes that's what I'm saying. Mine is working fine too. You connected to the calendar API sometime ago right? If I'm understanding the recent posts correctly, it's the initial connection to google that no longer works like it used to.

1 Like

Maybe 5 months ago. I had trouble making the connection as well. The issue is that when doing it for ST, in the Google Console you have to set a URL that is unique to ST. I don't know what the equivalent URL would be for Hubitat or if one is available.

I just checked...it's the Oauth Callback URL.

I'm certainly no expert in this area and the article below may not be entirely related to the recent discussion in this thread, but I thought I'd mention it in case it was or was useful for anyone here...

Simon

1 Like

The Google Calendar API is not a G Suite function. I don't have G Suite but I can access the Calendar API.