We have moved at community.getvera.com

Author Topic: Google Calendar Switch  (Read 139875 times)

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: Google Calendar Switch
« Reply #480 on: July 30, 2014, 07:16:45 pm »
WOW, that Info Viewer is awesome... Love tools that make life so easy... Will post log data later, on my way home....
openLuup, AltUI, Zway and HomeWave, enough said...

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: Google Calendar Switch
« Reply #481 on: July 30, 2014, 08:06:13 pm »
just wondering which side of the event a automation profile will trigger from

for example, i put into my google calendar when i work night shifts from 10pm until 7am, so that my lamp in my room will come on when i arrive home from work, air purifier turns on just as i leave work, ect.

will i need to set delays from the time that the calendar event starts (10pm meaning 9 hours before my automation profile does anything) or ends (7am meaning no delay before the first item triggers)

cheers

If you want to specify just one calendar event and have something happen when it starts and something else happen when it ends - then I'd consider using the PLEG plugin since it understands transitions of an event from 'Off' to 'On' and vice-versa (and much, much, much, much more). 

Without getting complicated PLEG can have an input (e.g. GCal Triggering); conditions (e.g. Trigger on and Trigger Off) and different Actions associated with each condition.   All this without having to include delayes etc (although it can do that as well).  I think of it as the swiss army knife for controlling vera ..... 

In general - vera only understands when something Triggers i.e. the start of an event.  So without using PLEG you could have two separate events - one for "going to work" and one for "arriving home" - but the downside is you have to make two calendar entries (which is why I like PLEG   8)   )


Hope this helps


Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: Google Calendar Switch
« Reply #482 on: July 30, 2014, 11:09:48 pm »
@Stuart

Here are the logs (pre and post), after I captured and analyzed the log data I loaded the two revised files and ran another test. Then I ran two more (just in case) and it certainly appears that the updated files have corrected the (my) issue...

Prior to load of updated files...
Code: [Select]
06 07/30/14 20:45:02.183 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEventTime was: 20:45 Jul 30 to 20:47 Jul 30 now: 20:45 Jul 30 to 20:47 Jul 30 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2fa0f680>
06 07/30/14 20:45:02.184 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEvent was: [removed by Cuda] now: [removed by Cuda] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2fa0f680>
50 07/30/14 20:45:02.184 luup_log:133: GCAL gc_V 1.9.0:Next Event:  [removed by Cuda] -- 20:45 Jul 30 to 20:47 Jul 30 <0x2fa0f680>
50 07/30/14 20:45:02.184 luup_log:133: GCAL gc_V 1.9.0:Event-Start  [removed by Cuda] 07/30 20:45  Tripped <0x2fa0f680>
06 07/30/14 20:45:02.185 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEvent was: [removed by Cuda] now: [removed by Cuda] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2fa0f680>
06 07/30/14 20:45:02.185 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_Value was:  now: [removed by Cuda] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa0f680>
06 07/30/14 20:45:02.185 Device_Variable::m_szValue_set device: 133 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: Tripped was: 0 now: 1 #hooks: 1 upnp: 0 v:0xcab208/NONE duplicate:0 <0x2fa0f680>
07 07/30/14 20:45:02.189 Event::Evaluate 31 Event scene Google Calendar is true users:326641 allow:1 <0x2fa0f680>
08 07/30/14 20:45:02.189 Scene::RunScene running 65 Google Calendar <0x2fa0f680>
06 07/30/14 20:45:02.189 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_TrippedEvent was:  now: [removed by Cuda] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa0f680>
06 07/30/14 20:45:02.192 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_TrippedID was:  now: [removed by Cuda] 07/30 20:47 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa0f680>
06 07/30/14 20:45:02.194 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_nextCheck was: 2014-07-30T20:45:00 now: 2014-07-30T20:47:00 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa0f680>
50 07/30/14 20:45:02.195 luup_log:133: GCAL gc_V 1.9.0:Next check will be in 119 sec at 2014-07-30T20:47:00 <0x2fa0f680>
06 07/30/14 20:45:02.705 RAServerSync::SendAlert ID [removed by Cuda],PK_Alert:3584247071 sync 0x155e490 for https://cms1.mios.com/alert?PK_AccessPoint=30007459&HW_Key=[removed by Cuda]&DeviceID=[removed by Cuda]&LocalDate=2014-07-30%2020:45:02&LocalTimestamp=1406771102&AlertType=3&SourceType=3&Argument=31&Format=&Code=Tripped&Value=1&Description=Event&Users=[removed by Cuda] <0x2c00f680>
02 07/30/14 20:45:09.103 ZW_Send_Data node 12 USING ROUTE 255.16.127.193 <0x2c20f680>

