GoogleCalendar2Timer Plugin

Questions and comments specific to a particular plugin should go here.
Surio89
Posts: 10
Joined: Sat May 14, 2011 8:57 am

GoogleCalendar2Timer Plugin

Post by Surio89 » Wed Feb 04, 2015 11:16 am

Hi there,

i developed a Google API V3 based Google Calendar Plugin. All events are mapped to the EG Timer Plugin that you have to add to your project first.

LAST UPDATE - 0.2.2 OCT 26 2015:
  • UTC Detection Bugfix again



Download:
GoogleCalendar2Timer.zip
(5.53 KiB) Downloaded 97 times



Good to know/ known bugs / todos:
Only events from now until end of day are mapped to timer.
You have to reread the calendar manualy e.g. with a Timer loop of 5 Minutes. (remember the 1.000.000 requests/day limit of google calendar api :wink: )

Short description (If you have OAuth 2.0 and Google Developer Console experience):
  • Add project to Google Developer Console https://console.developers.google.com/project and activate Google Calendar API.
  • Add Client-ID type "Installed application"
  • Download Json and put into plugins folder or where you like
  • Add Google Python Client subfolder "apiclient", "oauth2client" and "uritemplate" https://code.google.com/p/google-api-py ... p&can=2&q= to EGs lib26\site-packages\ folder
  • Add Httplib2 subfolder /python2/httplib2 https://github.com/jcgregorio/httplib2 to EGs lib26\site-packages\ folder
  • Add plugin to your project
  • Open Auth URL from EG Log, accept and copy authcode to plugin configuration
  • Add Plugin Action "GetCalendarEvents", add your calendar ID and press OK
  • Run Action -> Plugin adds calendar items as events to the Timer plugin
Detailed description (for everyone else):
  • Open the Google Developer Console:https://console.developers.google.com/project
  • Add Project
    Image
    Image
  • Activate Google Calendar API
    Image
    Image
    Image
  • Add new Client-ID Type "Installed Application"
    Image
    Image
    Image
  • Download JSON to Plugin Folder
    Image
  • Download Google Api Python Client https://code.google.com/p/google-api-py ... p&can=2&q=
  • Extract the Zips Subfolder "apiclient", "oauth2client" and "uritemplate" in C:\Program Files (x86)\EventGhost\lib26\site-packages\
  • Download Httplib2 Git Project https://github.com/jcgregorio/httplib2 as ZIP and extract Subfolder /python2/httplib2 to C:\Program Files (x86)\EventGhost\lib26\site-packages\
  • Add Plugin to your Tree
    Image
  • Client Secret File (JSON): Full Path to the File including Filename and Extension e.g. C:\Program Files (x86)\EventGhost\plugins\GoogleCalendar2Timer\client_secret_7223455323-pq10su02345234523455d5ruaj1nehi.apps.googleusercontent.com.json
  • Developer Key: Go to your added Project in Google Developer Console https://console.developers.google.com/project/ and copy key
    Image
  • Press OK
  • Open Auth URL (Copy from EG Log) with Browser and Accept
    Image
    Image
    Image
  • Copy Authcode to Configuration
  • Add Action "GetCalendarEvents" and add your Calendar ID from https://www.google.com/calendar/render#h
    Image
  • Run Action
  • Open Timer Plugin to see results
    Image
Last edited by Surio89 on Mon Oct 26, 2015 9:32 am, edited 7 times in total.

Medienuser
Posts: 7
Joined: Mon Jun 02, 2014 1:00 am

Re: GoogleCalendar2Timer Plugin

Post by Medienuser » Fri Feb 13, 2015 4:27 pm

Hi Surio89!

I´d like to use your great plugin in and I made all steps as you descripe them. The Plugin starts working but if I send the "GetCalenderEvents Action" I get this error messages:

17:23:04 Fehler in Befehl: "GoogleCalendar2Timer: GetCalendarEvents: (...blanked out)@group.calendar.google.com"
17:23:04 Traceback (most recent call last) (1694):
17:23:04 File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
17:23:04 return self(*args)
17:23:04 File "C:\Program Files (x86)\EventGhost\plugins\GoogleCalendar2Timer\__init__.py", line 97, in __call__
17:23:04 events = self.plugin.calService.events().list(calendarId=calenderid, pageToken=page_token, singleEvents='true', timeMin=minTime, timeMax=maxTime).execute()
17:23:04 File "C:\Program Files (x86)\EventGhost\lib26\site-packages\oauth2client\util.py", line 132, in positional_wrapper
17:23:04 return wrapped(*args, **kwargs)
17:23:04 File "C:\Program Files (x86)\EventGhost\lib26\site-packages\apiclient\http.py", line 723, in execute
17:23:04 raise HttpError(resp, content, uri=self.uri)
17:23:04 HttpError: <HttpError 404 when requesting https://www.googleapis.com/calendar/v3/calendars/(blanked out)@group.calendar.google.com/events?timeMax=2015-02-14T00%3A00%3A00%2B01%3A00&alt=json&singleEvents=true&key=(blanked out)=2015-02-13T17%3A23%3A03%2B01%3A00 returned "Not Found">

May you help me please? I need your Plugin for my heating ;-)
Thanks and Greetings!

Surio89
Posts: 10
Joined: Sat May 14, 2011 8:57 am

Re: GoogleCalendar2Timer Plugin

Post by Surio89 » Fri Feb 13, 2015 5:21 pm

Hi are you sure that the calendar ID is correct? Maybe you copied a space character in front of your ID? Is there a %20 in the blanked out string? I should filter the input to prevent this.

I use the plugin for heating too. Since last update i had no problems and all events fired just in time :). Please report any possible error so nobody will freeze at home because of my fault :D

Medienuser
Posts: 7
Joined: Mon Jun 02, 2014 1:00 am

Re: GoogleCalendar2Timer Plugin

Post by Medienuser » Fri Feb 13, 2015 7:09 pm

Yeah! You are the man!!! Thank you very much! It was the space character. Now it works perfect!
No one has to freeze ;-) Great Plugin!!!

Chonner
Posts: 1
Joined: Sun Feb 17, 2013 8:01 pm

Re: GoogleCalendar2Timer Plugin

Post by Chonner » Thu Mar 05, 2015 12:23 pm

Hey Surio,

Just wanted to say thanks for this Plugin, it really useful and seems to be working really reliably. Also thanks for the very detailed instructions, made installation a breeze!
One question, the Prefix field when configuring the GetCalendarEvent action, is that suppose to be the prefix to the Timer Event i.e. Timer.GC2T_Test123_Start
As all I am getting is Timer.Test123_Start, and it would be nice to differential the 2 calendars I am watching based on the prefix.

Also the GCal Event description as a payload would be the cherry on top, but I guess that is a limitation with Timer and would require using ScheduleGhost instead, so is not easily done.
So I'll make do with a complex syntax of event titles and parsing the needed parameters out of there.

Once again thank you very much for creating this plugin.

Surio89
Posts: 10
Joined: Sat May 14, 2011 8:57 am

Re: GoogleCalendar2Timer Plugin

Post by Surio89 » Thu Apr 02, 2015 9:22 am

The Calendar has a automatic UTC detection now and cares about summer time timeshift.

Since Summer Time switch i missed all END triggers because the plugin deleted the timer action before it was triggered. Bug is now fixed.

Payload is not possible because of Timer Plugin limitations. Im not sure if ScheduleGhost can handle it but i will do some tests.

The Prefix is used to identify the added actions in Timer Plugin. To identify different calendars you can modify the "Start", "End" and "Intermediate" Suffix. But im working on a better solution. Thanks for your feedback.

skribb
Experienced User
Posts: 157
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: GoogleCalendar2Timer Plugin

Post by skribb » Wed Apr 08, 2015 4:43 pm

Hi, this plugin is really useful , especially since my android based calendar watching is getting buggier and buggier.

I was wondering how to set up the timer loop, I've never used the timer plugin before and I can't find any instructions on it.

Also, how do I make EG react to the calendar events? Putting Timer.*_Start as an event doesn't work for me.
Automation is life.

Win7 64bit
EG: r1722

Surio89
Posts: 10
Joined: Sat May 14, 2011 8:57 am

Re: GoogleCalendar2Timer Plugin

Post by Surio89 » Thu Apr 09, 2015 7:15 am

New Update available - UTC detection caused false intermediate events


@skribb
To add a timer loop add Time Plugin and a Timer Action like this:
timerloop.JPG

To get the correct Trigger you can add a 1 minute trial event to your calendar to see all events.
You can double click the Timer Plugin to see all scheduled event names in event name column

