Author Topic: GCAL3 - Version 2.6  (Read 150353 times)

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 673
  • Karma: +68/-2
GCAL3 - Version 2.6
« on: August 22, 2014, 10:26:48 am »
This version of Google Calendar supports the Google V3 API's and the necessary authentication required by Google.

Google Credentials
In Google API's prior to V3 it was possible to access a calendar using a url that included a unique key.
Now you need explicit credentials (service account) as well as an ID that identifies the calendar you wish to access.
You will also need to share the calendar with your service account.
The document 'Setting up a Google V3 API Service Account'  here:
http://forum.micasaverde.com/index.php/topic,49258.msg322822.html#msg322822
gives step-by-step instructions on how to create an account , get a credentials file and your Calendar ID.

You need to set up credentials before you use GCAL3

Installation and Setup
Be sure to read the Installation and Initial Setup document here:
http://forum.micasaverde.com/index.php/topic,49258.msg322823.html#msg322823
There is also an advanced configuration document here - with a lot of features, some explanations and some examples.
http://forum.micasaverde.com/index.php/topic,49258.msg322826.html#msg322826

If the documentation is in error, misleading or ambiguous - I'll try to fix that too.

Debugging
GCal3 has three levels of debug messages (1-3).   For troubleshooting, set gc_debug to 3.
Each plugin has the ability to capture it's own log files (see the 2.0 release notes).
Or you can use the GetLog plugin available here:
http://forum.micasaverde.com/index.php/topic,36744.0.html

To assist folks with initial setup / troubleshooting / proving that the plugin is working -- I have created a test calendar and a test set of credentials they can be downloaded from here:
http://forum.micasaverde.com/index.php/topic,49258.msg322824.html#msg322824
 
To use these, follow these steps (in this order).
1. Switch the GCal plugin to Bypass Mode and leave it there until all the steps below are complete.
2. In Apps --> Develop Apps --> Luup Files  Upload the GCal3Test.json file. No need to reload.
3. In the Control tab (of the plugin).  Type "GCal3Test.json" (no quotes)  into the Credential File field and Press "Set".  UI7 will restart itself.  For UI5 you will need to press Reload.
4.  In the Control tab (of the plugin).  Copy the text from the file GCal3TestCalendarID.txt and paste it into the Calendar ID field and press "Set".  UI7 will restart itself.  For UI5 you will need to press Reload.
5. Switch the GCal plugin to Arm Mode

You will now see the next event show up.  Note that these events are named for the time (in GMT) that they occur -- so the actual time, in your timezone may be different.

Be sure to replace the test values for CalendarID and Credential File with your own afterwards ( Following the sequence above).


Release Method
Most releases will be through the marketplace.  From time-to-time there will be test patches (individual files).
To force an update (since vera is inconsistent in this regard) you can use
http://<your vera ip>:3480/data_request?id=update_plugin&Plugin=7016

Release Notes

Note: if you are upgrading from a release prior to 2.0 - please follow the procedure described for rel 2.0 (see below)

Release 2.6
UI Changes
The calendar Tab has been removed.  It serves little purpose and was a source of confusion.

Non-Functional Changes (because they do not affect the working of the plugin)
Due to some differences between Vera units the following changes have been made to assist with general robustness:
1. JSON parser:  If json.lua is not present, a symbolic link to dkjson.lua is created.  This means that if either file is referenced in a "require" statement - then it should work transparently.
2. Removed as much curl code as possible.  Some had to be retained because the alternatives (to curl) do not resolve url redirects (necessary for some iCal).

Release 2.5
Improvements / Changes include:
1.  Improved the handling of events that span midnight
2.  Removed the need to set gc_ExtraDays to some value > 0 if you have a single event that spans multiple days.
3.  Fixed the sometimes incorrect counts of gc_EventsToday and gc_EventsLeft Today ( another "Midnight" thing).
4.  Removed most of gc_Variables (some plugin control info and calendar "snapshot" used for network outages)
    It was taking up too much space in the UI.  It's now in a file.
    A couple of variables are retained to keep the Calendar Tab functioning.