Here is the log after I loaded the two files...
Code: [Select]
06 07/30/14 21:18:02.185 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEvent was: [removed by Cuda] now: [removed by Cuda] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2fa37680>
06 07/30/14 21:18:02.185 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_Value was:  now: [removed by Cuda] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa37680>
06 07/30/14 21:18:02.186 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_TrippedEvent was:  now: [removed by Cuda] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa37680>
06 07/30/14 21:18:02.186 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_TrippedID was:  now: [removed by Cuda] 07/30 21:20 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa37680>
06 07/30/14 21:18:02.187 Device_Variable::m_szValue_set device: 133 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: Tripped was: 0 now: 1 #hooks: 1 upnp: 0 v:0x9d6208/NONE duplicate:0 <0x2fa37680>
08 07/30/14 21:18:02.189 JobHandler_LuaUPnP::HandleActionRequest device: 36 service: urn:upnp-org:serviceId:IOSPush1 action: SendPushOverNotification <0x2fa37680>
08 07/30/14 21:18:02.189 JobHandler_LuaUPnP::HandleActionRequest argument Message=[removed by Cuda] <0x2fa37680>
08 07/30/14 21:18:02.189 JobHandler_LuaUPnP::HandleActionRequest argument Priority=0 <0x2fa37680>
08 07/30/14 21:18:02.190 JobHandler_LuaUPnP::HandleActionRequest argument Title=[removed by Cuda] <0x2fa37680>
08 07/30/14 21:18:02.190 JobHandler_LuaUPnP::HandleActionRequest argument Sound=tugboat <0x2fa37680>
06 07/30/14 21:18:02.897 Device_Variable::m_szValue_set device: 36 service: urn:upnp-org:serviceId:IOSPush1 variable: TimeSend was: 1406771938 now: 1406773082 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa37680>
06 07/30/14 21:18:02.898 Device_Variable::m_szValue_set device: 36 service: urn:upnp-org:serviceId:IOSPush1 variable: PushOverCount was: 12 now: 13 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa37680>
06 07/30/14 21:18:02.900 Device_Variable::m_szValue_set device: 36 service: urn:upnp-org:serviceId:IOSPush1 variable: LastError was: RST - 21:10 now: Ok - 21:18 - (PushOver) #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa37680>
02 07/30/14 21:18:03.101 LOG_CHECK_MEMORY_LEAK pMem start 0x1350000 now 0x15dd000 last 0x15c2000 leaked 2674688 <0x2be37680>
06 07/30/14 21:18:03.302 Device_Variable::m_szValue_set device: 36 service: urn:upnp-org:serviceId:IOSPush1 variable: PluginMessage was: -.- now: -.- #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2fa37680>
07 07/30/14 21:18:03.304 Event::Evaluate 31 Event scene Google Calendar is true users:326641 allow:1 <0x2fa37680>
08 07/30/14 21:18:03.304 Scene::RunScene running 65 Google Calendar <0x2fa37680>
50 07/30/14 21:18:03.304 luup_log:133: GCAL gc_V 1.9.0:Event-Start [removed by Cuda]07/30 21:18 Tripped <0x2fa37680>
06 07/30/14 21:18:03.305 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_nextCheck was: 2014-07-30T21:18:00 now: 2014-07-30T21:20:00 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa37680>
50 07/30/14 21:18:03.337 luup_log:133: GCAL gc_V 1.9.0:Next check will be in 119 sec at 2014-07-30T21:20:00 <0x2fa37680>
06 07/30/14 21:18:03.338 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_lastCheck was: 2014-07-30T21:18:01 now: 2014-07-30T21:18:03 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa37680>
06 07/30/14 21:18:03.339 Device_Variable::m_szValue_set device: 133 service: urn:srs-com:serviceId:GCal2 variable: gc_jsonEvents was: [[removed by Cuda]] now: [] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fa37680>
50 07/30/14 21:18:03.352 luup_log:133: GCAL gc_V 1.9.0:StartMin is 2014-07-30T00:00:00 StatMax is 2014-08-01T05:18:03 <0x2fa37680>
50 07/30/14 21:18:03.352 luup_log:133: GCAL gc_V 1.9.0:Checking google calendar <0x2fa37680>
06 07/30/14 21:18:03.756 RAServerSync::SendAlert ID 2147483647,PK_Alert:3584410031 sync 0x1211550 for https://cms1.mios.com/alert?PK_AccessPoint=[removed by Cuda]&HW_Key=[removed by Cuda]&DeviceID=[removed by Cuda]&LocalDate=2014-07-30%2021:18:03&LocalTimestamp=1406773083&AlertType=3&SourceType=3&Argument=31&Format=&Code=Tripped&Value=1&Description=Event&Users=[removed by Cuda] <0x2c037680>

