We have moved at community.getvera.com

Author Topic: GCal3 to write events to Calendar  (Read 4524 times)

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
GCal3 to write events to Calendar
« on: January 06, 2015, 12:55:02 pm »
Any thoughts on making the Calendar plugin operate upstream ? Since you've built the ability to oAuth with Google I'd love the ability to utilize lua via the plugin to 'manage' events to the Calendar. I actually use this plugin more than any other to control my lights (Lux, Hue, indoor and outdoor LED's), speech (reminders), push (text messages), irrigation and thermostats.  The ability to create events and delete events would make this the perfect solution...

Anyways, just a thought... I noticed things were kind of quiet around here so I thought I'd make some noise... 8)

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

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCal3 to write events to Calendar
« Reply #1 on: January 06, 2015, 01:43:16 pm »
Any thoughts on making the Calendar plugin operate upstream ? Since you've built the ability to oAuth with Google I'd love the ability to utilize lua via the plugin to 'manage' events to the Calendar. I actually use this plugin more than any other to control my lights (Lux, Hue, indoor and outdoor LED's), speech (reminders), push (text messages), irrigation and thermostats.  The ability to create events and delete events would make this the perfect solution...

Anyways, just a thought... I noticed things were kind of quiet around here so I thought I'd make some noise... 8)

I seem to recall that there is already a plugin for creating events in google calendar ????   Have not used or looked at it myself - but perhaps this has already been done.

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: GCal3 to write events to Calendar
« Reply #2 on: January 06, 2015, 02:01:17 pm »
Hmm, I checked a little and thought that maybe that code was abandoned (event2gcal)... I'll load the plugin and see if I can possibly make it work. Will report back.

Any thoughts on making the Calendar plugin operate upstream ? Since you've built the ability to oAuth with Google I'd love the ability to utilize lua via the plugin to 'manage' events to the Calendar. I actually use this plugin more than any other to control my lights (Lux, Hue, indoor and outdoor LED's), speech (reminders), push (text messages), irrigation and thermostats.  The ability to create events and delete events would make this the perfect solution...

Anyways, just a thought... I noticed things were kind of quiet around here so I thought I'd make some noise... 8)

I seem to recall that there is already a plugin for creating events in google calendar ????   Have not used or looked at it myself - but perhaps this has already been done.
openLuup, AltUI, Zway and HomeWave, enough said...

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: GCal3 to write events to Calendar
« Reply #3 on: January 06, 2015, 02:23:15 pm »
No bueno... Event2GCal : Lua error
Plug is fully configured, a little digging through the logs show :

Code: [Select]
08      01/06/15 13:09:36.842   JobHandler_LuaUPnP::HandleActionRequest device: 232 service: urn:event2gcal:serviceId:Event2GCal1 action: SetCalendarName <0x30dc2680>
08      01/06/15 13:09:36.842   JobHandler_LuaUPnP::HandleActionRequest argument fwdserver=1 <0x30dc2680>
08      01/06/15 13:09:36.843   JobHandler_LuaUPnP::HandleActionRequest argument remoteIP=70.251.39.9 <0x30dc2680>
08      01/06/15 13:09:36.843   JobHandler_LuaUPnP::HandleActionRequest argument token=[removed by Cuda] <0x30dc2680>
08      01/06/15 13:09:36.843   JobHandler_LuaUPnP::HandleActionRequest argument PK_AccessPoint=[removed by Cuda] <0x30dc2680>
08      01/06/15 13:09:36.843   JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=232 <0x30dc2680>
08      01/06/15 13:09:36.843   JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:event2gcal:serviceId:Event2GCal1 <0x30dc2680>
08      01/06/15 13:09:36.844   JobHandler_LuaUPnP::HandleActionRequest argument action=SetCalendarName <0x30dc2680>
08      01/06/15 13:09:36.844   JobHandler_LuaUPnP::HandleActionRequest argument NewCalendarName=[removed by Cuda] <0x30dc2680>
08      01/06/15 13:09:36.844   JobHandler_LuaUPnP::HandleActionRequest argument rand=0.25600285013206303 <0x30dc2680>
06      01/06/15 13:09:36.845   Device_Variable::m_szValue_set device: 232 service: urn:event2gcal:serviceId:Event2GCal1 variable: CalendarName was:  now: [removed by Cuda] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0

And UPNP crashed the system so the restart occured and then this :

01      01/06/15 13:10:03.789   JobHandler_LuaUPnP::CreateLuaInterfaces can't load plugin /etc/cmh-lu//google.lua <

Guess I'll have to open up the Google.lua and see what it's doing inside....
openLuup, AltUI, Zway and HomeWave, enough said...

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCal3 to write events to Calendar
« Reply #4 on: January 06, 2015, 02:57:48 pm »
If it's been abandoned then I think it unlikely that it uses the new auth mechanism.  Let me know what you see and I can decide if it makes sense to maybe try to update it or add some functionality into GCal3 or ......


Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: GCal3 to write events to Calendar
« Reply #5 on: January 06, 2015, 04:25:42 pm »
I found a link to the developers website (French) based on his event2Gcal thread. Per his/her advice, I removed the plugin and added it manually. That, at the very least cleared all the issues I was having with Lua errors. However, it appears that this is where the trail goes cold (so to speak). System logs show the following :

Code: [Select]
08      01/06/15 14:49:29.885   JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x31750680>
08      01/06/15 14:49:29.885   JobHandler_LuaUPnP::HandleActionRequest argument Code=local now = os.date("*t")
luup.call_action("urn:event2gcal:serviceId:Event2GCal1", "SetEventDesc", {NewEventDesc= "L'alarme a ?t? correctement d?sactiv?e ? "..tostring(now.hour).." heures "..tostring(now.min).." minutes "..tostring(now.sec).." secondes"},234) <0x31750680>
08      01/06/15 14:49:29.887   JobHandler_LuaUPnP::HandleActionRequest device: 234 service: urn:event2gcal:serviceId:Event2GCal1 action: SetEventDesc <0x31750680>
08      01/06/15 14:49:29.887   JobHandler_LuaUPnP::HandleActionRequest argument NewEventDesc=L'alarme a ?t? correctement d?sactiv?e ? 14 heures 49 minutes 29 secondes <0x31750680>
06      01/06/15 14:49:29.887   Device_Variable::m_szValue_set device: 234 service: urn:event2gcal:serviceId:Event2GCal1 variable: EventDesc was: L'alarme a ?t? correctement d?sactiv?e ? 14 heures 49 minutes 9 secondes now: L'alarme a ?t? correctement d?sactiv?e ? 14 heures 49 minutes 29 secondes #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x31750680>

... but nothing else, I too suspect an error (since it's not using oAuth2) from Google is occurring but we just never see it (lack of debug logs). When I changed the credentials (that's all I did) I got a nice email from Google letting me know they blocked access to my calendar. In conclusion, I looked at the last time developer logged into this site and it's been almost 2 years come the 24th of this month.

I wonder if this plugin was using what I see now (being referred to) as a 'Quick Add' as I don't see parameters for date/time or location of the event - just the event name and description using Google 'english' (e.g. Pick up John Doe at 8:00am today). I foresee a plugin not only being a method for creating events for HA but also logs of information ('John Doe' entered the 'Front Door' at '9:02am' or 'Front Door' camera sensed motion at '9:02am') stored back into the Calendar or alternatively a secondary calendar.

Much appreciated Stuart....

If it's been abandoned then I think it unlikely that it uses the new auth mechanism.  Let me know what you see and I can decide if it makes sense to maybe try to update it or add some functionality into GCal3 or ......
openLuup, AltUI, Zway and HomeWave, enough said...

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCal3 to write events to Calendar
« Reply #6 on: January 06, 2015, 07:05:50 pm »
I will take a look no promise as to how quickly.

I might be able to do something simple like add a service call to GCal3  that does something simple like addEvent and pass in eventName, startdate/time, enddate/time. That would be pretty generic, be able to be called from Luup code and probably satisfy a number of use cases .

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: GCal3 to write events to Calendar
« Reply #7 on: January 06, 2015, 07:22:01 pm »
Thanks again and totally appreciate you taking the time to look at all of this....

I will take a look no promise as to how quickly.

I might be able to do something simple like add a service call to GCal3  that does something simple like addEvent and pass in eventName, startdate/time, enddate/time. That would be pretty generic, be able to be called from Luup code and probably satisfy a number of use cases .
openLuup, AltUI, Zway and HomeWave, enough said...

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCal3 to write events to Calendar
« Reply #8 on: March 05, 2015, 05:48:31 pm »
Later today I will publish a beta version of  GCal3 that will enable calendar events to be created using Lua in scenes and etc

It will be on the main GCal3 board

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: GCal3 to write events to Calendar
« Reply #9 on: March 05, 2015, 05:54:08 pm »
Thanks Stuart, I've really been looking forward to this....

Later today I will publish a beta version of  GCal3 that will enable calendar events to be created using Lua in scenes and etc

It will be on the main GCal3 board
openLuup, AltUI, Zway and HomeWave, enough said...

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: GCal3 to write events to Calendar
« Reply #10 on: March 06, 2015, 01:14:38 am »
I got curious about what the use-case would be for this. Could you give an example what you will be using this for CudaNet?
- Tomas

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: GCal3 to write events to Calendar
« Reply #11 on: March 06, 2015, 02:25:26 pm »
My use case my differ from others but here was my intent.

Create a secondary calendar (read-only) which would be shared with my family. A format (web based) which they can view specific information about my home (including me). They won't have access to Vera (remotely) and sending them emails or notifications would be annoying. So the readable events would be, the time I left work and arrived at the office. The temperature and mode state within the home (each zone). The time the maids entered the house and left. How long the sprinkler system ran (each zone) and at what time - or perhaps it didn't run due to weather or water restrictions. Are my dogs being active or sleeping (via Whistle; IFTTT)  etc. Camera sensed motion by the Garage. Someone rang my doorbell. Think of it as a permanent log whereby I can look back and see what happened that day. You could even write some LUA to read back the days events to you at the click of a button (e.g. Homewave).

Hope that helps..

I got curious about what the use-case would be for this. Could you give an example what you will be using this for CudaNet?
openLuup, AltUI, Zway and HomeWave, enough said...

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: GCal3 to write events to Calendar
« Reply #12 on: March 09, 2015, 01:36:48 am »
That is not a bad idea CudaNet, now I want it to :D
- Tomas

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCal3 to write events to Calendar
« Reply #13 on: March 25, 2015, 02:03:29 pm »
I just released new version of GCal3 to the marketplace - with well tested calendar add feature.

Just for information - I used the calendar add event with 3 different plugins on 3 different calendars (2 on a vera running UI7 and one on a vera running UI5).  I used these to trigger scenes which created different events (some fixed some random) on calendars different to the one the plugin was connected to and sometimes to the same calendar.

This allowed me to really stress test the plugin (found and fixed a few weaknesses - mostly with timing) by exercising the plugin with many many events over days and in both UI5 and UI7.

So just as food for thought:  Can use a calendar event to create an event in the same or different calendar (if using more than one plugin) and can use this as a technique for having one vera trigger another (via the calendar).   This is near-real time (to the minute) because whenever a calendar event is added - if it starts before the plugin would otherwise update - it forces a re-read of the calendar.

Not sure if this will inspire some ideas - but hope so.