5  Changed some initialization code that sometimes resulted in "Startup Lua Failed".
6  Fixed an incorrect default for gc_EndDelta
7  Added a size check on the json parser used for UI5 (json.lua) to force a download of the correct
   version (Some UI5 users has an old version that was causing startup failures)

NOTE:  This upgrade will preserve the plugin settings BUT you will need to reset CalendarID and Credentials File Name(if other than the default)  PLEASE follow the instructions here:
http://forum.micasaverde.com/index.php/topic,26692.msg294527.html#msg294527

Release 2.4
I broke the calendar tab in this release.  It is fixed in R2.5.
So I have pulled this Release from the marketplace


Release 2.3
Added graceful handling of an internet outage:
 - If the internet drops - GCal will continue to work using the last "good" calendar information.
 - If vera reboots and there is no internet  - GCal will continue to work using the last "good" calendar information.
 - When working "offline" the event name in the display panel will be proceeded by two asterisks i.e. **
 - If the calendar id or Credentials file are changed -- GCal MUST have an internet connection at that time to validate that the calendar is accessible, and to get a "good" set of calendar information.
 - Of course - if you have an extended internet outage - the last "good" calendar information may not be any use if all the events have passed ....

Fixed a bug when an event spans midnight.
 - When GCal reads from google it now looks back to the start of the previous day (so as not to miss events that started the prior day).
 - If you have an event that spans more than one day - you will need to set gc_ExtraDays to some value > 0 (the default) to look back more days.

Release 2.2
Fixed a small bug where the check interval was 180 sec instead of 180 min

Release 2.1 - Removed this from marketplace because I had a bug that I fixed in R2.2

1.  Updated the user documentation (V2.1) to add some clarifications.
2.  At startup - the plugin will recognize if it's not on a vera unit and bypass some checks (instead of just stopping).
3.  Configuration (credentials and CalendarID) checking and error messages and are easier to understand.
4.  Made a small change so that the "window" of time that the plugin looks for events is aligned with the local day. I.e. when it checks for events 'today' it looks from the start of 'today' until the end of 'today'.  If you need the plugin to look further you can use the gc_ExtraDays (default = 0) variable.

Release 2.0

This is a fairly significant release.  Please see the release notes posted here:
http://forum.micasaverde.com/index.php/topic,26692.msg276087.html#msg276087

Edit:  Removed release notes for version prior to 2.0.  The changes are all reflected in the documentation so the notes were just taking up space.
« Last Edit: June 11, 2017, 12:54:23 pm by Stuart »

Offline CudaNet

  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-10
  • Chimichanga !
Re: GCAL3 - Google Calendar 3
« Reply #1 on: August 22, 2014, 01:10:13 pm »
Stuart, really looking forward to installing this. Will give it a go in the next day or so.... So glad this plugin is in it's own forum (just noticed that)...
openLuup, AltUI, Zway and HomeWave, enough said...

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 673
  • Karma: +68/-2
Re: GCAL3 - Google Calendar 3
« Reply #2 on: August 22, 2014, 02:09:47 pm »
Stuart, really looking forward to installing this. Will give it a go in the next day or so.... So glad this plugin is in it's own forum (just noticed that)...

Just posted the release files above.   Hope the install is smooth ......

Offline korttoma

  • Hero Member
  • *****
  • Posts: 689
  • Karma: +25/-5
  • Keep it simple, stupid
Re: GCAL3 - Google Calendar 3
« Reply #3 on: August 22, 2014, 04:15:20 pm »
Thumbs up Stuart!!!
- Tomas

Offline duiffie

  • Full Member
  • ***
  • Posts: 126
  • Karma: +2/-0
Re: GCAL3 - Google Calendar 3
« Reply #4 on: August 25, 2014, 05:22:24 am »
Followed all the steps, but:

Code: [Select]
50      08/25/14 11:24:40.417   luup_log:75: GCal3 gc_V 0.6:Getting new token __LEAK__ this:40960 start:3620864 to 0x12e1000 <0x8c24>
50      08/25/14 11:24:40.420   luup_log:75: GCal3 gc_V 0.6:Client email is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com __LEAK__ this:4096 start:3624960 to 0x12e2000 <0x8c24>
50      08/25/14 11:24:40.792   luup_log:75: GCal3 gc_V 0.6:Command rm /etc/cmh-ludl/GCal3/GCal3.token returned 256 <0x8c24>
50      08/25/14 11:24:41.027   luup_log:75: GCal3 gc_V 0.6:Command /usr/lib/lua/googlejwt.sh xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com  https://www.googleapis.com/auth/calendar /etc/cmh-ludl/GCal3/GCal3.pem /etc/cmh-ludl/GCal3/GCal3.token returned 32512 <0x8c24>
50      08/25/14 11:24:41.028   luup_log:75: GCal3 gc_V 0.6:Could not execute the googlejwt.sh script <0x8c24>
50      08/25/14 11:24:41.029   luup_log:75: GCal3 gc_V 0.6:Fatal error trying to get access token <0x8c24>
06      08/25/14 11:24:41.032   Device_Variable::m_szValue_set device: 75 service: urn:srs-com:serviceId:GCalIII variable: gc_nextCheck was: 2014-08-25T14:13:52 now: 2014-08-25T14:24:32 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x8c24>
50      08/25/14 11:24:41.033   luup_log:75: GCal3 gc_V 0.6:Next check will be in 10800 sec at 2014-08-25T14:24:32 <0x8c24>

The calendar shows up fine though after opening the calendar-tab, the device hangs on 'Checking...'.

Any idea? :-)
« Last Edit: August 25, 2014, 06:31:32 am by duiffie »
Vera2 (1.5.622)

Offline roquej

  • Sr. Newbie
  • *
  • Posts: 35
  • Karma: +0/-0
Re: GCAL3 - Google Calendar 3
« Reply #5 on: August 25, 2014, 09:11:55 am »
Stuart,

Will GCal3 install over GCal_II or would it be appear as another device?

Thank you!

JR

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 673
  • Karma: +68/-2
Re: GCAL3 - Google Calendar 3
« Reply #6 on: August 25, 2014, 10:47:20 am »
Followed all the steps, but:

Code: [Select]
50      08/25/14 11:24:40.417   luup_log:75: GCal3 gc_V 0.6:Getting new token __LEAK__ this:40960 start:3620864 to 0x12e1000 <0x8c24>
50      08/25/14 11:24:40.420   luup_log:75: GCal3 gc_V 0.6:Client email is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com __LEAK__ this:4096 start:3624960 to 0x12e2000 <0x8c24>
50      08/25/14 11:24:40.792   luup_log:75: GCal3 gc_V 0.6:Command rm /etc/cmh-ludl/GCal3/GCal3.token returned 256 <0x8c24>
50      08/25/14 11:24:41.027   luup_log:75: GCal3 gc_V 0.6:Command /usr/lib/lua/googlejwt.sh xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com  https://www.googleapis.com/auth/calendar /etc/cmh-ludl/GCal3/GCal3.pem /etc/cmh-ludl/GCal3/GCal3.token returned 32512 <0x8c24>
50      08/25/14 11:24:41.028   luup_log:75: GCal3 gc_V 0.6:Could not execute the googlejwt.sh script <0x8c24>
50      08/25/14 11:24:41.029   luup_log:75: GCal3 gc_V 0.6:Fatal error trying to get access token <0x8c24>
06      08/25/14 11:24:41.032   Device_Variable::m_szValue_set device: 75 service: urn:srs-com:serviceId:GCalIII variable: gc_nextCheck was: 2014-08-25T14:13:52 now: 2014-08-25T14:24:32 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x8c24>
50      08/25/14 11:24:41.033   luup_log:75: GCal3 gc_V 0.6:Next check will be in 10800 sec at 2014-08-25T14:24:32 <0x8c24>

The calendar shows up fine though after opening the calendar-tab, the device hangs on 'Checking...'.

Any idea? :-)

@duiffie
This log tells me there was a error trying to execute the command /ur/lib/lua/googlejwt.sh -- possibly that it could not be found .....
The number and type of arguments looks correct