openLuup, AltUI, Zway and HomeWave, enough said...

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: Google Calendar Switch
« Reply #483 on: July 30, 2014, 11:37:47 pm »
@CudaNet --

Well, Well !!  Looks like the plugin 'Trip' - eventhough it looks like it's only an assignment in the code -  behaves synchronously.  Possibly with 'downstream' triggers being set, before it returns to the calling code ......  at least, that's what the timings in the log suggest.  So indeed there was a race condition .....

Great Catch !!

Note to self:  make sure the plugin Trigger set and unset go last and stay that way !!

Hmm - I wonder if this has anything to do with notifications failing on the "An event has specified name" trigger option ??   Something to dig into tomorrow .....

Thanks for the logs and thanks to info viewer

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: Google Calendar Switch
« Reply #484 on: July 30, 2014, 11:48:02 pm »
Thanks to you, I'm loving this code - tons of possibilities. The wife loves it too, easy for her to add events since she already uses Google Calendar.

@CudaNet --

Well, Well !!  Looks like the plugin 'Trip' - eventhough it looks like it's only an assignment in the code -  behaves synchronously.  Possibly with 'downstream' triggers being set, before it returns to the calling code ......  at least, that's what the timings in the log suggest.  So indeed there was a race condition .....

Great Catch !!

Note to self:  make sure the plugin Trigger set and unset go last and stay that way !!

Hmm - I wonder if this has anything to do with notifications failing on the "An event has specified name" trigger option ??   Something to dig into tomorrow .....

Thanks for the logs and thanks to info viewer
openLuup, AltUI, Zway and HomeWave, enough said...

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: Google Calendar Switch
« Reply #485 on: August 12, 2014, 05:28:02 pm »
FINAL VERSION OF GOOGLE CALENDAR II

I posted the final version (2.2) of goggle calendar II to the marketplace today.  This version fixes a race condition that affected at least one user and I also noticed that I'd been triggering the plugin on every event if no keyword was specified.  The correct behavior was to set the trigger event variable (which I was also doing) but not trigger the plugin.  Anyway - to help give a visual, the icon for the plugin is now a light-bulb which is (1) off when no event (2) 1/2 bright when in an event but no keyword (3) full bright when tripped on a keyword.

I'd like to use better icons but was thwarted by UI5 - maybe UI7 will make these things easier / possible ......

The next version will be called 'Google Calendar 3' in honor of the new (V3) google API's that must be used from about November.  I.e. the previous versions of google calendar (the original plus GCal_II) are apparently going to stop working in Nov when google turn off the V2 API's which were used up till now.

The V3 google API's also introduce a new authentication scheme - initial setup will be a bit more involved.  I'll document it fairly completely to make it easier for all.  The initial functionality will pick up where Google Calendar II left off i.e. Version 2.2