If you didnt change the suffix its always like:
Timer.EVENTNAME_Start
Timer.EVENTNAME_Intermediate
Timer.EVENTNAME_End

EVENTNAME is the Title of your calendar event

skribb
Experienced User
Posts: 157
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: GoogleCalendar2Timer Plugin

Post by skribb » Fri Apr 10, 2015 11:28 pm

Thanks for the input

But, regarding "EVENTNAME", is it a wildcard native to your plugin or was that just a description for how the events look like? Because, what i want to achieve, is that EG OSD shows the next event in my calendar. I.e as soon as a calendar event is starting, the OSD shows what that event is, but I guess i need a python script to extract the part between Timer and _Start so I can print it in the OSD`?

Edit: I managed to scrape together different python bits I sniffed out on the web and this will print the calendar event to OSD

Code: Select all

# get the event
timerevent = eg.event.string

if '_Start' in timerevent:
    startslice = 'Timer.'
    endslice = '_Start'    
    calevent = timerevent[timerevent.find(startslice)+6 : timerevent.find(endslice)]
    #print to OSD
    eg.plugins.EventGhost.ShowOSD(calevent, u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial', (34, 250, 10), (0, 0, 0), 4, (0, -385), 0, 30.0, True)
Automation is life.

Win7 64bit
EG: r1722

skribb
Experienced User
Posts: 157
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: GoogleCalendar2Timer Plugin

Post by skribb » Tue Jul 21, 2015 5:44 pm

Hi, as of a few days back I get this error whenver the timer is run:
19:41:35 SSLHandshakeError: [Errno 1] _ssl.c:480: error:0D0C50A1:asn1 encoding routines:ASN1_item_verify:unknown message digest algorithm
could this be a change in the API?
Automation is life.

Win7 64bit
EG: r1722

Surio89
Posts: 10
Joined: Sat May 14, 2011 8:57 am

Re: GoogleCalendar2Timer Plugin

Post by Surio89 » Thu Jul 23, 2015 1:07 pm

I think that the httplib2 can't validate the Google SSL Cert. Maybe Google updated the SSL Cert. I added it manually to the cacert.txt but it doesn't work. You can disable SSL validation by replacing the __init__.py in EventGhost\lib26\site-packages\httplib2\ with the __init__.py attached to this post.
Attachments
__init__.py
(69.36 KiB) Downloaded 105 times

skribb
Experienced User
Posts: 157
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: GoogleCalendar2Timer Plugin

Post by skribb » Thu Jul 30, 2015 5:31 am

Seems to work now, thanks!
Automation is life.

Win7 64bit
EG: r1722

Filandre
Posts: 10
Joined: Sat Mar 28, 2015 8:27 pm

Re: GoogleCalendar2Timer Plugin

Post by Filandre » Thu Jul 30, 2015 4:59 pm

Thanks, that works!
But, can anyone explain the outcome of no SSL validation?

santafr0g
Posts: 1
Joined: Tue Aug 18, 2015 9:08 am

Re: GoogleCalendar2Timer Plugin

Post by santafr0g » Tue Aug 18, 2015 9:32 am

Had the same initial SSL error as the other folks... worked fine once I used your modified python file

robins
Posts: 5
Joined: Mon Oct 14, 2013 12:11 pm

Re: GoogleCalendar2Timer Plugin

Post by robins » Sun Aug 23, 2015 9:04 am

Hello and thank you for the job!

I have a problem to start the pluggin, an idea?

10:49:03 Erreur lors du démarrage du greffon: GoogleCalendar2Timer
10:49:03 Traceback (most recent call last) (1700):
10:49:03 File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInstanceInfo.py", line 177, in Start
10:49:03 self.instance.__start__(*self.args)
10:49:03 File "C:\ProgramData\EventGhost\plugins\GoogleCalendar2Timer\__init__.py", line 39, in __start__
10:49:03 credentials = flow.step2_exchange(authtoken)
10:49:03 File "C:\Program Files (x86)\EventGhost\lib26\site-packages\oauth2client\util.py", line 132, in positional_wrapper
10:49:03 return wrapped(*args, **kwargs)
10:49:03 File "C:\Program Files (x86)\EventGhost\lib26\site-packages\oauth2client\client.py", line 1310, in step2_exchange
10:49:03 raise FlowExchangeError(error_msg)
10:49:03 FlowExchangeError: invalid_grant

Post Reply