What does the log file indicate at the very start ?   It's possible there was a failure in downloading googlejwt.sh or setting it's permissions. 

Unfortunately googlejwt.sh is currently a 'black box' there is no debugging.  That's the next thing I'm working on, although - given a correctly formed GCal3.json file - I've not seen it fail.

Lets see if googlejwt.json exists first - can you telnet in ?  do an 'ls -l' ?

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 673
  • Karma: +68/-2
Re: GCAL3 - Google Calendar 3
« Reply #7 on: August 25, 2014, 10:54:07 am »
Stuart,

Will GCal3 install over GCal_II or would it be appear as another device?

Thank you!

JR

You "should" be fine - I think (I'm on the road for a couple of days)  there may be one global variable that I have not tidied up that is common with GCal_II but it's only used briefly when decoding calendar results - so it would be bad luck if there was a 'collision'.  Even then - I'm not certain how Lua / mios seprates the execution space .....  so it might be perfectly fine even as is.

Offline duiffie

  • Full Member
  • ***
  • Posts: 126
  • Karma: +2/-0
Re: GCAL3 - Google Calendar 3
« Reply #8 on: August 25, 2014, 12:11:20 pm »
Followed all the steps, but:

Code: [Select]
50      08/25/14 11:24:40.417   luup_log:75: GCal3 gc_V 0.6:Getting new token __LEAK__ this:40960 start:3620864 to 0x12e1000 <0x8c24>
50      08/25/14 11:24:40.420   luup_log:75: GCal3 gc_V 0.6:Client email is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com __LEAK__ this:4096 start:3624960 to 0x12e2000 <0x8c24>
50      08/25/14 11:24:40.792   luup_log:75: GCal3 gc_V 0.6:Command rm /etc/cmh-ludl/GCal3/GCal3.token returned 256 <0x8c24>
50      08/25/14 11:24:41.027   luup_log:75: GCal3 gc_V 0.6:Command /usr/lib/lua/googlejwt.sh xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com  https://www.googleapis.com/auth/calendar /etc/cmh-ludl/GCal3/GCal3.pem /etc/cmh-ludl/GCal3/GCal3.token returned 32512 <0x8c24>
50      08/25/14 11:24:41.028   luup_log:75: GCal3 gc_V 0.6:Could not execute the googlejwt.sh script <0x8c24>
50      08/25/14 11:24:41.029   luup_log:75: GCal3 gc_V 0.6:Fatal error trying to get access token <0x8c24>
06      08/25/14 11:24:41.032   Device_Variable::m_szValue_set device: 75 service: urn:srs-com:serviceId:GCalIII variable: gc_nextCheck was: 2014-08-25T14:13:52 now: 2014-08-25T14:24:32 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x8c24>
50      08/25/14 11:24:41.033   luup_log:75: GCal3 gc_V 0.6:Next check will be in 10800 sec at 2014-08-25T14:24:32 <0x8c24>

The calendar shows up fine though after opening the calendar-tab, the device hangs on 'Checking...'.

Any idea? :-)

@duiffie
This log tells me there was a error trying to execute the command /ur/lib/lua/googlejwt.sh -- possibly that it could not be found .....
The number and type of arguments looks correct

What does the log file indicate at the very start ?   It's possible there was a failure in downloading googlejwt.sh or setting it's permissions. 

Unfortunately googlejwt.sh is currently a 'black box' there is no debugging.  That's the next thing I'm working on, although - given a correctly formed GCal3.json file - I've not seen it fail.

Lets see if googlejwt.json exists first - can you telnet in ?  do an 'ls -l' ?

it does exist and it is executable:
Code: [Select]
ls -ltr /usr/lib/lua/googlejwt.sh
-rwxr-xr-x    1 root     root         1240 Aug 25 18:04 /usr/lib/lua/googlejwt.sh

i see that the openssl command is used within this shell script. My box (vera 2) doesn't seem to have openssl installed, can that be a reason?
Vera2 (1.5.622)

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 673
  • Karma: +68/-2
Re: GCAL3 - Google Calendar 3
« Reply #9 on: August 25, 2014, 12:22:47 pm »
@ Duiffie
Wow!   I have a vera light and do not know if there is supposed to be a difference.