I'm probably a couple of weeks away from releasing GCal3 and I'll start a completely new thread for that.   After I get the first release of GCal3 out, I'll see if it works with UI7.   I'm not sure what it will mean if it does not work since, it seems there is no documentation about how to migrate to UI7 ......  still, I'm up for the challenge ......

Offline ft9

  • Sr. Newbie
  • *
  • Posts: 23
  • Karma: +1/-0
Re: Google Calendar Switch
« Reply #486 on: August 12, 2014, 05:53:33 pm »
Thank you so much for your work Stuart!
It has been working great!

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: Google Calendar Switch
« Reply #487 on: August 12, 2014, 11:47:23 pm »
Good work Stuart!  ;)
- Tomas

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: Google Calendar Switch
« Reply #488 on: August 13, 2014, 11:19:26 am »
This is one of my top 5 plugins so kudos to the developer and all that contributed.
openLuup, AltUI, Zway and HomeWave, enough said...

guest141575

  • Guest
Re: Google Calendar Switch
« Reply #489 on: August 19, 2014, 06:22:44 am »
Stuart, Thank you for your work on this plugin. I appreciate it.

My Google Calendar II plugin was auto updated to V 2.2 last night so my system wasn't working like it did before.

Documentation (V1.5) says that
Quote
If no keyword is set then any event will enable the plugin to trigger

I haven't specified any keyword in the plugin since I want the plugin to get tripped on all calendar events. The problem is that the icon only gets half-lit and the "Tripped"-property won't change from 0 to 1. Only way I can get it to work is by specifying a keyword.

Any help will be appreciated. Thanks.

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: Google Calendar Switch
« Reply #490 on: August 19, 2014, 11:12:38 am »
Same thing happened to me, everything stopped as I too had no keywords defined. As a workaround I had to add my keywords (semi colon delimited) within gc_Keyword (plugin>advanced). Another issue is the calendar (plugin>calendar) is no longer being displayed (definitely not a show stopper).

Stuart, Thank you for your work on this plugin. I appreciate it.

My Google Calendar II plugin was auto updated to V 2.2 last night so my system wasn't working like it did before.

Documentation (V1.5) says that
Quote
If no keyword is set then any event will enable the plugin to trigger

I haven't specified any keyword in the plugin since I want the plugin to get tripped on all calendar events. The problem is that the icon only gets half-lit and the "Tripped"-property won't change from 0 to 1. Only way I can get it to work is by specifying a keyword.

Any help will be appreciated. Thanks.
openLuup, AltUI, Zway and HomeWave, enough said...

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: Google Calendar Switch
« Reply #491 on: August 19, 2014, 12:00:50 pm »
Same thing happened to me, everything stopped as I too had no keywords defined. As a workaround I had to add my keywords (semi colon delimited) within gc_Keyword (plugin>advanced). Another issue is the calendar (plugin>calendar) is no longer being displayed (definitely not a show stopper).

Stuart, Thank you for your work on this plugin. I appreciate it.

My Google Calendar II plugin was auto updated to V 2.2 last night so my system wasn't working like it did before.

Documentation (V1.5) says that
Quote
If no keyword is set then any event will enable the plugin to trigger

I haven't specified any keyword in the plugin since I want the plugin to get tripped on all calendar events. The problem is that the icon only gets half-lit and the "Tripped"-property won't change from 0 to 1. Only way I can get it to work is by specifying a keyword.

Any help will be appreciated. Thanks.

Ah well ..... since I was trying to maintain the behavior of the original ..... I 'fixed' a 'bug' in my code since the intent was that -- with no keyword set, the plugin itself did not 'trigger' on each and every event but instead your scene would be set-up to react to "An event has specified name" and therefore simplify the use (i.e. so you did not have to react to each and every trigger).  The documentation needs to be tidied up ......

Obviously this broke the plugin for your use case .....

Attached is a patched version (just the one file) which you can download and try

EDIT: Attachment removed due to silly syntax error on my part - patched patch several posts below