The reason I went that route is because vera does not have a lua module that would otherwise be used.  So I assumed that the *nix libraries would be the safest approach.......

I'll send an email to vera support and ask.  It may be a simple opt install -  if so we can do that manually and later I can pout a check in the plugin.


Offline duiffie

  • Full Member
  • ***
  • Posts: 126
  • Karma: +2/-0
Re: GCAL3 - Google Calendar 3
« Reply #10 on: August 25, 2014, 12:40:10 pm »
@ Duiffie
Wow!   I have a vera light and do not know if there is supposed to be a difference.

The reason I went that route is because vera does not have a lua module that would otherwise be used.  So I assumed that the *nix libraries would be the safest approach.......

I'll send an email to vera support and ask.  It may be a simple opt install -  if so we can do that manually and later I can pout a check in the plugin.

I did 2 things and then things started to work:
- installed openssl: opkg install openssl-util
- changed the first line of the googlejwt.sh script (#!/bin/bash to #!/bin/ash) because bash seems not present on vera 2 as well
Vera2 (1.5.622)

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 673
  • Karma: +68/-2
Re: GCAL3 - Google Calendar 3
« Reply #11 on: August 25, 2014, 03:51:48 pm »
@Duiffie

Great! And Thanks! !!!

I suspect that ash vs bash is just a symlink  to busybox-  strange that MCV would do that. ..... might be an openwrt thing. ....

Might be that the script can be made generic by invoking busybox direct.

I'm traveling this week but will look at some options when I return including auto installing opened out it's not there. ...

Offline farang

  • Full Member
  • ***
  • Posts: 159
  • Karma: +23/-3
Re: GCAL3 - Google Calendar 3 (Unit Busy)
« Reply #12 on: August 26, 2014, 01:03:19 pm »
I've upgraded from GCal II to GCal 3.

Now, whenever Vera needs to make a reload it will take like ages. I have 4 defined calendar devices. The reload happens an arbitrary number of times, typically 4 times in a row. It says "Unit Busy", then it says "Running LUA Startup" or "Starting LUA Engine". Then it starts with "Unit Busy" and so on..  Before it was only a single cycle.

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 673
  • Karma: +68/-2
Re: GCAL3 - Google Calendar 3 (Unit Busy)
« Reply #13 on: August 26, 2014, 03:08:58 pm »
I've upgraded from GCal II to GCal 3.

Now, whenever Vera needs to make a reload it will take like ages. I have 4 defined calendar devices. The reload happens an arbitrary number of times, typically 4 times in a row. It says "Unit Busy", then it says "Running LUA Startup" or "Starting LUA Engine". Then it starts with "Unit Busy" and so on..  Before it was only a single cycle.

Once it's done does it work correctly?
Can you capture a log file?
I did not test with multiple plugins since hopefully the ability to define multiple keywords makes that unnecessary.  I will try to test but may not get to it until next week.

Offline farang

  • Full Member
  • ***
  • Posts: 159
  • Karma: +23/-3
Re: GCAL3 - Google Calendar 3 (Unit Busy)
« Reply #14 on: August 26, 2014, 04:15:37 pm »
I've upgraded from GCal II to GCal 3.

Now, whenever Vera needs to make a reload it will take like ages. I have 4 defined calendar devices. The reload happens an arbitrary number of times, typically 4 times in a row. It says "Unit Busy", then it says "Running LUA Startup" or "Starting LUA Engine". Then it starts with "Unit Busy" and so on..  Before it was only a single cycle.

Once it's done does it work correctly?
Can you capture a log file?
I did not test with multiple plugins since hopefully the ability to define multiple keywords makes that unnecessary.  I will try to test but may not get to it until next week.

First I want to say Thank You for your great work.  ;D

Yes, everything seems to work after it's done reloading etc , so it's not that urgent. It can wait until you have time to look into it. I use multiple GCal 3 devices since I have several calendars to watch :D

If You can't reproduce the behaviour I will learn how to produce a log file. Thanks!  ;D ;D ;D