There is a new variable gc_triggerNoKeyword which defaults to false.  You will need to set it to true in the advanced tab and should have the previous behavior restored.

I'll carry this forward to GCal3 which I will release shortly ....

Let me know if it works - it was a minor change and since I'm working on GCal3 (and have to get to my day job) did not test it .....


« Last Edit: August 19, 2014, 02:39:11 pm by Stuart »

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: Google Calendar Switch
« Reply #492 on: August 19, 2014, 12:47:21 pm »
Same thing happened to me, everything stopped as I too had no keywords defined. As a workaround I had to add my keywords (semi colon delimited) within gc_Keyword (plugin>advanced). Another issue is the calendar (plugin>calendar) is no longer being displayed (definitely not a show stopper).


The calendar tab not showing is an definite 'oops' on my part - caused when I was transferring code to the new directory for GCal3

This attachment should fix it ...  but cannot be sent as a js file.  So download it and remove the .txt part (corrected file name is J_GCal_II.js) before adding to your vera  - refresh the browser when done.

When you confirm that all is well  - I'll push out these two patched as (hopefully) the last of the GCal_II official releases (like to end on a "all working" note)

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: Google Calendar Switch
« Reply #493 on: August 19, 2014, 12:54:45 pm »
Hmm, encountering an LUA engine failed to load..
01      08/19/14 12:00:06.421   LuaInterface::LoadCode: [string "local GCAL_VERSION = "V 2.2.1"..."]:447: ')' expected near '=' <0x2b00d000>
01      08/19/14 12:00:06.932   Device_Interface::CreateLuaInterface 133 failed to start engine <0x2b00d000>

Same thing happened to me, everything stopped as I too had no keywords defined. As a workaround I had to add my keywords (semi colon delimited) within gc_Keyword (plugin>advanced). Another issue is the calendar (plugin>calendar) is no longer being displayed (definitely not a show stopper).


The calendar tab not showing is an definite 'oops' on my part - caused when I was transferring code to the new directory for GCal3

This attachment should fix it ...  but cannot be sent as a js file.  So download it and remove the .txt part (corrected file name is J_GCal_II.js) before adding to your vera  - refresh the browser when done.

When you confirm that all is well  - I'll push out these two patched as (hopefully) the last of the GCal_II official releases (like to end on a "all working" note)
« Last Edit: August 19, 2014, 01:06:32 pm by CudaNet »
openLuup, AltUI, Zway and HomeWave, enough said...

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: Google Calendar Switch
« Reply #494 on: August 19, 2014, 01:16:58 pm »
Patched lines 447 and 488
if (GC.Keyword ~= "")  or (GC.triggerNoKeyword == "true") then luup.variable_set(SECURITY_SID, "Tripped", 0, lul_device) end
if (GC.Keyword ~= "") or (GC.triggerNoKeyword == "true") then

Will test and report back (I'll load the JS file after I unit these changes).

Hmm, encountering an LUA engine failed to load..
01      08/19/14 12:00:06.421   LuaInterface::LoadCode: [string "local GCAL_VERSION = "V 2.2.1"..."]:447: ')' expected near '=' <0x2b00d000>
01      08/19/14 12:00:06.932   Device_Interface::CreateLuaInterface 133 failed to start engine <0x2b00d000>

Same thing happened to me, everything stopped as I too had no keywords defined. As a workaround I had to add my keywords (semi colon delimited) within gc_Keyword (plugin>advanced). Another issue is the calendar (plugin>calendar) is no longer being displayed (definitely not a show stopper).


The calendar tab not showing is an definite 'oops' on my part - caused when I was transferring code to the new directory for GCal3

This attachment should fix it ...  but cannot be sent as a js file.  So download it and remove the .txt part (corrected file name is J_GCal_II.js) before adding to your vera  - refresh the browser when done.

When you confirm that all is well  - I'll push out these two patched as (hopefully) the last of the GCal_II official releases (like to end on a "all working" note)
« Last Edit: August 19, 2014, 01:21:32 pm by CudaNet »
openLuup, AltUI, Zway and HomeWave, enough said...