The Vera Community forums have moved!

Advanced => Plugins & Plugin Development => Programming => Google Calendar Switch => Topic started by: utz on August 24, 2011, 06:06:01 pm

Title: Google Calendar Switch
Post by: utz on August 24, 2011, 06:06:01 pm
This is all still very beta but maybe someone out there has use for it ...

The idea:
The plugin is a simple switch (similar to a motion detector) which uses a Google Calendar as input. The plugin will check periodically if an event with a particular name is active in the calendar. If such event is currently active the plugin will go to state tripped=1, if not then tripped=0. In addition a variable is set that can be additionally specified in the event and may be used in a scene.

For example, I control my central heating that way. I specify in Google Calendar events throughout the day that are called HEATING_ON. When an event with such name is present the scene running the heating is triggered. I can also specify an event in the form of HEATING_ON{20}. In this case the 20 is extracted and stored in a variable. I use the 20 to override the temperature set-point of the heating (it now will heat to 20 degree and not use the set-point of the room thermostat). Other options would be to use events such as LIGHT_ON or ALARM_ON which could be specified in the same calendar that several instances of the plugin use.

How it works:
The plugin periodically (period defined in I_GCAl.xml in UPDATE_FREQU with 5min as a reasonable value)  contacts a google calendar and requests all calendar events in a window of  UPDATE_FREQU. Google Calendar returns all active events in this period as a JSON output. In that output I look for a keyword defined in the control tab of the plugin (I do not parse the JSON properly, it is just a pattern matching in the output for the keyword). If the keyword is found the plugin goes to the state Tripped.

Install:
1) Get a Google account and setup a calendar. You may want to create a separate calendar instance for the home automation stuff.
2) Click on calendar settings and then click on the XML button at "Private Address". You will now see a link that vera will use as a pointer to access the calendar. Copy this link and change at the start https to http (have not figured out yet how to use https).
3) Install the 4 attached files on vera and create a device using D_GCal.xml
4) Click on the device you created. In the control tab there will be 2 boxes. In the first one you have to insert the link to the calendar (The box is a bit small but it works). Then press set. In the second box you enter the event name you want to use (e.g. HEATING_ON). Then press set.
5) You can use the button "check" to see if events in the calendar are picked up. Otherwise the plugin will check every 5min (this value can be configured).

Let me know if things don't work and I see if I can fix it.

Known issues:
- It works in the UK but there might be problems when located in other timezones (working on it!)
- When pressing the set button it will not blink or something. So it is hard to tell that something happens without user feedback. If someone knows how to fix this I will put it in.
- When you press the set button it will set the variables gcalon and gcallink. You can see the content of these variables on the advanced tab at the bottom (usually after reloading the page). The boxes for setting the link and the keyword are empty even if gcalon and gcallink are set (see in the advanced tab). In other words, variables may be set but they are not shown in the set boxes. Again, who knows how to fix this?
- Arm/Bypass button only works properly after reloading the UI 2 or 3 times.

Version Log:
- v1: initial version
- v2: notifications tab (for henk); larger fields to input link and keyword; changed nill to nil (Ap15e)
- v2b: hopefully fixes the timezone problem (currently under testing)
- v3: added a tab with the calendar to view scheduled events

code has moved to http://code.mios.com/trac/mios_google-calendar-plugin/
Title: Re: Google Calendar Switch
Post by: Henk on August 24, 2011, 06:22:24 pm
GREAT!

Will test this this weekend and get you some feedback!

Thx

- Henk
Title: Re: Google Calendar Switch
Post by: futzle on August 24, 2011, 06:24:13 pm
@utz,

Congratulations on getting your plugin working.  It looks like a great idea.
Title: Re: Google Calendar Switch
Post by: strangely on August 24, 2011, 07:01:18 pm
Thanks, seems like something I could make use of, and may even provide a certain amount of control if cp.mios.com is down perhaps?

I think @guessed was once working on something similar to this with Google calender that could record and play back events?

Title: Re: Google Calendar Switch
Post by: Ap15e on August 24, 2011, 07:07:10 pm
Thanks for sharing your code. Will test the plugin when time permits.
You should replace nill with nil.
Title: Re: Google Calendar Switch
Post by: utz on August 24, 2011, 07:16:30 pm
You should replace nill with nil.

Yes will do. It seems both works so I was never sure what to use.
Title: Re: Google Calendar Switch
Post by: DaveL17 on August 24, 2011, 09:40:29 pm
+1

This could be the start of something fantastic. I've long thought that a calendar interface would be a huge boost for usability and functionality.  Graphic interface, recurring events and it would be fairly easy to simulate random events.

Good luck with this.
Title: Re: Google Calendar Switch
Post by: guessed on August 25, 2011, 01:50:52 am
I think @guessed was once working on something similar to this with Google calender that could record and play back events?
It started with Playback and pseudo natural language expressions in Calendar

ie. Calendar entries with titles of the form:

Set #10 to on    OR
Set #12 to 50%    OR
Run IamHomeScene

would fire off Switch, Dimmer, or Scene events.

...but I haven't worked on it in over a yr as I ran into a bag of problems with the specific CalDAV calls I was making, and how "portable" they were across CalDAV servers (Yahoo, Google, and the one at work).  I was trying using [CalDAV] commands that would let me download a few hours worth to Vera so it could Operate when the Network was down, and there was all sorts of non-compliance for recurring events etc.

Sounds like this one is having more luck using the JSON interfaces.

@utz,
If you're interested in salvaging bits from it, let me know and I'll open the [private] code.mios.com space to you so you can get stuff from it.
Title: Re: Google Calendar Switch
Post by: utz on August 25, 2011, 03:03:02 am
@guessed

Using a language is a nice idea as it makes a very flexible system. I experimented with this as well and looked at putting Lua code directly in the event description. However, my intention was to create a simple shared calendar that family members can use to have some control over the house (without the need to deal with the vera UI). So I decided to make it relatively simple. The only one that would use complex programing  via the calendar would be me and I can do that stuff via vera directly.

I also had several tries before this somewhat worked. I first started with the ICAl format and wrote a parser for this. The idea was to poll a calendar once a day and then operate on the events locally (to avoid constant calendar queries). That exploded in complexity and was just not feasible  (I found some of your posts where the CalDav is discussed and that seemed to be similarly complex). So now the plugin queries the calendar every few minutes which is not very efficient (in terms of network traffic). However, that way all the work is on googles side in terms of figuring out if something is scheduled or not. The solution now is ugly but simple to implement and works.

Some things I came across and was wondering if anyone has an answer: Obviously, vera uses JSON and XML and there must be a parser for it on the system. Is there a way to use these parsers from Lua. It seems to me a bit silly to install a JSON parser for Lua while there must be one on the system already.
Title: Re: Google Calendar Switch
Post by: futzle on August 25, 2011, 05:50:04 am
Is there a way to use these parsers from Lua. It seems to me a bit silly to install a JSON parser for Lua while there must be one on the system already.

It looks like lxp (http://matthewwild.co.uk/projects/luaexpat/lom.html) is installed.  Amazingly, there isn't a JSON parser library on my Vera.
Title: Re: Google Calendar Switch
Post by: Ap15e on August 25, 2011, 06:06:31 am
utz,

You're right, it doesn't matter whether you're using nill or nil - as long as you don't inizialize the variable nill ...  :)
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 07:14:15 am
@utz

Whats not working with the https? Vera is unable to build the SSL connection?
What kind of error messages are you getting.

Just asking so i wont run into any unexpected thng when im going to try this out and i can report back with usuable feedback.

- Henk

Install:
1) Get a Google account and setup a calendar. You may want to create a separate calendar instance for the home automation stuff.
2) Click on calendar settings and then click on the XML button at "Private Address". You will now see a link that vera will use as a pointer to access the calendar. Copy this link and change at the start https to http (have not figured out yet how to use https).
3) Install the 4 attached files on vera and create a device using D_GCal.xml
4) Click on the device you created. In the control tab there will be 2 boxes. In the first one you have to insert the link to the calendar (The box is a bit small but it works). Then press set. In the second box you enter the event name you want to use (e.g. HEATING_ON). Then press set.
5) You can use the button "check" to see if events in the calendar are picked up. Otherwise the plugin will check every 5min (this value can be configured).
Title: Re: Google Calendar Switch
Post by: utz on August 25, 2011, 07:18:44 am
Henk,

I just could not see in the documentation if luup.inet.wget can do https (only mentions http) or not so I never tried. Maybe it just works.
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 07:25:12 am
@utz,

We have seen that Vera does not support ssl nativly.
Here: http://forum.mios.com/index.php?topic=6665.0
And here: http://forum.mios.com/index.php?topic=6727.0

So im assuming you are right. I will try anyway and let you know the results!

- Henk
Henk,

I just could not see in the documentation if luup.inet.wget can do https (only mentions http) or not so I never tried. Maybe it just works.
Title: Re: Google Calendar Switch
Post by: guessed on August 25, 2011, 09:47:15 am
It does, you use LuaSec to initiate https calls and it's preinstalled. Will likely be faster/better than using wget since it won't launch processes and create all those temp files.

Ie. Less work for the little box.

It's SSL/TLS (for SMTP) that it has difficulty with, since the smtp drivers weren't modular enough to hook LuaSec into.
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 09:52:03 am
@guessed

Thx for the clarification! I was not aware of that. Sounds like a good alterntive then as well as more secure!

- Henk

It does, you use LuaSec to initiate https calls and it's preinstalled. Will likely be faster/better than using wget since it won't launch processes and create all those temp files.

Ie. Less work for the little box.

It's SSL/TLS (for SMTP) that it has difficulty with, since the smtp drivers weren't modular enough to hook LuaSec into.
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 10:19:42 am
4) Click on the device you created. In the control tab there will be 2 boxes. In the first one you have to insert the link to the calendar (The box is a bit small but it works). Then press set. In the second box you enter the event name you want to use (e.g. HEATING_ON). Then press set.
After entering the Calendar Link and clicking set & then the Calendar Keyword and pressing set.

Should the information continue to display in these boxes after closing the device page?

Going back to the boxes, they are empty.

JOD.
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 10:21:54 am
@JOD,

What happens if you change one (1) box only and save?

- Henk
4) Click on the device you created. In the control tab there will be 2 boxes. In the first one you have to insert the link to the calendar (The box is a bit small but it works). Then press set. In the second box you enter the event name you want to use (e.g. HEATING_ON). Then press set.
After entering the Calendar Link and clicking set & then the Calendar Keyword and pressing set.

Should the information continue to display in these boxes after closing the device page?

Going back to the boxes, they are empty.

JOD.
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 10:30:29 am
What happens if you change one (1) box only and save?
After setting either or both boxes, neither box has content after leaving the "Control" page.
Does yours stay?

JOD.
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 10:45:47 am
@JOD & @utz

Correct, in 1338 (the version im using) im seeing the same.
I cannot enter and save the box's contents.

Not 1, not the other and not both. It seems the "set" box is not clickable although the "hand" shows its linked.

Anyone else got it up and running follwing the installsteps here?
http://forum.mios.com/index.php?topic=7558.msg48518#msg48518

Ive tried it with http and with https, both no go...

- Henk
What happens if you change one (1) box only and save?
After setting either or both boxes, neither box has content after leaving the "Control" page.
Does yours stay?

JOD.
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 10:53:09 am
I'm going to assume the boxes default to empty.
Both the Link and the Keyword are present in the gcallink & gcalon boxes under the Advanced tab. So at least they did actually set.

However, since both these entries are a one time set and forget type of thing, I dont see why the boxes would not just keep the entry as entered, until changed. 

JOD.
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 11:01:07 am
It took me about 5 or 6 luaengine reloads to get the fields populated at all.
All entries are there now and i can actually arm/bypass the device.

Now on for some more testing ( i was holding off untill this w/e, but i got stuck in now anyway :))

- Henk
I'm going to assume the boxes default to empty.
Both the Link and the Keyword are present in the gcallink & gcalon boxes under the Advanced tab. So at least they did actually set.

However, since both these entries are a one time set and forget type of thing, I dont see why the boxes would not just keep the entry as entered, until changed. 

JOD.
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 11:10:27 am
More assumptions.. ;D
With an 11:00 - 2:00pm calendar entry, Is it safe to say the tripped event has a 5min window (based on the default setting) before triggering? 11:00 - 11:05?
My event did not trip during this period.....But still testing.

Based on the above "Appointment" should the tripped event reset somewhere between 2:00 - 2:05?

JOD.
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 11:14:08 am
I created an event (at 05:03 pm) that runs from 0500 to 0600pm and the check button does not pick it up. Im running with the proposed http setting now.

the check button doesnt trip the device.

Where/how can i change the timing of 5 minutes?
[feature request] add this as a variable to the control page?

will now try to create an event that starts in the future.
Also im going to set it up with notifications so i know when it triggers without staring at the GUI all day :P

- Henk

- edit -
After setting up notifications i got an immediate message that the event triggerd.
BUT.... i dont see the red man.... strange.

I have doublechecked syntax for both the xml entry as well as the keyword, they check out.

Have now set a future event for 7pm that lasts for an hour... lets see what happens.
More assumptions.. ;D
With an 11:00 - 2:00pm calendar entry, Is it safe to say the tripped event has a 5min window (based on the default setting) before triggering? 11:00 - 11:05?
My event did not trip during this period.....But still testing.

Based on the above "Appointment" should the tripped event reset somewhere between 2:00 - 2:05?

JOD.

Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 11:24:26 am
@Henk,

Double check your Keyword, make sure it matches the calendar entry. I clicked "Check" and the device tripped, however, it's still tripped. How does one reset it?
Ok, deleted the calendar entry and clicked check again, It reset.
*Feature request* A reset button on the control page.

Another assumption is that the calendar entry needs to be outside that "5 minute" window.

*Edit. To change the Keyword, you have to reload / save.

JOD.
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 11:30:20 am
@JOD

I doublechecked and edited my entry below.
As for reset. I would asume it resets after the event stopped and the first "check" finds the event is not there anymore. So allow it for 5 minutes max to "discover"  the changed status.

- Henk

I clicked "Check" and the device tripped, however, it's still tripped. How does one reset it? Ok, deleted the calendar entry and clicked check again, It reset.
*Feature request* A reset button on the control page.
JOD.
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 11:42:05 am
As for reset. I would asume it resets after the event stopped and the first "check" finds the event is not there anymore.
Understood, but if the "Check" checks for a future event and trips, does it stay tripped until the first event expires?
Does "Check" only check the validity of the 'Keyword" for the first calendar event?

I did just get a calendar trip condition. Very cool. Now waiting for the event expiration reset.

If you edited the Keyword, you have to reload, then check the Advanced tabs gcalon box.

*Edit. Reset occured 4 minutes after the event expiration.
Nice work @utz, this is really cool..

JOD.

Title: Re: Google Calendar Switch
Post by: utz on August 25, 2011, 11:48:05 am
Hi,

- when you press the set button it will set the variables gcalon and gcallink. You can see the content of these variables on the advanced tab at the bottom (usually after reloading the page).
- when pressing a button it will not blink or something. So it is hard to tell that something happens without user feedback. If someone knows how to fix this I will put it in. You can look at the logfile on vera, debug output will tell you if the button was pressed (I know, thats note a mode for usual operation)
- the boxes for the link and the keyword are empty. It would be nice to show there always the current set gcalon and gcallink variable. Again I dont know how to do this. If someone knows how to do this I add it.

.... sorry, as I said all a bit beta.
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 11:51:10 am
@utz

Dont be sorry!!! Its a GREAT plugin and it just needs some work...
We are just trying to be helpfull.

Keep it up!!!

- Henk
Hi,

- when you press the set button it will set the variables gcalon and gcallink. You can see the content of these variables on the advanced tab at the bottom (usually after reloading the page).
- when pressing a button it will not blink or something. So it is hard to tell that something happens without user feedback. If someone knows how to fix this I will put it in. You can look at the logfile on vera, debug output will tell you if the button was pressed (I know, thats note a mode for usual operation)
- the boxes for the link and the keyword are empty. It would be nice to show there always the current set gcalon and gcallink variable. Again I dont know how to do this. If someone knows how to do this I add it.

.... sorry, as I said all a bit beta.
Title: Re: Google Calendar Switch
Post by: utz on August 25, 2011, 11:51:19 am
As for reset. I would asume it resets after the event stopped and the first "check" finds the event is not there anymore.
Understood, but if the "Check" checks for a future event and trips, does it stay tripped until the first event expires?
Does "Check" only check the validity of the 'Keyword" for the first calendar event?

I did just get a calendar trip condition. Very cool. Now waiting for the event expiration reset.

If you edited the Keyword, you have to reload, then check the Advanced tabs gcalon box.

*Edit. Reset occured 4 minutes after the event expiration.
Nice work @utz, this is really cool..

JOD.



The check button simply triggers the function that is normally called by timer every 5min. If there is an event in the calendar at the time you press the button the red man comes on. If there is no event at the time the man goes blue. The button is essentially for people like me that cant wait 5min while testing the setup.
Title: Re: Google Calendar Switch
Post by: utz on August 25, 2011, 11:59:20 am
It took me about 5 or 6 luaengine reloads to get the fields populated at all.
All entries are there now and i can actually arm/bypass the device.

Yes I observed this as well and I have the same problem with other plugins (also ones that other people coded). I really would like to know how to get rid of this problem.

However, since both these entries are a one time set and forget type of thing, I dont see why the boxes would not just keep the entry as entered, until changed. 

Thats what I want as well I just do not know how to do this. I assume I need to change something in the .json file to achieve that. Its very annoying that it does not show the variables there.

 
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 12:16:24 pm
@utz,

It's not a big deal, as long as the user knows to click *Save* and check the Advanced tab, which now they do.
In my situation, since I didn't see that it saved the first time, I entered the keyword a second time, only different than the first, which now didn't match the Google entry...Which didnt trip the event..

Anyway, I'm new to Google Calendar and in the process now of setting it up on my iPhone and had a few thoughts.  

Is it possible to have multiple instances of the device, and use different keywords?
This would be great for those with rental properties

Or, being able to use two Keywords with each device, one to trip, and one to reset?

Are there additional ways to create/delete the calendar events?
Via email maybe?

JOD.

*Edit. "Check" checks within the next 5hrs for an event
Title: Re: Google Calendar Switch
Post by: utz on August 25, 2011, 01:22:46 pm
Is it possible to have multiple instances of the device, and use different keywords?
This would be great for those with rental properties

yes that should work (i have not tested it)

Or, being able to use two Keywords with each device, one to trip, and one to reset?

That was my initial design. However, I changed it so that when no event is present it switches it actively off.

Are there additional ways to create/delete the calendar events?
Via email maybe?

Whatever ways google provides to get events set can be used. I am not sure if you can set an event via mail.

*Edit. "Check" checks within the next 5hrs for an event

Not sure what you mean. You could change the time window in which to look for an event (e.g. see if there is anything in the next 5h and switch then on.
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 01:29:36 pm
*Edit. "Check" checks within the next 5hrs for an event
Quote
Not sure what you mean. You could change the time window in which to look for an event (e.g. see if there is anything in the next 5h and switch then on.
What I meant was. If there is a calendar event within the next 5hrs, "Check" returns a tripped condition. If the event is 5.5hrs out, it wont trip. So the "Check" button will return true for any event within the next 5hrs.

JOD.
Title: Re: Google Calendar Switch
Post by: utz on August 25, 2011, 01:34:11 pm
*Edit. "Check" checks within the next 5hrs for an event
Quote
Not sure what you mean. You could change the time window in which to look for an event (e.g. see if there is anything in the next 5h and switch then on.
What I meant was. If there is a calendar event within the next 5hrs, "Check" returns a tripped condition. If the event is 5.5hrs out, it wont trip. So the "Check" button will return true for any event within the next 5hrs.

JOD.

yep that could be done introducing an additional variable (for look ahead time). Hard coded that is done quickly; to be set via UI would need another box.
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 01:38:49 pm
No need for the additional variable. That's the way it works now, as default.

JOD.
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 02:50:03 pm
@utz

[feature request]

could you include the code for the "virtual device" as provided here:
http://forum.mios.com/index.php?topic=6650.msg47521#msg47521

That would actually make the device to be reckognized as a sensor
Also then the notification tab would become available so one doesnt have to run a scene to be notificated.

And still, the variable for timeintervals that the device uses to check the calendar (default 6 minutes) to be available as a user definabel box would be GREAT.

- Henk
Title: Re: Google Calendar Switch
Post by: utz on August 25, 2011, 03:55:21 pm
@utz

[feature request]

could you include the code for the "virtual device" as provided here:
http://forum.mios.com/index.php?topic=6650.msg47521#msg47521

That would actually make the device to be reckognized as a sensor
Also then the notification tab would become available so one doesnt have to run a scene to be notificated.

I added a new version (first post) that has a notifications tab (not tested). As I understand the "virtual device" is a switch that can indicate if someone is there or not. It should be possible to mimic this by the device as is (maybe I did not quite get it)

@utz
And still, the variable for timeintervals that the device uses to check the calendar (default 6 minutes) to be available as a user definabel box would be GREAT.

yep I will put this in tomorrow but I think I wont find time tonight ...
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 04:12:33 pm
@Henk,

There is an event drop down box for when:
"A calendar event is active"
and
"An armed calendar event is active"

What's your thinking with the Ping Sensor?
Being able to trigger events based on the GCS status of not tripped / "No calendar event" ?

JOD.

*Edit. After creating a 2nd instance of the GCS, I've tried repeatedly (over the past hour) to get the Link & Keyword to set, maybe it's not possible to have two active GCS devices?
Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 06:15:45 pm
@JOD

Not the pingsensor, the statedevice.
This plugin is more or less controlled by a calendar instead of manually like the statedevice, which makes it much more functional and gives it more practical uses.

Also my suggestion to add/borrough code from the state device would make it more "compatible" as it shows up as either a binary switch or a fully supported motion sensor. FI currently ivera doesnt "support" the plugin because it cannot classify it as either a switch or a sensor.

As for my single instance, i cant get it to trigger, so ill remove it tomorrow and try @utz new version. must be something im doing wrong at my end.

@utz, many many compliments on your hard work and putting up with our whining remarks on what could be improved.... ::)

@Henk,

There is an event drop down box for when:
"A calendar event is active"
and
"An armed calendar event is active"

What's your thinking with the Ping Sensor?
Being able to trigger events based on the GCS status of not tripped / "No calendar event" ?

JOD.

*Edit. After creating a 2nd instance of the GCS, I've tried repeatedly (over the past hour) to get the Link & Keyword to set, maybe it's not possible to have two active GCS devices?
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 06:52:49 pm
Sorry....
State Device not PS. Doh....

I'm sure you've already checked that the Private Link (HTTP no S) and the Keyword in the device match the Google Calendar?

JOD.



Title: Re: Google Calendar Switch
Post by: Henk on August 25, 2011, 07:00:44 pm
Thrice....

Ill report back tomorrow after setting up the latest version from scratch

- Henk

Sorry....
State Device not PS. Doh....

I'm sure you've already checked that the Private Link (HTTP no S) and the Keyword in the device match the Google Calendar?

JOD.




Title: Re: Google Calendar Switch
Post by: utz on August 25, 2011, 07:12:29 pm
@Henk

for debugging I suggest:
1) ssh into vera
2) on command line start logging with: VerboseLogging.sh enable
3) in /var/log/cmh start: tail -f LuaUPnP.log | grep GCAL
4) you should see something like:
Code: [Select]
50 08/26/11 0:05:26.549 luup_log:67: GCAL: check calendar
50 08/26/11 0:05:26.550 luup_log:67: GCAL: checking google calendar
50 08/26/11 0:05:26.875 luup_log:67: GCAL: query url: http://www.google.com/calendar/feeds/XXXXXXXXXXX@group.calendar.google.com/private-eXXXXXXXXXX1237/basic?alt=json&fields=entry/title&start-min=2011-08-25T23:05:26&start-max=2011-08-25T23:10:56
50 08/26/11 0:05:26.877 luup_log:67: GCAL: query status: 0
50 08/26/11 0:05:26.877 luup_log:67: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$gd":"http://schemas.google.com/g/2005"}}
50 08/26/11 0:05:26.878 luup_log:67: GCAL: no event with name HEATING_ON is currently active

Especially the line with "query status:" should show a 0 indicating something came back from the server
Title: Re: Google Calendar Switch
Post by: JOD on August 25, 2011, 08:56:13 pm
The 2nd instance of the GCS device is up and running, it has the same Link as the 1st but different Keyword but it's not playing nice with the 1st GCS device.

Even though there is a 3hr separation between devices in the calendar, the 2nd device turns on a second after the first.
The expiration of each event turns off the relevant device as expected.

JOD.
Title: Re: Google Calendar Switch
Post by: utz on August 26, 2011, 03:35:18 am
The 2nd instance of the GCS device is up and running, it has the same Link as the 1st but different Keyword but it's not playing nice with the 1st GCS device.

Even though there is a 3hr separation between devices in the calendar, the 2nd device turns on a second after the first.
The expiration of each event turns off the relevant device as expected.

JOD.


Strange. Do you use 2 keywords that are similar (one as a substring of the other?). Could you send me the debug output of the on and off events as described above? I will try to reproduce this over the weekend and see where the bug might be.

I just checked with 2 instances of the device on one calendar and for me it worked. I used HEATING_ON as keyword for one and ALARM_ON as keyword for the other.
Title: Re: Google Calendar Switch
Post by: JOD on August 26, 2011, 10:17:41 am
Quote
Do you use 2 keywords that are similar
Yes, they were similar. Vera 1 & Vera #XXXX
I’m changing the Keywords and will test it again.

Quote
I used HEATING_ON as keyword for one and ALARM_ON as keyword for the other.
What if you used HEATING_OFF for the 2nd instance?

JOD.
Title: Re: Google Calendar Switch
Post by: utz on August 26, 2011, 10:23:00 am
Quote
Do you use 2 keywords that are similar
Yes, they were similar. Vera 1 & Vera #XXXX
I’m changing the Keywords and will test it again.

Quote
I used HEATING_ON as keyword for one and ALARM_ON as keyword for the other.
What if you used HEATING_OFF for the 2nd instance?

JOD.

Something like HEATING_ON and HEATING_OFF would work
Something like HEATING and HEATING_ON would be a bad idea as the first is a substring of the second.

To avoid that I would need to code a proper JSON parser instead of just matching strings but I am lazy.
 
Title: Re: Google Calendar Switch
Post by: JOD on August 26, 2011, 10:48:10 am
I was hoping to use this as a means of toggling the "Away" scene for both my wife and me.

Test 1.
Using a 1hr calendar separation:
Device 1. gcalon = Husband
Device 2. gcalon = Wife
Both devices turn on at the same time (first calendar appointment)

2nd test.
2hr calendar separation:
Device 1. gcalon = HEATING_ON
Device 1. gcalon = HEATING_OFF
Both devices turn on at the same time (first calendar appointment)


Quote
but I am lazy
No problem.  ;D

JOD.
Title: Re: Google Calendar Switch
Post by: utz on August 26, 2011, 11:19:42 am
@jod

can you try to create the debug output as described in post #42.

It must be something simple. It did not happen in my setup.
Title: Re: Google Calendar Switch
Post by: Henk on August 26, 2011, 12:00:44 pm
@utz

Short feedback o notification tab in version 2

(UI5 gives much better device installation response by the way, only 1 lua restart needed to populate the device).

I found that the notifications tab is there, but i cannot hookup notifications to anything.
The pulldown menu is empty.

- Henk
Title: Re: Google Calendar Switch
Post by: JOD on August 26, 2011, 12:03:06 pm
This is the 2nd test scenario from my last post and after the expiration of the 1st appointment (Heating_ON) 10:40am - 10:55am. This device is currently idle.

2nd upcoming appointment (device #2) HEATING_OFF scheduled for 12:05PM - 1:05PM is currently active. I'm posting this at 12:00 but the time was 11:38 at the time of the log.

If you want, I can do a "pending" appointment printout?

Code: [Select]
^X50 08/26/11 11:38:40.010 luup_log:18: GCAL: checking google calendar <0x402>
50 08/26/11 11:38:40.397 luup_log:18: GCAL: query url: http://www.google.com< Private Key>
50 08/26/11 11:38:40.399 luup_log:18: GCAL: query status: 0 <0x402>
50 08/26/11 11:38:40.400 luup_log:18: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:38:40.401 luup_log:18: GCAL: an event with name HEATING_OFF is currently active <0x402>
50 08/26/11 11:38:40.405 luup_log:18: GCAL: no value attached <0x402>
50 08/26/11 11:38:40.412 luup_log:20: GCAL: checking google calendar <0x402>
50 08/26/11 11:38:40.912 luup_log:20: GCAL: query url: http://www.google.com< Private Key>
50 08/26/11 11:38:40.914 luup_log:20: GCAL: query status: 0 <0x402>
50 08/26/11 11:38:40.915 luup_log:20: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:38:40.916 luup_log:20: GCAL: no event with name HEATING_ON is currently active <0x402>

JOD.
Title: Re: Google Calendar Switch
Post by: Henk on August 26, 2011, 12:52:57 pm
@utz

Ok more feedback.

The "check"  button doesnt work for me, no response other than the one i PM ed you.

This is the "5 minute timer" feedback from the tailcommand:

Quote

tail -f /var/log/cmh/LuaUPnP.log | grep GCAL
50      08/26/11 18:47:18.019   luup_log:36: GCAL: checking google calendar <0x4                                              02>
50      08/26/11 18:47:18.381   luup_log:36: GCAL: query url: http://www.google.                                              com/calendar/feeds/my.email@gmail.com/private-xxxxxxxxxxxxxxxxx/basic?alt=json&fields=entry/title&start-min=2011-08-26T16:47:18&start-max=201                                              1-08-26T15:51:28 <0x402>
50      08/26/11 18:47:18.382   luup_log:36: GCAL: query status: 0 <0x402>
50      08/26/11 18:47:18.383   luup_log:36: GCAL: query result: {"version":"1.0                                              ","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$gd":"h                                              ttp://schemas.google.com/g/2005"}} <0x402>
50      08/26/11 18:47:18.384   luup_log:36: GCAL: no event with name TEST is cu                                              rrently active <0x402>

I really am surprised at the www.wr.org url ... and somehow the event (that is there) is not reckognized... i checked the private calender xml string over and over... its correct.

- Henk
Title: Re: Google Calendar Switch
Post by: utz on August 26, 2011, 01:34:19 pm
@Henk,

when I look at the url query url I can see the following two parameters:
start-min=2011-08-26T16:47:18
and
start-max=2011-08-26T15:51:28

The plugin is asking to look for events in a time window where the start window time is after the end window time which obviously returns no events. It should be something like:
start-min=2011-08-26T16:47:18
and
start-max=2011-08-26T16:52:28

This has probably to do with the time zones and how lua converts handles time calls. I live in the UK and there is normally nothing to be added to times. If you sit in the netherlands (a guess) then we have that 1h difference to UTC (which google wants).

I have to look at this a bit and see if I can puzzle together what to do for different time zones .... 
Title: Re: Google Calendar Switch
Post by: Henk on August 26, 2011, 01:53:35 pm
@utz

Good guess i am in the Netherlands at GMT +1 (summertime +2)
If you need more logs, let me know.

I have tried setting up a special group calender for Vera witht the same results.
Also it sounds logical what you are saying... i hve always used short test events that wer never longer than 1 hour so the timedifference would never have been compensated, thus the alarm wouldnever trigger.

Good team like this!

- Henk



@Henk,

when I look at the url query url I can see the following two parameters:
start-min=2011-08-26T16:47:18
and
start-max=2011-08-26T15:51:28

The plugin is asking to look for events in a time window where the start window time is after the end window time which obviously returns no events. It should be something like:
start-min=2011-08-26T16:47:18
and
start-max=2011-08-26T16:52:28

This has probably to do with the time zones and how lua converts handles time calls. I live in the UK and there is normally nothing to be added to times. If you sit in the netherlands (a guess) then we have that 1h difference to UTC (which google wants).

I have to look at this a bit and see if I can puzzle together what to do for different time zones .... 

Title: Re: Google Calendar Switch
Post by: utz on August 26, 2011, 02:09:14 pm
@JOD
can the timezone issue be your problem as well? You cut this part of in your logfile.

@Henk
Google wants to have the query in UTC. For me in the UK that means that for an event in google calendar at 6pm I have to send a query for 5pm. So, if it is 6pm and the plugin runs I use t = os.date('!*t') to get on vera the UTC time for my query (which is 5pm; this value is start-min in the query). This seems to work for you as well Henk (I think, to UTC you have 2h diff). Then I have to add 5min to this time for the start max. This is where you Henk loose an hour somehow. Why I dont know yet. I will investigate.
Title: Re: Google Calendar Switch
Post by: JOD on August 26, 2011, 02:48:47 pm
@JOD
can the timezone issue be your problem as well?
I dont think so.
Quote
You cut this part of in your logfile.
I'm having to do it over a VNC connection (no refresh) but it looked to be the entire logfile at the time.

Code: [Select]
^X50 08/26/11 11:38:40.010 luup_log:18: GCAL: checking google calendar <0x402>
50 08/26/11 11:38:40.397 luup_log:18: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:38:40&start-max=2011-08-26T20:43:40 <0x402>
50 08/26/11 11:38:40.399 luup_log:18: GCAL: query status: 0 <0x402>
50 08/26/11 11:38:40.400 luup_log:18: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:38:40.401 luup_log:18: GCAL: an event with name HEATING_OFF is currently active <0x402>
50 08/26/11 11:38:40.405 luup_log:18: GCAL: no value attached <0x402>
50 08/26/11 11:38:40.412 luup_log:20: GCAL: checking google calendar <0x402>
50 08/26/11 11:38:40.912 luup_log:20: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:38:40&start-max=2011-08-26T20:43:40 <0x402>
50 08/26/11 11:38:40.914 luup_log:20: GCAL: query status: 0 <0x402>
50 08/26/11 11:38:40.915 luup_log:20: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:38:40.916 luup_log:20: GCAL: no event with name HEATING_ON is currently active <0x402>
50 08/26/11 11:43:40.010 luup_log:18: GCAL: checking google calendar <0x402>
50 08/26/11 11:43:40.407 luup_log:18: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:43:40&start-max=2011-08-26T20:48:40 <0x402>
50 08/26/11 11:43:40.408 luup_log:18: GCAL: query status: 0 <0x402>
50 08/26/11 11:43:40.409 luup_log:18: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:43:40.410 luup_log:18: GCAL: an event with name HEATING_OFF is currently active <0x402>
50 08/26/11 11:43:40.415 luup_log:18: GCAL: no value attached <0x402>
50 08/26/11 11:43:40.421 luup_log:20: GCAL: checking google calendar <0x402>
50 08/26/11 11:43:40.749 luup_log:20: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:43:40&start-max=2011-08-26T20:48:40 <0x402>
50 08/26/11 11:43:40.750 luup_log:20: GCAL: query status: 0 <0x402>
50 08/26/11 11:43:40.751 luup_log:20: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:43:40.752 luup_log:20: GCAL: no event with name HEATING_ON is currently active <0x402>
50 08/26/11 11:48:40.009 luup_log:18: GCAL: checking google calendar <0x402>
50 08/26/11 11:48:40.304 luup_log:18: GCAL: query url: http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:48:40&start-max=2011-08-26T20:53:40 <0x402>
50 08/26/11 11:48:40.305 luup_log:18: GCAL: query status: 0 <0x402>
50 08/26/11 11:48:40.306 luup_log:18: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:48:40.307 luup_log:18: GCAL: an event with name HEATING_OFF is currently active <0x402>
50 08/26/11 11:48:40.312 luup_log:18: GCAL: no value attached <0x402>
50 08/26/11 11:48:40.318 luup_log:20: GCAL: checking google calendar <0x402>
50 08/26/11 11:48:40.646 luup_log:20: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:48:40&start-max=2011-08-26T20:53:40 <0x402>
50 08/26/11 11:48:40.647 luup_log:20: GCAL: query status: 0 <0x402>
50 08/26/11 11:48:40.648 luup_log:20: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:48:40.649 luup_log:20: GCAL: no event with name HEATING_ON is currently active <0x402>
50 08/26/11 11:53:40.009 luup_log:18: GCAL: checking google calendar <0x402>
50 08/26/11 11:53:40.292 luup_log:18: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:53:40&start-max=2011-08-26T20:58:40 <0x402>
50 08/26/11 11:53:40.293 luup_log:18: GCAL: query status: 0 <0x402>
50 08/26/11 11:53:40.294 luup_log:18: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:53:40.295 luup_log:18: GCAL: an event with name HEATING_OFF is currently active <0x402>
50 08/26/11 11:53:40.300 luup_log:18: GCAL: no value attached <0x402>
50 08/26/11 11:53:40.306 luup_log:20: GCAL: checking google calendar <0x402>
50 08/26/11 11:53:40.721 luup_log:20: GCAL: query url: http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:53:40&start-max=2011-08-26T20:58:40 <0x402>
50 08/26/11 11:53:40.723 luup_log:20: GCAL: query status: 0 <0x402>
50 08/26/11 11:53:40.724 luup_log:20: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:53:40.725 luup_log:20: GCAL: no event with name HEATING_ON is currently active <0x402>
50 08/26/11 11:58:40.015 luup_log:18: GCAL: checking google calendar <0x402>
50 08/26/11 11:58:40.313 luup_log:18: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:58:40&start-max=2011-08-26T21:03:40 <0x402>
50 08/26/11 11:58:40.314 luup_log:18: GCAL: query status: 0 <0x402>
50 08/26/11 11:58:40.315 luup_log:18: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:58:40.316 luup_log:18: GCAL: an event with name HEATING_OFF is currently active <0x402>
50 08/26/11 11:58:40.321 luup_log:18: GCAL: no value attached <0x402>
50 08/26/11 11:58:40.327 luup_log:20: GCAL: checking google calendar <0x402>
50 08/26/11 11:58:40.672 luup_log:20: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T15:58:40&start-max=2011-08-26T21:03:40 <0x402>
50 08/26/11 11:58:40.673 luup_log:20: GCAL: query status: 0 <0x402>
50 08/26/11 11:58:40.674 luup_log:20: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 11:58:40.675 luup_log:20: GCAL: no event with name HEATING_ON is currently active <0x402>
50 08/26/11 12:03:40.015 luup_log:18: GCAL: checking google calendar <0x402>
50 08/26/11 12:03:40.410 luup_log:18: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T16:03:40&start-max=2011-08-26T21:08:40 <0x402>
50 08/26/11 12:03:40.411 luup_log:18: GCAL: query status: 0 <0x402>
50 08/26/11 12:03:40.412 luup_log:18: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 12:03:40.413 luup_log:18: GCAL: an event with name HEATING_OFF is currently active <0x402>
50 08/26/11 12:03:40.418 luup_log:18: GCAL: no value attached <0x402>
50 08/26/11 12:03:40.424 luup_log:20: GCAL: checking google calendar <0x402>
50 08/26/11 12:03:40.836 luup_log:20: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T16:03:40&start-max=2011-08-26T21:08:40 <0x402>
50 08/26/11 12:03:40.837 luup_log:20: GCAL: query status: 0 <0x402>
50 08/26/11 12:03:40.838 luup_log:20: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 12:03:40.839 luup_log:20: GCAL: no event with name HEATING_ON is currently active <0x402>
50 08/26/11 12:08:40.017 luup_log:18: GCAL: checking google calendar <0x402>
50 08/26/11 12:08:40.365 luup_log:18: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T16:08:40&start-max=2011-08-26T21:13:40 <0x402>
50 08/26/11 12:08:40.367 luup_log:18: GCAL: query status: 0 <0x402>
50 08/26/11 12:08:40.368 luup_log:18: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 12:08:40.369 luup_log:18: GCAL: an event with name HEATING_OFF is currently active <0x402>
50 08/26/11 12:08:40.373 luup_log:18: GCAL: no value attached <0x402>
50 08/26/11 12:08:40.380 luup_log:20: GCAL: checking google calendar <0x402>
50 08/26/11 12:08:40.803 luup_log:20: GCAL: query url:  http://www.google.com<Private Key>=json&fields=entry/title&start-min=2011-08-26T16:08:40&start-max=2011-08-26T21:13:40 <0x402>
50 08/26/11 12:08:40.804 luup_log:20: GCAL: query status: 0 <0x402>
50 08/26/11 12:08:40.805 luup_log:20: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","entry":[{"title":{"$t":"HEATING_OFF","type":"html"}}]}} <0x402>
50 08/26/11 12:08:40.806 luup_log:20: GCAL: no event with name HEATING_ON is currently

JOD.
Title: Re: Google Calendar Switch
Post by: utz on August 26, 2011, 03:03:53 pm
@JOD

your logfile has the lines:
GCAL: query url http://www.google.com/<Private Key>

I would need to know what is added at the end of <Private Key> (the start-min start-max values)
Title: Re: Google Calendar Switch
Post by: JOD on August 26, 2011, 03:06:55 pm
Ok, I see it now. Give me a minute to delete the private key lines and I will apend the previous post with the updated data.

JOD.
Title: Re: Google Calendar Switch
Post by: utz on August 26, 2011, 03:18:13 pm
@henk

could you try the attached version to see if this fixes the problem (I do not want to change time zones on my system for testing as it would probably screw up everything).

Title: Re: Google Calendar Switch
Post by: Henk on August 26, 2011, 03:22:17 pm
@utz

Sure, no problem, while you were debugging, i was thinking...
Would a functon help where a user would enter his deviation from UTC as a variable?

Will let you know if it works!

- Henk
@henk

could you try the attached version to see if this fixes the problem (I do not want to change time zones on my system for testing as it would probably screw up everything).


Title: Re: Google Calendar Switch
Post by: utz on August 26, 2011, 03:52:40 pm
@utz

Sure, no problem, while you were debugging, i was thinking...
Would a functon help where a user would enter his deviation from UTC as a variable?

All systems should know already how far they are of UTC as we all set timezone and time ...
Title: Re: Google Calendar Switch
Post by: JOD on August 26, 2011, 04:02:46 pm
@Henk,

In Google Calendar, it shows the time offset from GMT.
See attachement.

JOD.
Title: Re: Google Calendar Switch
Post by: utz on August 29, 2011, 01:53:15 pm
Added a tab with embedded google calendar to see the scheduled events in UI4.

(you need to use set link again for it to work; in case you upgrade from an existing version of the plugin)
Title: Re: Google Calendar Switch
Post by: m0jon on September 01, 2011, 11:07:52 am
OK i think i'm getting there slowly!!!!

I've added the plugin and linked it to my google calendar and the little red man appears and i get email notifications. However it does not switch the kitchen light on!!!

My keyword is Kitchen_Light my calendar event is called Kitchen_Light and i've named my kitchen light Kitchen_Light. I've got a scene which switches on the kitchen light and named that Kitchen_Light but still nothing. Any ideas where i have gone wrong?

Cheers

m0jon
Title: Re: Google Calendar Switch
Post by: strangely on September 01, 2011, 11:29:07 am
You'll also need to set up an "event" in the scene you want to trigger.
Title: Re: Google Calendar Switch
Post by: m0jon on September 01, 2011, 11:37:55 am
@strangely

Thanks for your reply. A case of can't see the wood for the trees!!!

Cheers
Title: Re: Google Calendar Switch
Post by: utz on September 02, 2011, 08:25:17 am
Is there anyone using the thing in another timezone then the UK.? Let me know if this works or if there are still time zone related problems.
Title: Re: Google Calendar Switch
Post by: Henk on September 02, 2011, 09:21:54 am
@utz,

Im back to UI4 now and reinstalled the plugin (v3)
Im having some issues still (no red man, calenderview will not refresh) so i will pm you some logs after ive done some more testing tonight or in the w/e.

I DO like the way this plugin is going! Ill do my best to work out any user errors that i seem to be having and also to provide feedback!

- Henk

Is there anyone using the thing in another timezone then the UK.? Let me know if this works or if there are still time zone related problems.
Title: Re: Google Calendar Switch
Post by: strangely on September 02, 2011, 12:50:47 pm
I've been trying to use it (USA), but am also having some difficulties getting it to see my Calender and work. Just haven't had too much time yet to work whats going on with it!
Title: Re: Google Calendar Switch
Post by: utz on September 02, 2011, 05:15:18 pm
I've been trying to use it (USA), but am also having some difficulties getting it to see my Calender and work. Just haven't had too much time yet to work whats going on with it!

I noticed that when you open the calendar tab (a js tab) you get a progress bar loading the tab which never finishes. When you then click on another tab and then after that you go back on the calendar tab it displays it fine. I have this problem with any js tabs I create. Anyone a hint here?

If you have more precise error messages I will try fixing it. In my setting it works.
Title: Re: Google Calendar Switch
Post by: futzle on September 02, 2011, 05:37:40 pm
I noticed that when you open the calendar tab (a js tab) you get a progress bar loading the tab which never finishes. When you then click on another tab and then after that you go back on the calendar tab it displays it fine. I have this problem with any js tabs I create. Anyone a hint here?

It's a known bug with all JavaScript tabs. MCV knows about it but I don't think there is a published fix.
Title: Re: Google Calendar Switch
Post by: therealabdo on October 25, 2011, 05:23:42 am
Hello; first of all really thnx for sharing this it is really amazing

but actually i am having a problem and i have noticed that many here have the same problem,
after clicking "set" for the URL i have included nothing changed and when i close and re open the window it disappears! :(
as if i didn't press set from the first place
i tried https and http, both keyword and link separate and togethers but got no luck

please help

thnx
Title: Re: Google Calendar Switch
Post by: JOD on October 25, 2011, 09:12:11 am
Check the Advanced tab to see if the Link & Keyword are in the gcallink & gcalon boxes.

http://forum.micasaverde.com/index.php/topic,7558.msg48588.html#msg48588

This plugin is broken in UI5, the gcallink box does not propagate after entering the Link.

JOD.
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 06, 2011, 05:34:16 am
Hello all,

really nice idea with the calendar. I tried to install the V3 version (about 9th of September).

I have still the problem that

a) I get no response, when I set the private URL and the EVENT NAME.
b) when I use the TAB calendar I see response from google but this seems not to be my calendar, it is an error message:

undefined@group.calendar.google.com
Termine aus einem oder mehreren Kalendern konnten hier nicht angezeigt werden, da Sie nicht über die nötige Berechtigung verfügen.

c) I dont see the two variables at the advanced Tab

d) when are the changes saved? When I leave the device there is no save button available at UI4.

Can anybody help me?

Thanks
Stefan
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 06, 2011, 05:35:58 am
Sorry, forget the attachment. To confused about this issue. :-)

Title: Re: Google Calendar Switch
Post by: utz on December 06, 2011, 06:03:55 am
I tried to install the V3 version (about 9th of September).
Thats probably the last version. I did not get around since then to clean it up and develop it further.

Quote
a) I get no response, when I set the private URL and the EVENT NAME.
There will not be a response in the UI. the values get stored and you should see them stored in the advanced tab under variable gcallink and gcalon. (you may need to reload to see the variables being set)

Quote
b) when I use the TAB calendar I see response from google but this seems not to be my calendar, it is an error message:
undefined@group.calendar.google.com
Termine aus einem oder mehreren Kalendern konnten hier nicht angezeigt werden, da Sie nicht über die nötige Berechtigung verfügen.

That can have two reasons. First, not the right link to the calendar is set up (in URL). Second, it could be the google calendar is not configured to be accessed.

You need to pick the right link to your calendar so that it works.
Quote
c) I dont see the two variables at the advanced Tab

They should be created when pushing the set button. Sometimes it is necessary to reload the UI to make sure it shows up (A general UI thing)

Quote
d) when are the changes saved? When I leave the device there is no save button available at UI4.

They should be saved when pushing the set button.



Can anybody help me?

Thanks
Stefan
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 06, 2011, 06:14:24 am
Thanks for quick reply!

I tried to reload and i see only one variable:

I don't see gcallink! May be this is the reason, why the connect failed?

I used the link in a browser and it works. I see one calendar entry. But not at VERA.

Any further ideas? Can the variable set manually?

Thanks

Stefan
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 06, 2011, 07:14:04 am
May be the mistake is creating device?

What is to be filled at the fields:
DeviceType    
Internal ID    
Description    
UpnpDevFilename    
UpnpImplFilename    

I create a new device and still see only galcon.

Hhhmm... Grrrf :-)
Title: Re: Google Calendar Switch
Post by: utz on December 06, 2011, 12:00:32 pm
May be the mistake is creating device?

What is to be filled at the fields:
DeviceType    
Internal ID    
Description    
UpnpDevFilename    
UpnpImplFilename    

I create a new device and still see only galcon.

Hhhmm... Grrrf :-)

There should be  a variable gcallink which contains the link to the calendar. If you put the link in the box "link" and press set it should store that value in the variable gcallink (similar to gcalon that contains the key to look for). SO if one works the other should too. Any strange things in the link you try to set (German umlaut or so?) .

If you create the device you should only need UpnpDevFilename I think.

What you can do is to start debugging output on vera, then press the check button in the device tab and locate the lines starting with "GCAL:" in the logfile. This should show what the plugin tries to do and we should see there what is missing.


Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 06, 2011, 12:32:32 pm
Oh I will do so,

but I am relatively new to debugging, even when I do this for other languages by job.

How can I start logging? I saw some entries, but where can I find the logs?

Thanks!
Title: Re: Google Calendar Switch
Post by: utz on December 06, 2011, 01:21:43 pm
A description can be found here: http://wiki.micasaverde.com/index.php/Logs

to find the calendar plugin related outputs use grep GCAL

Utz
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 06, 2011, 02:48:59 pm
Ok, great.

I activated and here is the entry. Don't look well :-) When I press the set button, it is red line.

01      12/06/11 20:47:53.854   LuaInterface::CallFunction-1 device 58 function SGCal_GCal1_SetGCalLink_run failed [string ".
."]:70: attempt to concatenate local 'gcalsrc' (a nil value) <0x4c0e>
06      12/06/11 20:48:13.583   Device_Variable::m_szValue_set device: 58 service: urn:utz-com:serviceId:GCal1 variable: gcal
n was: HEATING_ON now: HEATING_ON #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x500e>
06      12/06/11 20:48:13.602   Device_Variable::m_szValue_set device: 58 service: urn:utz-com:serviceId:GCal1 variable: gcal
n was: HEATING_ON now: HEATING_ON #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x500e>
Title: Re: Google Calendar Switch
Post by: utz on December 07, 2011, 04:04:21 pm
Ok, great.

I activated and here is the entry. Don't look well :-) When I press the set button, it is red line.

01      12/06/11 20:47:53.854   LuaInterface::CallFunction-1 device 58 function SGCal_GCal1_SetGCalLink_run failed [string ".
."]:70: attempt to concatenate local 'gcalsrc' (a nil value) <0x4c0e>
06      12/06/11 20:48:13.583   Device_Variable::m_szValue_set device: 58 service: urn:utz-com:serviceId:GCal1 variable: gcal
n was: HEATING_ON now: HEATING_ON #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x500e>
06      12/06/11 20:48:13.602   Device_Variable::m_szValue_set device: 58 service: urn:utz-com:serviceId:GCal1 variable: gcal
n was: HEATING_ON now: HEATING_ON #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x500e>

Ok, seems the code fails to understand the url you put in the field "Link" before you press set. Could I have a look at this link? The link will point to your personal calendar so you may want to change some parts of the link before posting (you could also modify and send it to me as personal message).

Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 08, 2011, 05:00:12 am
Ok.

Here it is. I changed some char (no special characters) and some numbers.

if this is not possible, to use for testing, I can send the original link and change later the XML adresse at google calendar. Is currently only one date in.

Thanks!!!!

http://www.google.com/calendar/feeds/hwallhaeusser%40hp.de/private-13724ab2df3326f65f432fd521fc04ba/basic

Stefan
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 08, 2011, 05:01:24 am
I forgot:

I also tested with

http://www.google.com/calendar/feeds/hwallhaeusser@hp.de/private-13724ab2df3326f65f432fd521fc04ba/basic

Stefan
Title: Re: Google Calendar Switch
Post by: utz on December 08, 2011, 12:29:24 pm
I forgot:

I also tested with

http://www.google.com/calendar/feeds/hwallhaeusser@hp.de/private-13724ab2df3326f65f432fd521fc04ba/basic

Stefan

My code is looking for something like:
http://www.google.com/calendar/feeds/XXXXXXXXXXXXX@group.calendar.google.com/private-XXXXXXXXXXXXXXX/basic

using the line
local gcalsrc = lul_settings.NewGCalLink:match("^http://www.google.com/calendar/feeds/(.*)@group.*$")

As your calendar link is something different it does not work. I havent looked at this for a while but there are several options in google to get the private link to a calendar and I suppose you picked the wrong one.
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 08, 2011, 01:29:16 pm
Hi,

ok one step more. You have been right.

You need FIRST setup more than one calendar then the scond one is with group address.

Now I have http://www.google.com/calendar/feeds/xxx1qurxxxxa6hkr68qu64@group.calendar.google.com/private-b3a7l32p23e05077eeedcde0f0fca00e/basic

I see now the other variables:

gcalsrc
gcallink
gcalon

But when I use the TAB to see the calendar it just open.......... open....

At log I see:

02      12/08/11 19:27:17.348   luvd_get_info mg conn can't read /etc/cmh-ludl//J_GCal.js?fwdserver=1& or /etc/cmh-lu//J_GCal.js?fwdserver=1& from filename /J_GCal.js?fwdserver=1& pPtrFile (null) <0x700e>
08      12/08/11 19:27:24.209   JobHandler_LuaUPnP::HandleActionRequest device: 58 service: urn:utz-com:serviceId:GCal1 action: GCalCheck <0x700e>
08      12/08/11 19:27:24.210   JobHandler_LuaUPnP::HandleActionRequest argument fwdserver=1 <0x700e>
08      12/08/11 19:27:24.211   JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=58 <0x700e>
08      12/08/11 19:27:24.211   JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:utz-com:serviceId:GCal1 <0x700e>
08      12/08/11 19:27:24.212   JobHandler_LuaUPnP::HandleActionRequest argument action=GCalCheck <0x700e>
08      12/08/11 19:27:24.213   JobHandler_LuaUPnP::HandleActionRequest argument rand=0.10696562276307364 <0x700e>
50      12/08/11 19:27:24.214   luup_log:58: GCAL: check calendar <0x700e>
50      12/08/11 19:27:24.215   luup_log:58: GCAL: checking google calendar <0x700e>
50      12/08/11 19:27:25.254   luup_log:58: GCAL: query url: http://www.google.com/calendar/feeds/xxxxxxxxr68qu64@group.calendar.google.com/private-b3a3dcaxxxxxxeedcde0f0fca00e/basic?alt=json&fields=entry/title&start-min=2011-12-08T18:27:24&start-max=2011-12-08T17:32:00

Title: Re: Google Calendar Switch
Post by: utz on December 08, 2011, 01:38:17 pm
But when I use the TAB to see the calendar it just open.......... open....

I think you are describing a known UI4 bug. The tab is a javascript tab and when you click first time on them it tries to open them but never finishes (the loading bar does not go away). Click on another tab and when you go back on the tab a second time it should load the javascript tab with the calendar.
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 08, 2011, 06:11:22 pm
Hello utz,

first thanks for your help!

I don't know the bug at UI4, but when I switch back to the TAB ein don't see anaything else. Tried several times.

But I found a error at the log:

 12/08/11 19:16:27.994   ^[[33;1mluvd_get_info mg conn can't read /etc/cmh-ludl//J_GCal.js?fwdserver=1& or /etc/cmh-lu//J_GCal.js?fwdserver=1& from filename /J_GCal.js?fw
02      12/08/11 19:16:36.015   ^[[33;1mZW_Send_Data node 11 NO ROUTE (nil)^[[0m <0xc04>
04      12/08/11 19:16:36.174   <Job ID="7" Name="pollnode #11 1 cmds" Device="44" Created="11-12-08 19:16:36" Started="11-12-08 19:16:36" Completed="11-12-08 19:16:36" Duration

What does this mean?

When I look at the dir:

/etc/cmh-ludl# ls
D_GCal.json.lzo          D_StateDevice.xml.lzo    D_Weather.xml.lzo        I_GoogleWeather.xml.lzo  J_GCal.js.lzo            S_Weather.xml.lzo
D_GCal.xml.lzo           D_Weather.json.lzo       I_GCal.xml.lzo           I_StateDevice.xml.lzo    S_GCal.xml.lzo

I am to new to detect here the issue..  What are the *.lzo files?

When I read further on the log: I found:

50      12/08/11 23:54:44.011   luup_log:58: GCAL: checking google calendar <0x402>
50      12/08/11 23:54:45.277   luup_log:58: GCAL: query url:http://www.google.com/calendar/feeds/xxxxxxxma6hkr6xxxu64@group.calendar.google.com/private-b3a3xxxxxxxeedcde0fxxxxca00e/basic?alt=json&fields=entry/title&start-min=2011-12-08T22:54:44&start-max=2011-12-08T21:58:40
50      12/08/11 23:54:45.278   luup_log:58: GCAL: query status: 0 <0x402>

50      12/08/11 23:54:45.279   luup_log:58: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$gd":"http://schemas.goo...

The URL seems correct. When I paste the URL without ?alt=json..... at the browser I get an entry.

a) can I test it directly from Vera ssh?
b) How is the calendar entry to be setup, when I want to raise the event? I just put the code word at the subject?

Thanks and have a good start into the day!

Stefan
Title: Re: Google Calendar Switch
Post by: strangely on December 11, 2011, 12:48:44 am
I've never had any luck getting it to accept my private address either. This is mine which I've edited a bit:

http://www.google.com/calendar/feeds/MYNAMEWASHERE%40gmail.com/private-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/basic
Title: Re: Google Calendar Switch
Post by: utz on December 11, 2011, 06:19:58 am
I've never had any luck getting it to accept my private address either. This is mine which I've edited a bit:

http://www.google.com/calendar/feeds/MYNAMEWASHERE%40gmail.com/private-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/basic

My code is looking for something like:
http://www.google.com/calendar/feeds/XXXXXXXXXXXXX@group.calendar.google.com/private-XXXXXXXXXXXXXXX/basic

using the line
local gcalsrc = lul_settings.NewGCalLink:match("^http://www.google.com/calendar/feeds/(.*)@group.*$")

... Obviously there are many ways to specify a link to a valid google calendar. I would need to change my program to accept the variety of methods possible. When I did this I put it together so that it works for my calendars which have the link form as specified above. (I guess the difference may be that I use google calendar as my normal calendar and then I created a dedicated specific calendar within that just for the automation stuff).

I would need to sit down and clean up the code to make it more generic. Problem is that I have too much real work at the moment so that there is no more time left for this stuff (maybe I find some time over Christmas to look into this). 
Title: Re: Google Calendar Switch
Post by: utz on December 11, 2011, 06:27:44 am
I don't know the bug at UI4, but when I switch back to the TAB ein don't see anaything else. Tried several times.
Can you make a screenshot of the tab to see whats there?

Quote
But I found a error at the log:

 12/08/11 19:16:27.994   ^[[33;1mluvd_get_info mg conn can't read /etc/cmh-ludl//J_GCal.js?fwdserver=1& or /etc/cmh-lu//J_GCal.js?fwdserver=1& from filename /J_GCal.js?fw
02      12/08/11 19:16:36.015   ^[[33;1mZW_Send_Data node 11 NO ROUTE (nil)^[[0m <0xc04>
04      12/08/11 19:16:36.174   <Job ID="7" Name="pollnode #11 1 cmds" Device="44" Created="11-12-08 19:16:36" Started="11-12-08 19:16:36" Completed="11-12-08 19:16:36" Duration

What does this mean?
How did you cantact vera when you tried it? Via mios or directly in your home network. Seems to me it cant find the javascript file. Anyone with some more insight have an idea?

Quote
When I look at the dir:

/etc/cmh-ludl# ls
D_GCal.json.lzo          D_StateDevice.xml.lzo    D_Weather.xml.lzo        I_GoogleWeather.xml.lzo  J_GCal.js.lzo            S_Weather.xml.lzo
D_GCal.xml.lzo           D_Weather.json.lzo       I_GCal.xml.lzo           I_StateDevice.xml.lzo    S_GCal.xml.lzo

I am to new to detect here the issue..  What are the *.lzo files?
No clue, anyone else an idea?

Quote
When I read further on the log: I found:

50      12/08/11 23:54:44.011   luup_log:58: GCAL: checking google calendar <0x402>
50      12/08/11 23:54:45.277   luup_log:58: GCAL: query url:http://www.google.com/calendar/feeds/xxxxxxxma6hkr6xxxu64@group.calendar.google.com/private-b3a3xxxxxxxeedcde0fxxxxca00e/basic?alt=json&fields=entry/title&start-min=2011-12-08T22:54:44&start-max=2011-12-08T21:58:40
50      12/08/11 23:54:45.278   luup_log:58: GCAL: query status: 0 <0x402>

50      12/08/11 23:54:45.279   luup_log:58: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$gd":"http://schemas.goo...

That seems right. "GCAL: query" sends a request to google calendar. At "GCAL: query result:" something comes back. Within this reply I will then search for the keyword that you have set "HEATING_ON" for example.

Title: Re: Google Calendar Switch
Post by: sjolshagen on December 16, 2011, 07:53:47 am
Hi,

I don't believe the following (including the attachment) is correct behavior? Running UI5 on a Vera2 with 1.5.236 installed.

I've just started kicking the tires of this plugin, so I may _very_ well be doing something wrong. If I am, my apologies! However, after having created a calendar event (ALERT) and having configured the plugin, I'd have expected the "triggered" value to get set to 1 whenever I run "Check" _and_ an alert calendar event is happening. Is that not the correct expectation?

Also, shouldn't the content of the variable (calendar link and key word) be displayed in the UI?

See the log output below (and the associated image I've attached) to demonstrate that at the time, the "ALERT" event was ongoing but the plugin appears to believe there is no event.

Code: [Select]
50 12/16/11 7:43:41.854 luup_log:117: GCAL: check calendar <0xa408>
50 12/16/11 7:43:41.855 luup_log:117: GCAL: checking google calendar <0xa408>
50 12/16/11 7:43:42.114 luup_log:117: GCAL: query url: http://www.google.com/calendar/feeds/[feed-edited]@group.calendar.google.com/private-[edited]/basic?alt=json&fields=entry/title&start-min=2011-12-16T12:43:41&start-max=2011-12-16T11:48:41 <0xa408>
50 12/16/11 7:43:42.115 luup_log:117: GCAL: query status: 0 <0xa408>
50 12/16/11 7:43:42.115 luup_log:117: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed": {"xmlns":"http://www.w3.org/2005/Atom","xmlns$gd":"http://schemas.google.com/g/2005"}} <0xa408>
50 12/16/11 7:43:42.116 luup_log:117: GCAL: no event with name ALARM is currently active <0xa408>

Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 16, 2011, 08:26:18 am
Hi,

the same behavoir for me (UI4).

I am not sure how I should setup the google calendar (at which time and how long?)

E.g. I want to start the event at 07:30 am (German time).

Starting from 07:30 - 07:45 or longer/shorter?

I copied the URL from log to browser and got a xml file back, which shows only emtpy response header ...).

UTZ@: can You help us?

PS. How can we change the times, when the event is checked at google. I think my vera has some delay in handling events since I update the URL and get connections to google for 2 events.
Title: Re: Google Calendar Switch
Post by: utz on December 16, 2011, 09:53:17 am
Hi,

I don't believe the following (including the attachment) is correct behavior? Running UI5 on a Vera2 with 1.5.236 installed.

I've just started kicking the tires of this plugin, so I may _very_ well be doing something wrong. If I am, my apologies! However, after having created a calendar event (ALERT) and having configured the plugin, I'd have expected the "triggered" value to get set to 1 whenever I run "Check" _and_ an alert calendar event is happening. Is that not the correct expectation?

Also, shouldn't the content of the variable (calendar link and key word) be displayed in the UI?

See the log output below (and the associated image I've attached) to demonstrate that at the time, the "ALERT" event was ongoing but the plugin appears to believe there is no event.

Code: [Select]
50 12/16/11 7:43:41.854 luup_log:117: GCAL: check calendar <0xa408>
50 12/16/11 7:43:41.855 luup_log:117: GCAL: checking google calendar <0xa408>
50 12/16/11 7:43:42.114 luup_log:117: GCAL: query url: http://www.google.com/calendar/feeds/[feed-edited]@group.calendar.google.com/private-[edited]/basic?alt=json&fields=entry/title&start-min=2011-12-16T12:43:41&start-max=2011-12-16T11:48:41 <0xa408>
50 12/16/11 7:43:42.115 luup_log:117: GCAL: query status: 0 <0xa408>
50 12/16/11 7:43:42.115 luup_log:117: GCAL: query result: {"version":"1.0","encoding":"UTF-8","feed": {"xmlns":"http://www.w3.org/2005/Atom","xmlns$gd":"http://schemas.google.com/g/2005"}} <0xa408>
50 12/16/11 7:43:42.116 luup_log:117: GCAL: no event with name ALARM is currently active <0xa408>

The plugin looks for an entry with name ALARM between the time of 12:43 and 11:48 and does not find it. (start-min=2011-12-16T12:43:41&start-max=2011-12-16T11:48:41). I have not touched the code in a while but I think that is wrong as the end time is before the start time (I have to check again what the google api wants here).

I also had the problem when using it with time zones. Here in the UK I have no offset to GMT while other people have that (Which would require some more thinking).

I will try looking at the plugin over Christmas, I just have too much other things going at the moment ...
 
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 16, 2011, 10:10:22 am
Hi Utz,

I can understand! I have pretty much to do this year. And I have some greater issues with the Danfoss Living... and I have to contact Danfoss developers to help to solve this issue.

But this Plugin is very helpful and I like it very much...

I looked at this log entries, too and found it strange that min and max is changed. But it works before, or?

Hmm. I will try to switch the entries and send again with browser to look what happens.

Keep you informed!
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 16, 2011, 10:24:21 am
Ok:

UPDATE:  I tried to change min and max date/time => and success!!

I got the event name as title back:

{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$gd":"http://schemas.google.com/g/2005","entry":[{"title":{"$t":"HEATING_ON","type":"html"}}]}}

But how can I change the code for creating the URL?
Title: Re: Google Calendar Switch
Post by: utz on December 17, 2011, 03:07:51 am
The plugin looks for an entry with name ALARM between the time of 12:43 and 11:48 and does not find it. (start-min=2011-12-16T12:43:41&start-max=2011-12-16T11:48:41).

The time window to look for is
start-min=2011-12-16T12:43:41&start-max=2011-12-16T11:48:41
but should be
start-min=2011-12-16T12:43:41&start-max=2011-12-16T12:48:41

... so there is an hour missing on the start-max time. Start-min and saart-max shoul be 5min apart (minus a few seconds due to vera being bad at maths).

I developed this plugin in the summer and it worked. Now we have winter with that one hour time change in the clocks and I suspect this to be the culprit.

This whole timezone business makes it difficult to get this to work (in particular for everyone in all time zones ...).

I have a look ....
Title: Re: Google Calendar Switch
Post by: LG on December 17, 2011, 03:49:35 am
Hi Utz,

I think that removing the line "t.isdst=true" in I_GCal.xml will solve this issue... at least for winter.
Title: Re: Google Calendar Switch
Post by: utz on December 17, 2011, 02:11:18 pm
Hi Utz,

I think that removing the line "t.isdst=true" in I_GCal.xml will solve this issue... at least for winter.

probably right but i try to find a fix that solves this permanent.
Title: Re: Google Calendar Switch
Post by: weissertigerxl on December 19, 2011, 08:36:33 am
Hi Utz,

replacing the code works for winter know. Great!

Would be perfect to devlop further on the plug in!

Thanks!
Title: Re: Google Calendar Switch
Post by: utz on December 19, 2011, 11:03:16 am
replacing the code works for winter know. Great!

Good to know. Thanks for testing. But obviously we cant have winter and summer plugins .... I hope to fix it over christmas, just have to finish other (real) work the next days before doing this.
Title: Re: Google Calendar Switch
Post by: markbannister on December 20, 2011, 11:27:10 am
How does one install this app in UI5?
Title: Re: Google Calendar Switch
Post by: mcvflorin on December 21, 2011, 03:15:14 am
@markbannister

Go to Apps >> Install Apps and install the plugin normally.
Title: Re: Google Calendar Switch
Post by: markbannister on December 21, 2011, 08:59:43 am
@markbannister

Go to Apps >> Install Apps and install the plugin normally.
Jeez, I just missed it in the list.  Thanks.

Is there a way to make a scene NOT activate if there is an event?
Title: Re: Google Calendar Switch
Post by: computerScience on December 27, 2011, 03:55:09 am
Very useful plugin, thanks a lot!

I also had the issue with start-min being greater than start-max.

As LG mentioned I can confirm that removing "t.isdst=true" in I_GCal.xml was working.
However I would appreciate a general solution.

Thanks again for a great plugin!
Title: Re: Google Calendar Switch
Post by: idlewild on January 06, 2012, 11:57:03 am
Great plugin!!

Had to remove "t.isdst=true" in I_GCal.xml.lzo as mentioned above.

@utz

Can you elaborate on how to use the attached value "gcalval" to set a thermostat to a spacific value?

I am using Heat{72} as my event name and successfully getting:

50      01/06/12 11:51:23.327   luup_log:20: GCAL: an event with name Heat is currently active <0x2d185680>
50      01/06/12 11:51:23.327   luup_log:20: GCAL: attached value: 72 <0x2d185680>

I would love to understand how to pass this value down the chain...


Thanks in advance!!
Title: Re: Google Calendar Switch
Post by: utz on January 07, 2012, 06:29:18 am
Can you elaborate on how to use the attached value "gcalval" to set a thermostat to a spacific value?

I am using Heat{72} as my event name and successfully getting:

50      01/06/12 11:51:23.327   luup_log:20: GCAL: an event with name Heat is currently active <0x2d185680>
50      01/06/12 11:51:23.327   luup_log:20: GCAL: attached value: 72 <0x2d185680>

I would love to understand how to pass this value down the chain...

You could access the value 72 for example within lua code of a scene via:

gcal_value = luup.variable_get("urn:utz-com:serviceId:GCal1","gcalval", gcal_dev)

The value gets stored in a variable of the calendar device.

Utz
Title: Re: Google Calendar Switch
Post by: idlewild on January 07, 2012, 11:05:27 pm
Can you elaborate on how to use the attached value "gcalval" to set a thermostat to a spacific value?

I am using Heat{72} as my event name and successfully getting:

50      01/06/12 11:51:23.327   luup_log:20: GCAL: an event with name Heat is currently active <0x2d185680>
50      01/06/12 11:51:23.327   luup_log:20: GCAL: attached value: 72 <0x2d185680>

I would love to understand how to pass this value down the chain...

You could access the value 72 for example within lua code of a scene via:

gcal_value = luup.variable_get("urn:utz-com:serviceId:GCal1","gcalval", gcal_dev)

The value gets stored in a variable of the calendar device.

Utz

Way Cool!!

Used the following code to set my thermostat according to events scheduled in google calendar:

Code: [Select]
local gCalDeviceNo = 18 -- GCal Sensor device number
local thermostatDeviceNo = 7  -- Thermostat device number

local GS_SID = "urn:utz-com:serviceId:GCal1" -- GCal Sensor Service ID
local TH_SID = "urn:upnp-org:serviceId:TemperatureSetpoint1_Heat" -- Thermostat Service ID

local gCalTemp = luup.variable_get (GS_SID, "gcalval", gCalDeviceNo )

luup.call_action (TH_SID, "SetCurrentSetpoint", {NewCurrentSetpoint  = gCalTemp }, thermostatDeviceNo )

luup.log("GCAL Heat Scene: NewCurrentSetpoint: " .. gCalTemp )

return true
Title: Re: Google Calendar Switch
Post by: trouty00 on January 14, 2012, 04:55:21 am
Hi Utz,

I think that removing the line "t.isdst=true" in I_GCal.xml will solve this issue... at least for winter.

how do i go about making this change??


I run find / -name I_GCal.xml but it doesnt find anything, i do have I_GCal.xml.lzo but when i open with vi its a buit jumbled so dont want to make an errors, is there another installed editor?

**EDIT - ok i found the file through apps>develop apps>Luup files

Title: Re: Google Calendar Switch
Post by: sjolshagen on January 30, 2012, 12:00:30 pm
The following I_GCAL.xml file works for me (EST5EDT - the America\New_York timezone) when reading the GCAL event and not having problems with the event being "off" by 5 hours.

The time (when the event was set for in the EST timezone) was 10:50pm (22:50:00) and the encoded URL used to capture the event was:

Code: [Select]
http://www.google.com/calendar/feeds/identifierofsometsort@group.calendar.google.com/private-bunchofnumbersandstuff/basic?alt=json&fields=entry/title&start-min=2012-01-30T03:51:26&start-max=2012-01-30T03:55:28


And at 6am EST, today, my WakeUpRamp scene was triggered by the Google Calendar alarm, exactly as hoped!

The code I added should work regardless of timezone (it calculates the timezone offset in seconds and adds it). I've got to go back and check if the is_dst flag being set the way it is will work when we go back to DST again, but that's "later" :)
Title: Re: Google Calendar Switch
Post by: trouty00 on February 14, 2012, 04:37:38 am
Hi,  did you ever get a chance to look at the calender address thing and make it possible to access primary calenders rather than just the additional ones?
Title: Re: Google Calendar Switch
Post by: utz on February 14, 2012, 05:53:09 pm
All,

I moved the code to http://code.mios.com/trac/mios_google-calendar-plugin/

This should help keeping track of patches and fixes. There is currently a UI4 and UI5 version in the svn. This includes changes from @sjolshagen (I tested this and it works in my timezone as well, thanks!).

If I missed something or it is not working please let me know.
Title: Re: Google Calendar Switch
Post by: sjolshagen on March 12, 2012, 07:57:57 am
This should help keeping track of patches and fixes. There is currently a UI4 and UI5 version in the svn. This includes changes from @sjolshagen (I tested this and it works in my timezone as well, thanks!).

But it (my edits) didn't "survive" the transition back to DST. This morning, my Vera decided to start my morning alarm 1 hour early... Will have to look into that sometime today, I hope.
Title: Re: Google Calendar Switch
Post by: sjolshagen on March 12, 2012, 10:43:35 pm
Not sure where to put this (or how), so here's a patch version that currently(!) works as expected by taking the US DST change and no DST for UTC into account for the I_GCal.xml file.

It seems Google Calendar provides all entries in UTC when anonymously accessing the calendar which is why the UTC change has been made in the file. I also removed my original offset calculation as it caused all sorts of early morning ruckus today! :)

I _think_ this patch will be able to handle any TZ, regardless of DST or not, but I could be horribly wrong and no warranty is expressed or implied.

Personally, I've added some debug logging for my own implementation of this implementation to more easily compare local time vs UTC at various points going forward.

Code: [Select]
--- I_GCal.xml 2012-03-12 22:30:13.000000000 -0400
+++ I_GCal_new.xml 2012-03-12 22:40:21.000000000 -0400
@@ -14,34 +14,26 @@
  end
       end
 
-      -- Added by sjolshagen to handle timezones
-      function get_timezone()
-   local now = os.time()
-   return os.difftime(now, os.time(os.date("!*t", now)))
-      end
-
-      -- check if an event with name gcalon is scheduled in the calendar gcallink
       function checkGCal()
  local gcallink = luup.variable_get(GCAL_SID, "gcallink", lul_device)
  local gcalon = luup.variable_get(GCAL_SID, "gcalon", lul_device)
  if ((gcallink~=nil) and (gcalon~=nil)) then
- debug("GCAL: checking google calendar")
+              debug("GCAL: checking google calendar - using anonymous link and getting times in UTC")
  local url = gcallink .. "?alt=json&amp;fields=entry/title"
- local t = os.time(t)
- t = t - get_timezone()
- local ta = os.date('!*t')
- ta.isdst=true
+              local t = os.time()
+              local ta = os.date('!*t', t)
  local s = string.format("%d-%02d-%02dT%02d:%02d:%02d", ta.year, ta.month, ta.day, ta.hour, ta.min, ta.sec)
  debug("GCAL: start-min: " .. s)
  url = url .. "&amp;start-min=" .. s
  t = t+(UPDATE_FREQU*60)
- ta = os.date('*t', t)
+              ta = os.date('!*t', t)
  s = string.format("%d-%02d-%02dT%02d:%02d:%02d", ta.year, ta.month, ta.day, ta.hour, ta.min, ta.sec)
  debug("GCAL: start-max: " .. s)
  url = url .. "&amp;start-max=" .. s
  local status, page = luup.inet.wget(url, 10)
  debug("GCAL: query url: " .. url)
  debug("GCAL: query status: " .. status)
+
          if (status == 0) then
  luup.log("GCAL: query result: " .. page)
  if( string.find (page, gcalon)~=nil ) then
@@ -74,7 +66,6 @@
  luup.call_timer("GCalTimer", 1, UPDATE_FREQU.."m", "", "")
  checkGCal()
       end
-
   </functions>
   <incoming>
  <lua>
Title: Re: Google Calendar Switch
Post by: utz on March 13, 2012, 06:09:13 am
@sjolshagen

I will investigate and figure out what happened..... Thanks for pointing it out.

Title: Re: Google Calendar Switch
Post by: sjolshagen on March 13, 2012, 07:00:50 am
@utz, thanks. The event fired at the expected time today (after I made the changes in the patch I included yesterday).
Title: Re: Google Calendar Switch
Post by: aecchalet on March 27, 2012, 03:04:17 pm
If I install the plugin from the Marketplace, will it include the last patch several posts before this post?
Thanks
Title: Re: Google Calendar Switch
Post by: utz on March 27, 2012, 03:36:55 pm
If I install the plugin from the Marketplace, will it include the last patch several posts before this post?
Thanks

sorry, no. I still haven't got around to sort this all out. 
Title: Re: Google Calendar Switch
Post by: Ned on April 05, 2012, 02:46:09 pm
Ok, I have the Calendar working and can see the man change red/green based upon the calendar, but was wondering what varable to check for in Luup to see that the calendar is armed, and active.  Is it similar to the virtual switch? I am trying to use the calendar to cancel the morning power up. Kind of upsets my wife when all the lights come on and we are trying to sleep. :o  I doubt it is "Status" that I am looking for... but looking to use something like this.

Code: [Select]
someoneHome = luup.variable_get("urn:upnp-org:serviceId:GCal","Status",DeviceID)
if(someoneHome=="1")then
    return false
else
    return true
end

Thanks for a great addon!

*EDIT* I found it is "Tripped", not "Status" that  you monitor.
Title: Re: Google Calendar Switch
Post by: sjolshagen on April 14, 2012, 06:58:53 pm
I wound up biting  the bullet and upgrading to UI5 today and with that comes a couple of caveats. For starters, the GCAL event didn't seem to make the upgrade so I had to go into the "Apps" menu and install the plugin on top of the old one.

That, of course, meant that my patch (see above) disappeared and I had to reapply it. That, in turn, made me realize my "debug()" logging routine is a little busted so I another function got added to my local I_GCAL.xml file. Not sure if anybody but utz has privileges to update plugin in the Marketplace, but regardless I've attached my patched I_GCAL.xml file to this post.

Obviously, all the "normal" disclaimers apply: YMMW, Worked on my Vera 2, can't promise it'll work on yours, etc, etc...
Title: Re: Google Calendar Switch
Post by: minxster on April 24, 2012, 11:38:32 am
Hi all,

I'm a newbie to all of this, including Vera/MIOS. But thanks already for this great plugin. I've got it all up and running with my Thermostat  ;D

Quick question though - do Recurring Events work? I have a large number of these setup for my heating schedule, though they all worked yesterday, they don't seem to work today?

Minxster
Title: Re: Google Calendar Switch
Post by: minxster on May 08, 2012, 07:39:35 pm
Hi all,

I did figure out that repeat calendar events do indeed work perfectly fine. Though I have been pretty confused over the whole time of events firing off.

I did have problems with events firing off nearly an hour early which caused me a few problem. So I've finally took a little time to go through the I_GCal.xml file to see what's going on.
*
I'm not fully clued up on the programming luup but think ta = os.date('*t', t) should be ta = os.date('!*t', t)?? When left to the original code, the start-max seems to be nearly an hour ahead of the start-min. With the code change, the start-max is 5 mins (UPDATE_FREQU*60) ahead as it should be. This seems to have stopped events form firing up too early.

sjolshagen: I've noticed that your patched xml file (above) already has this change in place  ;D
Title: Re: Google Calendar Switch
Post by: guest13242 on May 16, 2012, 03:17:20 pm
can someone please guide me how get it work? I download and created device no problems.
I can see the device green man and I can't seem get it to work. please tell me how to make scene sync with google calendar. for an example I want to pass HEATING_ON{20} onto a scene to turn on my thermostat at home. Thank you very much and I'm my English very limited.
Title: Re: Google Calendar Switch
Post by: psykokwak on May 20, 2012, 06:28:10 am
Hi all,

I'm a new vera user and I discovered this awesome google cal plugin.
I've made some improvements according to my needs.

- If my event is longer than UPDATE_FREQU minutes, device event "trigger" is launch every UPDATE_FREQU. So here a patch that fix that issue :
Code: [Select]
--- I_GCal.xml
+++ I_GCal.xml.new
@@ -54,10 +54,16 @@
                               debug("GCAL: no value attached")
                               luup.variable_set(GCAL_SID, "gcalval", "", lul_device)
                        end
-                       luup.variable_set(SECURITY_SID, "Tripped", 1, lul_device)
+                              local prevtripped = luup.variable_get(SECURITY_SID, "Tripped", lul_device)
+                              if (tonumber(prevtripped) == 0) then
+                                      luup.variable_set(SECURITY_SID, "Tripped", 1, lul_device)
+                              end
                else
                        debug("GCAL: no event with name " .. gcalon .. " is currently active")
-                       luup.variable_set(SECURITY_SID, "Tripped", 0, lul_device)
+                      local prevtripped = luup.variable_get(SECURITY_SID, "Tripped", lul_device)
+                      if (tonumber(prevtripped) == 1) then
+                              luup.variable_set(SECURITY_SID, "Tripped", 0, lul_device)
+                      end
                end
             end
        end

- I'm working on an other fix that trigger the device exactly when the calendar event starts and not if it starts between "now" and "UPDATE_FREQU".
Title: Re: Google Calendar Switch
Post by: garrettwp on May 20, 2012, 07:07:42 am
psykokwak,

Welcome! Thank you for providing your patch and providing to the community. Looking forward to seeing what you come up with next.

- Garrett
Title: Re: Google Calendar Switch
Post by: psykokwak on May 20, 2012, 10:18:37 am
In France (daylight time), I have an error on start-max hour value. I Fixed it (and remove the useless get_timezone() function).
Hop will definitively fix the daylight issue.

Here my patch :
Code: [Select]
--- I_GCal.xml.def
+++ I_GCal.xml
@@ -3,7 +3,7 @@
   <functions>
       local GCAL_VERSION      = "V 0.10"
       local LOG_DEBUG         = true
-      local UPDATE_FREQU      = 5
+      local UPDATE_FREQU      = 2
       local GCAL_SID          = "urn:utz-com:serviceId:GCal1"
       local SECURITY_SID      = "urn:micasaverde-com:serviceId:SecuritySensor1"

@@ -27,15 +27,12 @@
        if ((gcallink~=nil) and (gcalon~=nil)) then
             debug("GCAL: checking google calendar")
             local url = gcallink .. "?alt=json&amp;fields=entry/title"
-            local t = os.time(t)
-            t = t - get_timezone()
-            local ta = os.date('!*t')
-            ta.isdst=true
+            local now = os.time()
+            local ta = os.date("!*t", now)
             local s = string.format("%d-%02d-%02dT%02d:%02d:%02d", ta.year, ta.month, ta.day, ta.hour, ta.min, ta.sec)
             debug("GCAL: start-min: " .. s)
             url = url .. "&amp;start-min=" .. s
-            t = t+(UPDATE_FREQU*60)
-            ta = os.date('*t', t)
+                ta = os.date("!*t", now + (UPDATE_FREQU * 60))
             s = string.format("%d-%02d-%02dT%02d:%02d:%02d", ta.year, ta.month, ta.day, ta.hour, ta.min, ta.sec)
             debug("GCAL: start-max: " .. s)
             url = url .. "&amp;start-max=" .. s
@@ -54,10 +51,16 @@
                               debug("GCAL: no value attached")
                               luup.variable_set(GCAL_SID, "gcalval", "", lul_device)
                        end
-                       luup.variable_set(SECURITY_SID, "Tripped", 1, lul_device)
+                              local prevtripped = luup.variable_get(SECURITY_SID, "Tripped", lul_device)
+                              if (tonumber(prevtripped) == 0) then
+                               luup.variable_set(SECURITY_SID, "Tripped", 1, lul_device)
+                              end
                else
                        debug("GCAL: no event with name " .. gcalon .. " is currently active")
-                       luup.variable_set(SECURITY_SID, "Tripped", 0, lul_device)
+                       local prevtripped = luup.variable_get(SECURITY_SID, "Tripped", lul_device)
+                       if (tonumber(prevtripped) == 1) then
+                              luup.variable_set(SECURITY_SID, "Tripped", 0, lul_device)
+                       end
                end
             end
        end
Title: Re: Google Calendar Switch
Post by: therealabdo on May 22, 2012, 05:04:24 am
hello all

I have installed everything and done eveyrthing
but when i set the link and the keyword nothing appears in the advanced tap. Actually i coundnt find the galink and gacon fields
in the advanced tap there is such a galink field to be filled
Title: Re: Google Calendar Switch
Post by: psykokwak on May 23, 2012, 11:13:15 am
I almost finish to entirely rewrite the Lua program of this plugin. I improved the polling system. Now we can set the UPDATE_FREQ at 1 hour (default value) or more and each event will be tripped exactly at the scheduled time (0.1 second resolution). It work with daily events and (I hope) with every timezone. I add a small improvement into the gcallink parsing value. You can copy/past the private link directly from google calendar without change "https" to "http".
However this "new" plugin needs a new lua module which is not present into the firmware. This is a lua json parser.

So, before releasing this update (on the Mios Market ?) I have some packaging questions.
- How to integrate this lua module into the plugin ? Actually I copy the module file in /usr/lib/lua directory.
- Is the original author of this plugin is agree with my modifications and accepts to put them into the Mios Market ?
Title: Re: Google Calendar Switch
Post by: sjolshagen on May 23, 2012, 11:32:58 am
 
Quote
How to integrate this lua module into the plugin ? Actually I copy the module file in /usr/lib/lua directory.

I'm (obviously) not the original author, so it's pretty much up to him/MCV on how to distribute this.

However, I do have some feedback... I believe that having a library/module that's not part of the base distribution is a bit of a non-starter from a use perspective (and, possibly, also from a support perspective). Who owns fixing issues in this 3rd party parser and ensuring it doesn't have unintended interactions with the parser that I assume exists in the luup engine itself. I assume this because of the extensive use of JSON for the UI?. Also, another lua module/library will consume something I, personally, have precious little of as it is on my Vera2/UI4 combination; Memory.

I wonder how you'd deal with upgrades of the FW. Would that not mean the library would need to be re-installed?

Your plan to deploy this in the Mios Market suggests (perhaps incorrectly?) that your implementation is UI5 specific. Is that the case? If so, you're alienating a big part of the base which is Vera1/Vera2 and many of us have real problems with UI5 due to its increased resource consumption - which also brings it back to the 2nd "objection" I have to an implementation that leverages a 3rd party library which isn't distributed with the UI.
Title: Re: Google Calendar Switch
Post by: psykokwak on May 23, 2012, 11:51:12 am
Thanks for your answer.
There is actually no JSON library for LUA. It seems it's planned for the next update (http://forum.micasaverde.com/index.php/topic,10521.msg72854.html#msg72854). As the only two functions in the module have the same name and the same behaviour, moving the plugin to this library will be very easy.
I dont know if my plugin code is IU4 compliant. I'm pretty new in the Mios world and I use a vera light. This version can significantly reduce the number of requests to the google server and the program spends more time in sleep state. So I think it a good thing.

I think I will provide my code here. Any one who want could try and we will see if MVC staff want to add the plugin.
Title: Re: Google Calendar Switch
Post by: psykokwak on May 25, 2012, 08:17:52 am
Ok, here my Google calendar swich plugin.

Changelog :
- Work with private and public calendar (like public holiday...)
- Trigger on a specific event name (eventually followed by a "{xxx} tag" or any event (leave the field empty)
- No need to poll more than once per day.
- Raises the event to the exact second at which it begins. Same for the end of the event.

In the zip file, there is a "json.lua" file that you have to put in your "/usr/lib/lua" directory before using the module.
If you already have the plugin installed, replace them (in "/etc/cmh-ludl")

Hope there is no bug. It's my first LUA program :)

Title: Re: Google Calendar Switch
Post by: psykokwak on May 26, 2012, 07:19:21 pm
Hop. New release "1.2.1" with some minor graphical improvements.
Title: Re: Google Calendar Switch
Post by: psykokwak on May 28, 2012, 08:18:24 am
New version again : 1.2.2
Changelog :
- Fix an issue with empty keyword
- Device was not triggered when we "check" when an event has already started
Title: Re: Google Calendar Switch
Post by: fatal25 on May 28, 2012, 01:07:28 pm
Hi psykokwak,

thank you for your job but I've a error with Gcal device...

Code: [Select]
Ramassage Carton[39] : Startup Lua Failed
39 is my device number.

I don't understand this problem.


URL is a private adress like... https://... basic.ics

Keyword is Carton
Title: Re: Google Calendar Switch
Post by: psykokwak on May 28, 2012, 01:16:29 pm
Hi Fatal,
Could you give me the content of your "gcalval", "gcalon", "gcallink" (with some modified char) and "gcalsrc" (with some modified char) ?
Could you give me the part of your /var/log/cmh/LuaUPnP.log file that display the error ?
Is this error is displayed when your LuaUPnP engine starts (when you press the "reload" button on the top right) ?

Thanks.
Title: Re: Google Calendar Switch
Post by: fatal25 on May 28, 2012, 05:59:39 pm
Hi psy,

After a few minutes & a few reloads, that's work fine :)

I've tried with ICAL calendar & XML calendar.

It work only with XML calendar format.


Thank you.
Title: Re: Google Calendar Switch
Post by: trouty00 on May 29, 2012, 10:55:24 am
Hi psykokwak,
               great work! it now can also check my main calender without me having to create separate secondary calenders. how frequently does it check the calender, from what I understand you are suggesting that it just does a scheduled check and then will change the status based on this rather than continually polling the calender? where is this event data stored and what happens in the even of a power cycle/reload?

Also can you elaborate on what you mean by this though?

- Trigger on a specific event name (eventually followed by a "{xxx} tag" or any event (leave the field empty)


Thanks again
Stu
Title: Re: Google Calendar Switch
Post by: psykokwak on May 29, 2012, 12:09:37 pm
Hi trouty,
This version (as the old one) checks the calendar avery REFRESH_FREQ (see "I_GCal.xml" file).
The difference between the two versions is the value of this variable. On the old one, this value must be very small (5/10minutes) because it checks only if there is an event in the next REFRESH_FREQ window time and trigger if that true. On my version, It does the same task but it memorizes the beginning of the event and trigger the device exactly when the event starts. So you can have a bigger REFRESH_FREQ (one day or more. Default value is 6 hours).
No data are stored because at each LuaPnP engine's starts, the device polls the calendar. The last version (1.2.2) fixes a bug that did not trigger an event that had already started.

You can create a GCal device associated to a calandar without any keyword. In this case, each event (whatever the name) will trigger the device.
You also create a Gcal device associated to a calandar with a keyword. In this case, only event that has this name will trigger the device. You can append "{xxx}" to the event name where "xxx" is whatever you want and get this value when the device triggers (by using a scene) using the next Lua code :
Code: [Select]
local value = luup.variable_get("urn:utz-com:serviceId:GCal1","gcalval", 9
I hope my English is good enough..
Title: Re: Google Calendar Switch
Post by: psykokwak on May 29, 2012, 01:32:57 pm
Here a new version (1.2.3) which add UI4 compatibility.
Thanks Drikc.
Title: Re: Google Calendar Switch
Post by: fatal25 on May 29, 2012, 01:34:44 pm
Hi psykokwak,

I've created 5 devices on my google calendar.

Before, that's work fine with one device.

Now, the device doesn't trip when the event begins.


What can I do to resolve this problem?

I notice if I click on "Check", the device trips immediatly.

Thank you.
Title: Re: Google Calendar Switch
Post by: psykokwak on May 29, 2012, 01:44:19 pm
Hum.
Could you execute this command :
"cat /var/log/cmh/LuaUPnP.log | grep GCAL" and past me the result when an event should trigger but it does not ?
Title: Re: Google Calendar Switch
Post by: trouty00 on May 29, 2012, 02:04:42 pm
Hi trouty,
This version (as the old one) checks the calendar avery REFRESH_FREQ (see "I_GCal.xml" file).
The difference between the two versions is the value of this variable. On the old one, this value must be very small (5/10minutes) because it checks only if there is an event in the next REFRESH_FREQ window time and trigger if that true. On my version, It does the same task but it memorizes the beginning of the event and trigger the device exactly when the event starts. So you can have a bigger REFRESH_FREQ (one day or more. Default value is 6 hours).
No data are stored because at each LuaPnP engine's starts, the device polls the calendar. The last version (1.2.2) fixes a bug that did not trigger an event that had already started.

You can create a GCal device associated to a calandar without any keyword. In this case, each event (whatever the name) will trigger the device.
You also create a Gcal device associated to a calandar with a keyword. In this case, only event that has this name will trigger the device. You can append "{xxx}" to the event name where "xxx" is whatever you want and get this value when the device triggers (by using a scene) using the next Lua code :
Code: [Select]
local value = luup.variable_get("urn:utz-com:serviceId:GCal1","gcalval", 9
I hope my English is good enough..

I see that is great, so far I have just been creating multiple instances of the plugin each with different keywords for what im trying to trigger events on, great to know the time of refresh is customisable too,

great work
Stu
Title: Re: Google Calendar Switch
Post by: fatal25 on May 29, 2012, 02:19:04 pm
This is my log file :



look your PM for password. ('cause private google calendar address)

Thx

Title: Re: Google Calendar Switch
Post by: fatal25 on May 29, 2012, 05:38:33 pm
Thank you Psykokwak for your help

Title: Re: Google Calendar Switch
Post by: fatal25 on May 29, 2012, 05:45:11 pm
If I want to check "Tripped", can I use this code? :

Code: [Select]
local vacances = luup.variable_get("urn:utz-com:serviceId:GCal1","Tripped", 43)
if vacances == "1" then
return false
else
return true
end

Title: Re: Google Calendar Switch
Post by: psykokwak on May 29, 2012, 05:51:02 pm
Code: [Select]
local vacances = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped", 43)
if tonumber(vacances) == 1 then
return false
else
return true
end
Title: Re: Google Calendar Switch
Post by: sjolshagen on May 29, 2012, 10:41:10 pm
I'm getting an error while running v1.2.3 of the GCal plugin on UI4 (1.1.1362):

Code: [Select]
01 05/29/12 22:34:38.431 LuaInterface::CallFunction_Startup-1 device 112 function GCalStartup failed [string "..."]:121: attempt to index field 'gd$when' (a nil value) <0x402>
01 05/29/12 22:34:38.432 LuImplementation::StartLua running startup code for 112 I_GCal.xml failed <0x402>

It appears to be happening in lines 122-124 of the I_GCAL.xml file.

Not a LUA expert by any means and even less so when it comes to JSON parsing, so take this for what it's worth:This is, as far as I can tell, the offending line (i added the "or 0" to see if it helped. It didn't...)

Code: [Select]
local json_entry_timestart = json_entry['gd$when'][1].startTime or 0
Title: Re: Google Calendar Switch
Post by: psykokwak on May 30, 2012, 03:53:47 am
Hi sjolshagen,
Could you give me your "gcallink" and "gcalval" variables ? (in PM if you want).

Thanks.
Title: Re: Google Calendar Switch
Post by: psykokwak on June 03, 2012, 10:09:29 am
mcvflorin: Do you think you could update the original plugin with my version ?
Title: Re: Google Calendar Switch
Post by: JOD on June 11, 2012, 04:01:06 pm
I downloaded ver1.2 of the GCS from the Apps store with no issues on installation, adding the Link or Keyword.

Adding the keyword as an event to my calendar and manually running "Check" triggers the switch, removing the event and running Check again, the switch resets, but the switch does not trigger automatically.
Title: Re: Google Calendar Switch
Post by: sb_domo on June 16, 2012, 03:17:24 am
Hello,
This plug-in with the update is very useful. Bravo.

However, I have made ​​some changes to make it more communicative.

I added a variable "nextevent" that can tell what is the current event or the next, and its start date.
When there is no current or future event, its value is:
"Not set calendar" is gcalon=nil,
"No datas" if there isn't anything in the calendar (no return),
"No event" if there are no events in the next time window,
"No event match" if there is no event corresponding to the keyword

I also added two other variables:
Freq_Hour that defines, in hours, frequency of update (every 6 hours by default)
TimeSlot_hour that defines the time slot in hours recovered: It must be bigger than Freq_Hour (Freq_Hour is used otherwise). This allows for example, for Freq_Hour=6 and TimeSlot_hour = 24, to ask the plugin to go read the calendar every six hours and to indicate the next event within 24 hours...

Details of the changes:
In D_GCal.json :
"SceneGroup" add :
Code: [Select]
,{
                    "id":"4",
                    "top": "-0.5",
                    "left": "-1",
                    "x": "1",
                    "y":"1"
                }
"ControlGroup" add :
Code: [Select]
,{
                    "id":"5",
                    "isSingle":"1",
                    "scenegroup":"4"
                }
"Control" add :
Code: [Select]
,{
                    "ControlType": "label",
                    "top": "0",
                    "left": "0",
                    "Label": {
                        "lang_tag": "nextevent",
                        "text": "Event : "
                    },
                    "Display": {
                        "Top": 20,
                        "Left": 50,
                        "Width": 75,
                        "Height": 20
                    }
                },
                {
                    "ControlGroup": "5",
                    "ControlType": "variable",
                    "top": "1",
                    "left": "0",
    "text_align": "left",
    "Display": {
                        "Service": "urn:utz-com:serviceId:GCal1",
                        "Variable": "nextevent",
                        "Top": 20,
                        "Left": 150,
                        "Width": 150,
                        "Height": 20
                    }
                }

In "S_GCal.xml", in serviceStateTable add :
Code: [Select]
     <stateVariable sendEvents="no">
      <name>Freq_Hour</name>
      <sendEventsAttribute>no</sendEventsAttribute>
      <datatype>i4</datatype>
      <defaultValue>6</defaultValue>
     </stateVariable>
     <stateVariable sendEvents="no">
      <name>TimeSlot_hour</name>
      <sendEventsAttribute>no</sendEventsAttribute>
      <datatype>i4</datatype>
      <defaultValue>6</defaultValue>
     </stateVariable>
     <stateVariable sendEvents="no">
       <sendEventsAttribute>no</sendEventsAttribute>
       <name>nextevent</name>
       <dataType>string</dataType>
       <defaultValue>Unset</defaultValue>
     </stateVariable>

And change I_GCal.xml (see files in attachment). The changments are indicated by that note :
Code: [Select]
------Changement
Title: Re: Google Calendar Switch
Post by: parkerc on July 08, 2012, 04:18:00 pm
Hi

I have just installed the app from the Vera App Store v1.2.1 and have the following questions I hope someone can help me with.

1) why does it not remember/store the XML link to my calendar, why do i have to enter ot each time?
2) why does it not store/show me the keyword I'm looking for?
3) when it trips, how can i reset it , the guidence from jOD did not seem to work?

My grand plan.

I'm looking to see if there is a way to have a track triggered on my Sonos, when a particular Calander entry was found. E.g "My Birthday" = Setfiletoplay on Sonos = //192.168.1.123/music/steviewonder.mp3

Title: Re: Google Calendar Switch
Post by: parkerc on August 27, 2012, 01:30:14 pm
If anyone can help answer my post above I'd appreciate it. @sb_domo does your plugin address this?

Also, is it possible to do the same thing with my gmail account? So it looks for a specific email? Either for a particular keyword in the subject line, or maybe it could look for a new mail from a specific sender (and then trigger a scene)

A sort of Mail Box Checker?

I understand ths is possible with php 5 (using the imap module) as a friend built one for his gmail account but i have no idea about Lua.
Title: Re: Google Calendar Switch
Post by: resq93 on September 25, 2012, 12:57:18 pm
Is there any way to have an event trigger before the calendar time? Example - trip Gcal 5 minutes before the event starts

M
Title: Re: Google Calendar Switch
Post by: newbneedshelp on October 17, 2012, 10:05:11 am
I can't seem to be able to get it to work.
The linking of the google calendar page either does not work or it works so slowly that it take hours. If I get the successful link to show in variable 'gcalink' it looks different from what the link I pasted on, e.g.:
true link is: https://www.google.com/calendar/feeds/xxx%40gmail.com/private-d3xxxxxxx8/basic
gcalink content is: http://www.google.com/calendar/feeds/xxx%40gmail.com/private-d3xxxxxxx8/basic/full.
And nothing shows under the calendar link field. The comand does show under the keyword field.
Pressing the CHECK button does not seem to do anything - but in ADVANCED the calendar does display.


(1) How to set the temperature and which variable is that? Or just set in the calendar Heat_ON{20} and it will set 20C?
(2) How do I tell which thermostat to operate ?- I have 2 Z-wave Trane thermostats.
 ???
Title: Re: Google Calendar Switch
Post by: Shaigan on October 28, 2012, 09:06:13 am
Hi

Isn't there a bug with DST time ?
In France, we've just changed the hour (at 03:00, we put our clock to 02:00)

Now, my event are firing 1 hour before the real start
Title: Re: Google Calendar Switch
Post by: hansep on October 29, 2012, 02:50:31 am
I've got the DST/GMT problem as well. Running 1.22 on UI5.
Title: Re: Google Calendar Switch
Post by: Estoecker on November 02, 2012, 12:51:46 am

01   05/29/12 22:34:38.431   LuaInterface::CallFunction_Startup-1 device 112 function GCalStartup failed [string "..."]:121: attempt to index field 'gd$when' (a nil value) <0x402>
01   05/29/12 22:34:38.432   LuImplementation::StartLua running startup code for 112 I_GCal.xml failed <0x402>


I am also getting an error similar to this, anyone know how to resolve it?

Thanks
Title: Re: Google Calendar Switch
Post by: SM2k on November 06, 2012, 06:15:12 pm
Utz, Fantastic plugin. thank you! I have a feature request if possible. I'd like the ability to trigger a switch X minutes before/after the beginning/end of a calendar event. In other words be able to add a delta to a calendar event and have the switch trigger based on that offset instead of the actual start/stop on the calendar (ideally separate offsets for beginning and end).

Use case: I'd like to be able to add my or my wife's work schedule to a calendar and trigger events earlier and later than the actual calendar event. e.g. set an alarm clock or adjust climate control. For instance if work starts at 9:00 AM, I could add one switch for an alarm clock event 120 minutes earlier (7:00 AM) and another switch that could trigger turning up the heat 150 minutes earlier (or 6:30 AM). Likewise, since my office is an hour away from my house, I could turn up the heat 30 minutes after my shift ended.

That's all doable with the current plugin behavior, but it takes 3 calendar events instead of just one, so it's a little bit more cumbersome to coordinate multiple events.

If there already exists an easier way to pull off what I described, I'm all ears. :-)
Title: Re: Google Calendar Switch
Post by: SM2k on November 12, 2012, 12:01:44 pm
I went ahead and coded the change I previously mentioned. This patch adds settings for StartDelta and EndDelta which are measured in minutes. The main intent of this is to be able to coordinate multiple different actions based on a single calendar event.

Both StartDelta and EndDelta are *added* to the beginning and end of the original calendar event respectively. That is to say a negative delta will cause the sensor to fire earlier than the calendar event. No particular reason for doing it that way other than picking a convention that was easy to remember.

This is my first foray into messing about with plugins, so feedback or suggestions are welcome.


Code: [Select]
diff -urw orig/D_GCal.json delta/D_GCal.json
--- orig/D_GCal.json 2012-11-10 15:23:45.000000000 -0500
+++ delta/D_GCal.json 2012-11-12 11:21:07.000000000 -0500
@@ -259,6 +259,100 @@
                             }
                         ]
                     }
+                },
+                {
+                    "ControlType": "label",
+                    "Label": {
+                        "lang_tag": "StartDelta",
+                        "text": "Start Delta : "
+                    },
+                    "text_align": "center",
+                    "Display": {
+                        "Top": 205,
+                        "Left": 50,
+                        "Width": 75,
+                        "Height": 20
+                    }
+                },
+                {
+                    "ControlType":"input",
+                    "ID": "NewStartDelta",
+                    "Display":{
+                        "Top": 200,
+                        "Left":150,
+                        "Width": 300,
+                        "Height": 20
+                    }
+                },
+                {
+                    "ControlType": "button",
+                    "Label": {
+                        "lang_tag": "setStartDelta",
+                        "text": "Set"
+                    },
+                    "Display": {
+                        "Top": 200,
+                        "Left": 500,
+                        "Width": 75,
+                        "Height": 20
+                    },
+                    "Command": {
+                        "Service": "urn:utz-com:serviceId:GCal1",
+                        "Action":  "SetStartDelta",
+                        "Parameters": [
+                            {
+                                "Name": "NewStartDelta",
+                                "ID": "NewStartDelta"
+                            }
+                        ]
+                    }
+                },
+                {
+                    "ControlType": "label",
+                    "Label": {
+                        "lang_tag": "EndDelta",
+                        "text": "End Delta : "
+                    },
+                    "text_align": "center",
+                    "Display": {
+                        "Top": 255,
+                        "Left": 50,
+                        "Width": 75,
+                        "Height": 20
+                    }
+                },
+                {
+                    "ControlType":"input",
+                    "ID": "NewEndDelta",
+                    "Display":{
+                        "Top": 250,
+                        "Left":150,
+                        "Width": 300,
+                        "Height": 20
+                    }
+                },
+                {
+                    "ControlType": "button",
+                    "Label": {
+                        "lang_tag": "setEndDelta",
+                        "text": "Set"
+                    },
+                    "Display": {
+                        "Top": 250,
+                        "Left": 500,
+                        "Width": 75,
+                        "Height": 20
+                    },
+                    "Command": {
+                        "Service": "urn:utz-com:serviceId:GCal1",
+                        "Action":  "SetEndDelta",
+                        "Parameters": [
+                            {
+                                "Name": "NewEndDelta",
+                                "ID": "NewEndDelta"
+                            }
+                        ]
+                    }
                 }
             ]
         },
Only in orig: D_GCal.xml
diff -urw orig/I_GCal.xml delta/I_GCal.xml
--- orig/I_GCal.xml 2012-11-10 15:24:00.000000000 -0500
+++ delta/I_GCal.xml 2012-11-12 11:40:24.000000000 -0500
@@ -41,6 +41,7 @@
 
  function requestCalendar(url)
          debug("GCAL: checking google calendar")
+                local startDelta = tonumber(luup.variable_get(GCAL_SID, "StartDelta", lul_device) or 0) * 60
 
          if (url == nil) then
                  debug("GCAL: google calendar private url is unset.")
@@ -56,7 +57,8 @@
          debug("GCAL: start-min: " .. s)
          url = url .. "&amp;start-min=" .. s
 
-         ta = os.date("!*t", now + UPDATE_FREQ)
+                -- ensure we look far enough ahead to account for a negative starting delta
+         ta = os.date("!*t", math.max(now + UPDATE_FREQ, now + UPDATE_FREQ - startDelta))
          s = string.format("%d-%02d-%02dT%02d:%02d:%02d.000Z", ta.year, ta.month, ta.day, ta.hour, ta.min, ta.sec)
          debug("GCAL: start-max: " .. s)
          url = url .. "&amp;start-max=" .. s
@@ -87,6 +89,8 @@
  function checkGCal()
          local gcallink = luup.variable_get(GCAL_SID, "gcallink", lul_device)
          local gcalon = luup.variable_get(GCAL_SID, "gcalon", lul_device)
+                local startDelta = tonumber(luup.variable_get(GCAL_SID, "StartDelta", lul_device) or 0) * 60
+                local endDelta = tonumber(luup.variable_get(GCAL_SID, "EndDelta", lul_device) or 0) * 60
 
          if (gcalon == nil) then
                  debug("GCAL: google calendar event name is unset. Retry later...")
@@ -138,8 +142,13 @@
 
          -- Compute the delay in seconds before the next event starts
          local now = os.time()
-         local diff_start = strToTime(json_entry_timestart) - now
-         local diff_end = strToTime(json_entry_timeend) - now
+         local diff_start = strToTime(json_entry_timestart) - now + startDelta
+         local diff_end = strToTime(json_entry_timeend) - now + endDelta
+
+                if (diff_end &lt; 0) then
+                    debug("Event already ended (after delta was applied).")
+                    return {UPDATE_FREQ, "timeout", "" }
+                end
 
          if (diff_start &lt; 0) then
                  debug("GCAL: Event running for " .. - diff_start .. " seconds until " .. diff_end .. " seconds.")
@@ -227,6 +236,16 @@
  luup.variable_set(GCAL_SID, "gcalval", "", lul_device)
  end
         
+                local startDelta = luup.variable_get(GCAL_SID, "StartDelta", lul_device)
+                if (startDelta == nil) then
+                        luup.variable_set(GCAL_SID, "StartDelta", "0", lul_device)
+                end
+
+                local endDelta = luup.variable_get(GCAL_SID, "EndDelta", lul_device)
+                if (endDelta == nil) then
+                        luup.variable_set(GCAL_SID, "EndDelta", "0", lul_device)
+                end
+        
          GCalTimer(json.encode({"startup", "", interrupt}))
  end
   </functions>
@@ -249,7 +268,7 @@
      <name>GCalCheck</name>
      <run>
  luup.log(string.format("GCAL: Manual Check Calendar"))
- luup.task(tostring("Manual Check Calendar"), 1, luup.devices[lul_device].description, -1)
+ -- luup.task(tostring("Manual Check Calendar"), 1, luup.devices[lul_device].description, -1)
 
  interrupt = interrupt + 1
  GCalTimer(json.encode({"manual", "", interrupt}))
@@ -263,7 +282,7 @@
 
  if (lul_settings.NewGCalLink == nil) then
  debug("GCAL: gcallink is nil.")
- luup.task(tostring("Calendar link can not be empty!"), 1, luup.devices[lul_device].description, -1)
+ -- luup.task(tostring("Calendar link can not be empty!"), 1, luup.devices[lul_device].description, -1)
  return
  end
 
@@ -276,7 +295,7 @@
        debug("GCAL: Set Calendar id : " .. gcalsrc)
        debug("GCAL: Set Calendar Link : " .. gcallink)
 
-        luup.task(tostring("Set Calendar Link"), 1, luup.devices[lul_device].description, -1)
+        -- luup.task(tostring("Set Calendar Link"), 1, luup.devices[lul_device].description, -1)
      </run>
   </action>
   <action>
@@ -288,7 +307,7 @@
  local gcalon = lul_settings.NewGCalOn
  if (gcalon == nil) then
  debug("GCAL: gcalon is nil.")
- luup.task(tostring("All events will be triggered."), 1, luup.devices[lul_device].description, -1)
+ -- luup.task(tostring("All events will be triggered."), 1, luup.devices[lul_device].description, -1)
  gcalon = ""
  end
 
@@ -296,7 +315,33 @@
 
        debug("GCAL: Set Calendar event : " .. gcalon)
 
-        luup.task(tostring("Set Calendar Event"), 1, luup.devices[lul_device].description, -1)
+        -- luup.task(tostring("Set Calendar Event"), 1, luup.devices[lul_device].description, -1)
+     </run>
+   </action>
+   <action>
+     <serviceId>urn:utz-com:serviceId:GCal1</serviceId>
+     <name>SetStartDelta</name>
+     <run>
+        luup.log(string.format("GCAL: set calendar start delta (StartDelta)"))
+
+        local startDelta = lul_settings.NewStartDelta
+
+        debug("GCAL: Set Calendar Start Delta : " .. startDelta)
+
+        luup.variable_set(GCAL_SID, "StartDelta", startDelta, lul_device)
+     </run>
+   </action>
+   <action>
+     <serviceId>urn:utz-com:serviceId:GCal1</serviceId>
+     <name>SetEndDelta</name>
+     <run>
+        luup.log(string.format("GCAL: set calendar end delta (EndDelta)"))
+
+        local endDelta = lul_settings.NewEndDelta
+
+        debug("GCAL: Set Calendar End Delta : " .. endDelta)
+
+        luup.variable_set(GCAL_SID, "EndDelta", endDelta, lul_device)
      </run>
    </action>
   </actionList>
Only in orig: J_GCal.js
diff -urw orig/S_GCal.xml delta/S_GCal.xml
--- orig/S_GCal.xml 2012-11-10 15:24:19.000000000 -0500
+++ delta/S_GCal.xml 2012-11-12 11:21:43.000000000 -0500
@@ -17,6 +17,19 @@
       <datatype>string</datatype>
       <defaultValue>ON</defaultValue>
     </stateVariable>
+
+     <stateVariable sendEvents="no">
+      <name>StartDelta</name>
+      <sendEventsAttribute>no</sendEventsAttribute>
+      <datatype>i4</datatype>
+      <defaultValue>0</defaultValue>
+     </stateVariable>
+     <stateVariable sendEvents="no">
+      <name>EndDelta</name>
+      <sendEventsAttribute>no</sendEventsAttribute>
+      <datatype>i4</datatype>
+      <defaultValue>0</defaultValue>
+     </stateVariable>
   </serviceStateTable>
   <actionList>
     <action>
@@ -40,5 +53,24 @@
         </argument>
       </argumentList>
     </action>
+
+    <action>
+      <name>SetStartDelta</name>
+      <argumentList>
+        <argument>
+          <name>NewStartDelta</name>
+          <direction>in</direction>
+        </argument>
+      </argumentList>
+    </action>
+    <action>
+      <name>SetEndDelta</name>
+      <argumentList>
+        <argument>
+          <name>NewEndDelta</name>
+          <direction>in</direction>
+        </argument>
+      </argumentList>
+    </action>
   </actionList>
 </scpd>
Title: Re: Google Calendar Switch
Post by: SM2k on November 25, 2012, 11:52:48 am
Thanks for the update, utz!

In the latest release of this plugin, the state icon of the sensor no longer changes when inside an event. If you prefer that, then add these lines right above the "doc_url" line in D_GCal.json

Code: [Select]
    "state_icons": [
        "Motion_Sensor_0.png",
        "Motion_Sensor_100.png"
    ],
Title: Re: Google Calendar Switch
Post by: SM2k on November 25, 2012, 12:20:41 pm
I propose changing line 37 of I_GCal.xml

from:
Code: [Select]
                return os.time({isdst=true,year=year,month=month,day=day,hour=hour,min=minute,sec=second}) + get_timezone()

to:
Code: [Select]
                return os.time({isdst=os.date("*t").isdst,year=year,month=month,day=day,hour=hour,min=minute,sec=second}) + get_timezone()

Since we're currently in standard time, sensors appear to be firing an hour early because isdst was hard coded to true.

The above code construct introduces a tiny race race condition because get_timezone also computes the current time, but I think you'd have calendar events at 1 or 2 AM and be absurdly unlucky for that to make a difference.
Title: Re: Google Calendar Switch
Post by: psykokwak on November 28, 2012, 05:45:17 am
A new version is available (1.24) which fix the DST bug and that add two new variables :
- gcalinterval define the calendar polling interval in seconds
- gcalnextevent return a string about the next event (in the gcalinterval window).

Let me know if you have any question.
Title: Google Calendar Switch for "Other" not Private types
Post by: aecchalet on November 29, 2012, 04:50:38 pm
I am still looking for someone I can pay to customize this plug in so that it will read from an "other" type of Google calendar rather than the required private type.   (I mistakenly removed my previous solicitation and reasons for needing it.)
Contact me via private message if interested and with quote.
Thanks
Title: Re: Google Calendar Switch
Post by: psykokwak on December 17, 2012, 07:52:49 am
aecchalet: Explain me exactly what kind of calandar you want to add ? You can respond by PM.
Title: Re: Google Calendar Switch
Post by: armand on December 22, 2012, 04:51:08 am
thank you psykokwak for the DST fix, but I still have some strange log:

Quote
50      12/22/12 0:00:10.101    luup_log:29: GCAL: checking google calendar <0x2d6d5680>
50      12/22/12 0:00:10.101    luup_log:29: GCAL: start-min: 2012-12-21T23:00:10.000Z <0x2d6d5680>
50      12/22/12 0:00:10.102    luup_log:29: GCAL: start-max: 2012-12-22T03:00:10.000Z <0x2d6d5680>

Is it normal to check calendar 1 hour before current time ?

Because in some cases (same event two consecutive days):

Quote
50      12/22/12 0:00:10.338    luup_log:29: GCAL: Event running for 86410 seconds until -10 seconds. <0x2d6d5680>
...
50      12/22/12 0:00:10.344    luup_log:29: GCAL: Timer: Next event "end" in -10 seconds <0x2d6d5680>

 And the next gcal check after gcalinterval doesn't occurs
Title: Re: Google Calendar Switch
Post by: psykokwak on December 25, 2012, 06:18:21 am
Hi Armand,
What is your time zone ?
All plugin times are UTC.
Title: Re: Google Calendar Switch
Post by: S-F on December 29, 2012, 09:08:22 am
I have a feature request. It would be great if the calendar switch could be tripped if there is an entry any time during the day. For example, I have a scene to wake me up in the morning and I don't want it to run if I don't have to work. Naturally this occurs before I have to be at work. Currently I'm making all day events in the calendar called "No Work" on days when I don't have to work. If I could have the switch tripped all day for regular calendar events, such as one entitled "Work" which I already have, my life would be a lot less complicated and a lot less cluttered.

Otherwise this plugin is fantastic.
Title: Re: Google Calendar Switch
Post by: parkerc on December 29, 2012, 01:21:28 pm
S-F - Have you seen the Virtual Clock plugin (App Store) that might be of interest?
Title: Re: Google Calendar Switch
Post by: S-F on December 30, 2012, 03:58:20 pm
S-F - Have you seen the Virtual Clock plugin (App Store) that might be of interest?

How is it you think the Virtual Clock could solve this conundrum?
Title: Re: Google Calendar Switch
Post by: parkerc on December 30, 2012, 04:06:11 pm
You said..

I have a scene to wake me up in the morning and I don't want it to run if I don't have to work..

The Virtual Clock Plugin allows you to run a specific scene on specified days and at a specific time  (e.g Mon to Fri), I have 2 and use one to run events on work days and another for weekends (e.g i have the heating and lights come on earlier during the week)

It was just a thought considering the point you made, I  might be way off but wanted to put it out there just in case..
Title: Re: Google Calendar Switch
Post by: S-F on December 30, 2012, 05:39:23 pm
Ahhh, OK. That's what I thought. I manage it with the built in scheduling functionality in Vera. I have been for a couple years now with no issues. The problem is getting the scene to NOT run when I don't have to work.
Title: Re: Google Calendar Switch
Post by: parkerc on December 30, 2012, 05:56:00 pm
I love a challenge ;) ok, so rather than a calendar entry, what else could show you're not at work?

For example , is there any reason why you cant set the scene itself to check if a certain sensor is tripped or if a virtual switch is on/off to show that you're not working. Then if it sees that, then you can code the scene not to run.

This may be better placed in a seperate thread ;)
Title: Re: Google Calendar Switch
Post by: armand on January 04, 2013, 08:20:41 am
Hi Armand,
What is your time zone ?
All plugin times are UTC.

Hi psykokwak,
I set my Vera Lite with Paris timezone, so it probably explains the offset.
There is a possibility to change timezone for plugins also?

Title: Re: Google Calendar Switch
Post by: psykokwak on January 05, 2013, 07:58:23 am
Hi Armand,
What is your time zone ?
All plugin times are UTC.

Hi psykokwak,
I set my Vera Lite with Paris timezone, so it probably explains the offset.
There is a possibility to change timezone for plugins also?

Quelle est la durée de tes évènements google ? Il faut que ceux ci durent au moins une minute.
Le plugin communique avec google en UTC et fait la conversion à la timezone locale en se basant sur celle qui est configurée dans la vera.
Title: Re: Google Calendar Switch
Post by: armand on January 05, 2013, 05:00:02 pm
Hi Armand,
What is your time zone ?
All plugin times are UTC.

Hi psykokwak,
I set my Vera Lite with Paris timezone, so it probably explains the offset.
There is a possibility to change timezone for plugins also?

Quelle est la durée de tes évènements google ? Il faut que ceux ci durent au moins une minute.
Le plugin communique avec google en UTC et fait la conversion à la timezone locale en se basant sur celle qui est configurée dans la vera.

ce sonts des evenements 'journee entiere'. Et ca coince quand un événement se termine a la même heure que le début du suivant (minuit dans mon cas)
Title: Re: Google Calendar Switch
Post by: psykokwak on January 05, 2013, 05:15:06 pm
Ok, je note, je vais regarder ça.
Title: Re: Google Calendar Switch
Post by: armand on January 06, 2013, 04:33:48 pm
Ok, je note, je vais regarder ça.

Merci !
Title: Re: Google Calendar Switch
Post by: pollip1 on January 10, 2013, 08:09:23 am
*Tried to quote preview entry from Idlewild but it gets disallowed*



Hi Idlewild

I've tried putting this code into the "Heating On" scene (which is triggered by the GCal sensor). I have changed the devide numbers in the top two lines to match my GCal sensor and Thermostat but it doesn't send the variable to the thermostat.

Am I on the right path so far? And are there other parts of your code which I need to customise as well as the device numbers?

Please can you help!??

Thanks
Title: Re: Google Calendar Switch
Post by: pollip1 on January 10, 2013, 08:13:06 am
Sorry, now I've had to remove the original quote my comment has no context. This in response to Idlewild's comment:

Reply #108 on: January 07, 2012, 08:05:27 pm

Re: Using the variable (eg {20}) and using it to set the temperature on a thermostat.
Title: Re: Google Calendar Switch
Post by: sleedham on January 23, 2013, 03:20:42 pm
Great addon! I've got it all set up, and have it working. The only thing I'm not sure of, is how to pass the variable to my thermostat? I can easily set up a scene, and have the calendar trip my thermostat to a certain temp., but how can I get it to take the number from google calendar, pass it to my thermostat and use that number?

I have the addon collection the variable, and it reads and stores it properly, I just don't know how to use it when creating the scene, and setting the thermostat

Thanks for any help!
Title: Re: Google Calendar Switch
Post by: garrettwp on January 24, 2013, 01:57:22 am
You will need to take that value and issue luup code in the scene to set the thermostat to the given value. Search the forum for thermostat and luup code. There are many posts that show how this can be done.

- Garrett

p.s. earlier in the thread shows how you can do this:

http://forum.micasaverde.com/index.php/topic,7558.msg58590.html#msg58590
Title: Re: Google Calendar Switch
Post by: pollip1 on January 24, 2013, 05:36:05 am
Hi garrettwp

Thanks for your comment. That post from Idlewild is the closest I've got to making it work yet, but I'm still not there. I'm am new to Luup and in fact to Vera. I can see three places to implement Luup code in Vera:

1) In a scene under 'luup'
2) In a scene under 'triggers'
3) In 'apps'\'develop apps'

Which is the right place to implement Idlewild's code?

Thanks v much.
Title: Re: Google Calendar Switch
Post by: garrettwp on January 24, 2013, 06:21:30 am
Number 2 would be the first choice as this will go in the trigger for the calendar being tripped. Number 1 would be the second choice, but this will run on any trigger for the scene. Number 3 is for testing code only.

- Garrett
Title: Re: Google Calendar Switch
Post by: pollip1 on January 24, 2013, 06:43:10 am
Ah, that's a helpful explanation. Thanks.
Title: Re: Google Calendar Switch
Post by: sleedham on January 24, 2013, 11:58:04 am
Thanks! Got it working!
Title: Re: Google Calendar Switch
Post by: brian.k on January 24, 2013, 12:38:56 pm
Thanks for a great plugin.  I'm just getting started using it and already I'm thankful for some of the enhancements that others have requested before me.

If the Keyword is not set, so all events trigger the device, is there a variable that contains the event title when it is running and when it exits?  From the I_GCal.xml it looks like it might be possible to parse the gcalnextevent for the title, but I'm not certain that works or if the value will exist during start triggers, end triggers, both or neither.  (Plus my lua/LUUP skills are probably not up to accurate parsing of variable data.)

It would be nice to have access to the following variables when scripting trigger LUUP code:
On tripped
On un-tripped

This would enable the triggers do take specific actions for certain event titles when they trip and when they end, either by intended event date ranges or by GCal ranges.  I can see combining these into scripts to control multiple thermostats or other devices with a single GCal adding logic that targets some titles explicitly, and knowing the parameters of the event that just ended to take specific action(s).

Please pardon if any of my request shows how novice I really am.  Just let me know.  Thanks - Brian
Title: Re: Google Calendar Switch
Post by: hbcameron on January 31, 2013, 08:48:18 pm
I am looking for some help...  I have spent way too much time trying to figure this out.  I can't make this code work when the event shows tripped...

Code: [Select]
local lul_tmp = luup.variable_get("urn:utz-com:serviceId:GCal1","Tripped", 77)
if lul_tmp == "1" then
return true
else return false
end

I have tried this one:

Code: [Select]
local lul_tmp = luup.variable_get("urn:utz-com:serviceId:GCal1","Tripped", 77)
if tonumber(lul_tmp) == 1 then
return true
else return false
end

Can anyone give me an idea of what i am doing wrong?

Title: Re: Google Calendar Switch
Post by: RichardTSchaefer on January 31, 2013, 09:21:21 pm
Code: [Select]
lul_tmp = luup.variable_get("urn:utz-com:serviceId:GCal1","Tripped", 77)
return (lul_tmp == "1)
Title: Re: Google Calendar Switch
Post by: hbcameron on January 31, 2013, 09:48:32 pm
That won't work either... I get a error messages using what you typed and also
Code: [Select]
lul_tmp = luup.variable_get("urn:utz-com:serviceId:GCal1","Tripped", 77)
return (lul_tmp == "1")
Title: Re: Google Calendar Switch
Post by: sjolshagen on January 31, 2013, 09:51:50 pm
That won't work either... I get a error messages using what you typed and also
lul_tmp = luup.variable_get("urn:utz-com:serviceId:GCal1","Tripped", 77)
return (lul_tmp == "1")

Isn't it supposed to be "Status" and not "Tripped"?

Code: [Select]
lul_tmp = luup.variable_get("urn:utz-com:serviceId:GCal1","Status", 77)
return (lul_tmp == "1")
Title: Re: Google Calendar Switch
Post by: RichardTSchaefer on January 31, 2013, 09:52:33 pm
Actually I assumed you knew the right serviceid ... it's wrong! You know what they say about (ASS U ME)
To find it ... goto the advanced tab ... let your mouse hover over the variable name.
It will show you the serviceid ... Double check your device # while you are at it.
Title: Re: Google Calendar Switch
Post by: sjolshagen on January 31, 2013, 10:05:44 pm
Isn't it supposed to be "Status" and not "Tripped"?

Nope, it's not! http://forum.micasaverde.com/index.php/topic,7558.msg69404.html#msg69404 (http://forum.micasaverde.com/index.php/topic,7558.msg69404.html#msg69404)
Title: Re: Google Calendar Switch
Post by: hbcameron on January 31, 2013, 10:27:31 pm
Yea! Thanks for everyone's help...

Code: [Select]
lul_tmp = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped", 77)
return (lul_tmp == "1")
Works!
Title: Re: Google Calendar Switch
Post by: brian.k on February 02, 2013, 02:06:54 pm
Sorry for the repeat, but I don't see an answer to this one...

If the Keyword is not set, so all events trigger the device, is there a variable that contains the event title when it is tripped and when it exits?

Also, how can I use the offsets to trigger a scene x minutes before or after the event?  Is it that the GCal trips that much earlier and later, or am I supposed to use those values in LUUP code manually?

And if I use the offsets is there still a property that changes or event that fires at the actual start?

Thanks!
Title: Re: Google Calendar Switch
Post by: brian.k on February 04, 2013, 04:15:16 pm
Note on my previous...
 
Also, how can I use the offsets to trigger a scene x minutes before or after the event?  Is it that the GCal trips that much earlier and later, or am I supposed to use those values in LUUP code manually?

And if I use the offsets is there still a property that changes or event that fires at the actual start?

By offset, I was referring to the StartDelta and EndDelta that I now see were proposed (by smk2?) but are not implemented.  I'll have to look at how I might include some of that capability via LUUP or modifying my implementation.

My other question about getting the name of the event that was triggered or un-triggered when there is no keyword still applies.

Thanks!
Title: Re: Google Calendar Switch
Post by: SM2k on February 05, 2013, 12:37:54 pm
brian.k, the file trunk-6.zip on the google calendar plugin help page appears to be out of sync with the MiOS marketplace. There will be a small delay before I can download the app-store version and re-port the StartDelta/EndDelta patch. Glad to see it's useful to somebody!
Title: Re: Google Calendar Switch
Post by: brian.k on February 05, 2013, 12:46:22 pm
+1 for the changes that SM2k proposed and coded:
I went ahead and coded the change I previously mentioned. This patch adds settings for StartDelta and EndDelta which are measured in minutes. The main intent of this is to be able to coordinate multiple different actions based on a single calendar event.

Both StartDelta and EndDelta are *added* to the beginning and end of the original calendar event respectively. That is to say a negative delta will cause the sensor to fire earlier than the calendar event. No particular reason for doing it that way other than picking a convention that was easy to remember.
...

Having the StartDelta and EndDelta allow you to anticipate the calendar event.  So a calendar which indicates a room will be in use at 9am can trigger X minutes in advance so the thermostat can heat/cool the room before the event starts.  Likewise lights can be turned off Y minutes after the event ends.  The person administering the calendar does not need to compensate for the delays since the GCal would.

See SM2k's post and Delta.zip file which was based on the last public release.
Title: Re: Google Calendar Switch
Post by: SM2k on February 05, 2013, 01:09:22 pm
brian.k, it turns out you are correct. The delta patch is based on the latest release. I was mistaken about the trunk-6.zip being out of date.
Title: Re: Google Calendar Switch
Post by: garrettwp on February 15, 2013, 03:22:32 pm
I wanted to post that I made some changes to the Google Calendar Switch to save the title (keyword) value in the device. I also added an event trigger when creating scenes to check against a certain keyword. For example, if you create a scene and add a new trigger, you'll have the ability to select a trigger that matches a specified keyword. This allows for having only one google calendar switch and say one scene if you want to create a schedule for heating and cooling. I also modified the plugin to only load the needed modules e.g. json, http when needed. This should free up a little memory.

I have attached the modified files.

- Garrett
Title: Re: Google Calendar Switch
Post by: psykokwak on February 16, 2013, 07:11:56 am
Hi Garrett,
Could you provide me the diff files ?
If you are agree, I can add your modification into the plugin on the Mios Market.
Title: Re: Google Calendar Switch
Post by: garrettwp on February 16, 2013, 08:31:54 am
As requested.

- Garrett
Title: Re: Google Calendar Switch
Post by: psykokwak on February 17, 2013, 05:52:59 am
Thanks.
A new version w/ your patch is waiting for approval on the mios market.
Title: Re: Google Calendar Switch
Post by: keon on February 19, 2013, 02:43:48 pm
I Just updated to the new module with Garretts changes.  My question is this...

When you use a single plugin to trigger multiple events based on a keyword, how to you set it up to see different calendar events?

Example:
I have times in Gcal set as follows:
0700 "HI" - turn heat to high setting for when I get up
0900 "LOW" turn heat to low setting for when I go to work
1700 "HI" turn heat back to high setting when I return
2300 "LOW" turn heat to low for bed

I have the plugin module set with the keyword "HI" and it will trigger on the "HI" entries, but how to i get it to look for the "LOW" entries?

Do i need to run another instance of the plugin?
Title: Re: Google Calendar Switch
Post by: garrettwp on February 20, 2013, 06:12:24 am
I Just updated to the new module with Garretts changes.  My question is this...

When you use a single plugin to trigger multiple events based on a keyword, how to you set it up to see different calendar events?

Example:
I have times in Gcal set as follows:
0700 "HI" - turn heat to high setting for when I get up
0900 "LOW" turn heat to low setting for when I go to work
1700 "HI" turn heat back to high setting when I return
2300 "LOW" turn heat to low for bed

I have the plugin module set with the keyword "HI" and it will trigger on the "HI" entries, but how to i get it to look for the "LOW" entries?

Do i need to run another instance of the plugin?

No need to create another instance of the plugin. First, you will need to remove the keyword trigger from the calendar plugin. Second, you will need to create a scene and in the scene trigger section you will want to create a new trigger with the calendar plugin as the device and select the "A calendar event matches keyword" trigger. You will then enter the keyword in the keyword text field. Then add the actions you would like to have performed for that trigger. I have mine set to run luup code for that trigger. I have attached a few images.

- Garrett
Title: Re: Google Calendar Switch
Post by: roelloaded on February 24, 2013, 04:31:00 pm
hello, I used this fantastic plugin for a few days until I had to reset my vera3 with firmware 1.5.459: I reinstalled all applications but "Google Calendar Switch" no longer works and returns me "GCal Sensor [12]: Startup Lua Failed ". I have tried uninstalling and reinstalling, reset again vera3, but no longer worked. I can do some checking on the code?  :'(
Title: Re: Google Calendar Switch
Post by: psykokwak on March 02, 2013, 06:20:43 am
Ok, there was an error during the plugin publish on the market.
I just request for approval a new version that fix this issue.
Sorry...

In the meantime, you can put this file : http://code.mios.com/trac/mios_google-calendar-plugin/browser/trunk/json.lua?format=txt in your /usr/lib/lua directory.
Title: Re: Google Calendar Switch
Post by: beerguy on March 07, 2013, 07:39:50 pm
Hi. I had your switch working on a different vera lite and loved it. Thanks for the hard work. It's a great plugin for managing a remote property.

I'm now trying to install in on another vera and am getting the error. Your instructions to put the file in the /usr/lib/lua directory are beyond my experience. Can I do that through the UI5 interface under Apps or do I need to SSH in to do it?

Thanks again for the plugin.

Pat
Title: Re: Google Calendar Switch
Post by: zolk on March 09, 2013, 10:30:51 pm
Should I uninstall first?
What should be the correct file name json.txt or json.lua?
(I tried both, nothing helped)
Thanks
Title: Re: Google Calendar Switch
Post by: S-F on March 15, 2013, 09:02:39 pm
I went ahead and coded the change I previously mentioned. This patch adds settings for StartDelta and EndDelta which are measured in minutes. The main intent of this is to be able to coordinate multiple different actions based on a single calendar event.

Both StartDelta and EndDelta are *added* to the beginning and end of the original calendar event respectively. That is to say a negative delta will cause the sensor to fire earlier than the calendar event. No particular reason for doing it that way other than picking a convention that was easy to remember.

This is my first foray into messing about with plugins, so feedback or suggestions are welcome.



Is the patch posted here still viable? This functionality would be VERY helpful to me. I could have it toggle a virtual switch which in turn effects some of my work/sleep related scenes.

Why has this not been implemented into the plugin already?
Title: Re: Google Calendar Switch
Post by: brian.k on March 19, 2013, 12:32:55 pm
S-F, that patch was never integrated into the main code to my knowledge.  Because I too thought it was very valuable, I did merge it into a branch of an older version of G-Cal.  It has allowed me to set up events with actual start and end times, then set thermostats to pre-heat or pre-cool the room using one GCal with a start delta for the thermostat and one without for lights and other systems.  There were still some issues with that version (like not properly updating the device screen to show the delta's after they were set).

Unfortunately my branch does not include the great additions that have been made to GCal since then which optimize memory footprint and enhance multi-use GCal's.  Hopefully with others interested in it, it will be added back to the plugin market version.  Brian.
Title: Re: Google Calendar Switch
Post by: averell on March 22, 2013, 07:36:05 am
Nice plugin, however I found that I need to make my calendat "public"to be able to access it from the vera, else I get a 403, and a "no data". I would prefer not to share my calendar with the world, how can I use the calendar plugin to pass credentials?

Thanks,
Averell
Title: Re: Google Calendar Switch
Post by: gengen on March 25, 2013, 01:16:01 am
Here is a UPnP fix for the Google Calendar Switch version 1.251 which fixes problmes with the XML to allow it to work better with UPnP tools such as Device Spy.

Please see my post earlier today regarding updated UPnP tools to make these types of bugs easier to find and fix
Title: Re: Google Calendar Switch
Post by: Jamr on April 25, 2013, 02:10:42 am
What is the latest on this plugin. I would love to use it. I have tried every link from the calendar settings page and still can not get it to switch.
Any info would be useful.
Thanks
Jamr
Title: Re: Google Calendar Switch
Post by: garrettwp on April 25, 2013, 03:34:52 am
The plugin should be fully functional. I use it everyday for my hvac system and other things. Have you tried using the private xml address for the calendar you want to share located in the calendar settings?

- Garrett
Title: Re: Google Calendar Switch
Post by: Shaigan on April 25, 2013, 08:41:37 am
I've only a bug with fullday event : sometime, they dont untrig.
Using a 00:01 - 23:59 event, there is no problem.

--
via Samsung Galaxy S
Title: Re: Google Calendar Switch
Post by: xben007 on May 07, 2013, 12:31:04 pm
Hi !

I also have the "untrigger" bug. I use a google calendar with public holidays (so day events) but I have to manually click on the "check" button to untrigger on the next day.
And for some reason, the calendar tab does not always show (just a blank tab instead of the calendar which was displayed correctly when I did the set-up).
Title: Re: Google Calendar Switch
Post by: Jamr on June 11, 2013, 05:19:56 pm
I have installed the app and can see the calendar on the calendar tab but I still can not get it to work.

In Vera / Gcal sensor / calendar tab, I can view the calendar and events created by our rental web site. These events are automatically generated when a guest makes a reservation.
The text that is generated for the event is "(15:00) RESERVE" Sometimes the time is different depending on when the guest checks in.

Q. Can I use keyword "RESERVE" alone to detect these events? Or do I need to have the whole "(15:00) RESERVE"?
Q. If I need the whole keyword, how do I do that knowing the time may be different?

When I try either keyword, I do not get any visual notification that it's state has changed.
Q. How do I determine this?

Q. If I want to turn on my heater 1 hour before the check in time, how do I do this?

Sorry if these topics are covered here. I did read the install instructions and I did a quick search and could not find them. With 15 pages on this thread, I did not read it all.
Thanks for your time.
Jamr
Title: Re: Google Calendar Switch
Post by: S-F on June 11, 2013, 06:02:27 pm
1.) You only need to specify a single word. You can of course use more than one word. The word/s must be in the title of the calendar event.

2.) I'm sorry but I don't follow you here. Could you please elaborate or rephrase?

3.) When the word is detected

4.)I'm not sure what you mean by "check time". If you mean, can you have the plugin look into the future, the answer is a resounding NO. There was a patch available for a previous version of the plugin but it seems to have faded into the woodwork. This slays me as it is a SORELY needed feature!
Title: Re: Google Calendar Switch
Post by: Jamr on June 12, 2013, 09:09:37 pm
1.) You only need to specify a single word. You can of course use more than one word. The word/s must be in the title of the calendar event.

2.) I'm sorry but I don't follow you here. Could you please elaborate or rephrase?

3.) When the word is detected

4.)I'm not sure what you mean by "check time". If you mean, can you have the plugin look into the future, the answer is a resounding NO. There was a patch available for a previous version of the plugin but it seems to have faded into the woodwork. This slays me as it is a SORELY needed feature!

S-F, thanks for the reply.

I have the word "RESERVE" in my keywords box.
The calendar event has "(15:00) RESERVE" for it's title.
Prior to the event, if I click on the check button in the control tab, I see "no data" next to "Event" at the top of the Control tab page.
During the event, if I click on the check button in the control tab, I see "no data" next to "Event" at the top of the Control tab page.
Q. How do I know that the state of this module is changed?
As I understand it I can see no visual change in the module and it is not working correctly for me.
As I understand this plug-in, it is just a switch that switches state when the keyword is found in an event.

I went ahead and programmed a scene using this module and my thermostat. I wanted to raise the heat temp when it is time for someone to check into our rental.
In the Devices tab, I told my thermostat to raise the temp
In the trigger tab, I selected the "GCal Sensor"
I then selected the "A Calendar event matches Key Word"
I then named the trigger "Reservation Calendar Trigger"
I left the "Keyword Matches" at default "0" (I do not know what this setting is or does? Can someone please explain this setting.)

After installing this scene and clicking the check button all while I have a calendar event happening, my thermostat is still not rising.

Q. Does this app work on all calendars? The calendar I am using is what is called a "Other Calendar" in Google's settings. It is a calendar that gets it's data from someone else's calendar.


Thanks
Jamr
Title: Re: Google Calendar Switch
Post by: garrettwp on June 13, 2013, 01:46:12 am
The parameter for "Keyword Matches" needs to be the value that you want to have match against the calendar. So if you have a calendar title called Heat, the "Keyword Matches" value would have Heat. This will allow the scene to act on that keyword if and when it comes up. What do you have configured in the GCal plugin? Do you have anything set for the value of "gcalon"? What is the "gcalinterval" value set to as well? This can be found under the advance tab of the GCal plugin device.

- Garrett
Title: Re: Google Calendar Switch
Post by: Jamr on June 13, 2013, 02:02:10 pm
The parameter for "Keyword Matches" needs to be the value that you want to have match against the calendar. So if you have a calendar title called Heat, the "Keyword Matches" value would have Heat. This will allow the scene to act on that keyword if and when it comes up. What do you have configured in the GCal plugin? Do you have anything set for the value of "gcalon"? What is the "gcalinterval" value set to as well? This can be found under the advance tab of the GCal plugin device.

- Garrett

Garett, thanks for your reply,

As stated above, the gcalon or "Keyword" is "RESERVE". That is only part of the entire title of the calendar of "(15:00) RESERVE" According to S-F this will work.
I have set the "gcalinterval" to 1800. This should be 30 minutes.

So if I understand this process correctly, it will check every 30 minutes to see if if there is a calendar event currently active (at the present time) with the word RESERVE in the title of it.
Is this correct?

If this is correct, right now it is in that situation and it does not show any sign of changing it's state. It also does not raise the thermostats heat temp as programmed.

There has to be something I am missing.
Title: Re: Google Calendar Switch
Post by: RichardTSchaefer on June 13, 2013, 06:39:38 pm
Actually the Plugin pulls down future schedules. I do not remember the look ahead time.
So even if you only poll every 30 minutes, if a previous poll found an issue that will trigger 15 minutes from now, it should already handle that properly. If the schedule was static you would only need to poll at the interval of it's look ahead. The reason to poll more often is find recent changes to the calendar.
 

Title: Re: Google Calendar Switch
Post by: Jamr on June 13, 2013, 06:45:27 pm
Actually the Plugin pulls down future schedules. I do not remember the look ahead time.
So even if you only poll every 30 minutes, if a previous poll found an issue that will trigger 15 minutes from now, it should already handle that properly. If the schedule was static you would only need to poll at the interval of it's look ahead. The reason to poll more often is find recent changes to the calendar.

So any insight as to why this app is not functioning? As it seems all of the setting are correct.
Title: Re: Google Calendar Switch
Post by: RichardTSchaefer on June 13, 2013, 07:03:08 pm
Sounds like it's not connecting to your calendar.
Title: Re: Google Calendar Switch
Post by: Jamr on June 13, 2013, 07:05:46 pm
Sounds like it's not connecting to your calendar.

I can see the calendar in the calendar tab. If I can see the calendar in the calendar tab, how is it not connecting?
Title: Re: Google Calendar Switch
Post by: S-F on June 13, 2013, 07:44:27 pm
Actually the Plugin pulls down future schedules.

Is there a way for the layperson to capitalize on this? I would like Vera to not tell me to go to bed if I don't have to work in the morning.
Title: Re: Google Calendar Switch
Post by: RichardTSchaefer on June 13, 2013, 08:30:20 pm
Quote
Is there a way for the layperson to capitalize on this? I would like Vera to not tell me to go to bed if I don't have to work in the morning.

They would need to add a trigger to Google Calendar for  XXX time before the event.
Because you want to stay up today if you are on holiday or vacation tomorrow.

And XXX would have to be less than the look ahead time. The best way to do this is to make the look ahead a configurable parameter. The longer it is, the more memory the Plugin consumes to store future info.

For now, you could create a calendar with Party Nights ... and populate it with the days before a holiday or vacation.




Title: Re: Google Calendar Switch
Post by: Jamr on June 14, 2013, 12:31:45 pm
Sounds like it's not connecting to your calendar.

I can see the calendar in the calendar tab. If I can see the calendar in the calendar tab, how is it not connecting?

Richard, maybe you missed it. How can I get it to connect more? Especially if I can see the calendar in the calendar tab.
Title: Re: Google Calendar Switch
Post by: garrettwp on June 14, 2013, 03:26:02 pm
Try removing the gcalon variable. Meaning remove what you added in that field and restart the luup engine. Does it report any events?

- Garrett

Title: Re: Google Calendar Switch
Post by: Jamr on June 14, 2013, 05:10:36 pm
Try removing the gcalon variable. Meaning remove what you added in that field and restart the luup engine. Does it report any events?

- Garrett

Garrett, thanks for the reply.
I did remove the gcalon variable of "RESERVE" and saved. I do not know how to restart the LUUP engine.
After the unit restarted it shows nothing in the gcalon box and "no data" at the top of the module.
I hope I did that right since I do not know how to restart the luup engine.
Is this what you expected? Why would it report anything if there is no keyword or gcalon variable?

Thanks for your help.
Title: Re: Google Calendar Switch
Post by: garrettwp on June 14, 2013, 07:39:15 pm
By not using a keyword in the gcalon variable, the gcal plugin will see all events in the calendar and not the keyword. Since I believe your gcal plugin is set to poll the calendar every thirty minutes, do you have any events happening with in the thirty minute time frame? As for restarting luup, you did just that by hitting the save button.

- Garrett

Title: Re: Google Calendar Switch
Post by: Jamr on June 14, 2013, 07:56:00 pm
By not using a keyword in the gcalon variable, the gcal plugin will see all events in the calendar and not the keyword. Since I believe your gcal plugin is set to poll the calendar every thirty minutes, do you have any events happening with in the thirty minute time frame? As for restarting luup, you did just that by hitting the save button.

- Garrett

Garrett, yea it still says "no data" above the green icon. I am clearly in a event in the calendar also.

Any recommendations as to get this to work?
Title: Re: Google Calendar Switch
Post by: garrettwp on June 15, 2013, 01:39:53 pm
I can say that by putting what is in your calendar title (e.g. (15:00) RESERVE). It works fine for me and my gcal plugin. See attached image. I would double check your calendar settings and make sure that nothing is in the gcalon field to see what upcoming events happen. Change your  gcalinterval to something like 43200 (12 hours). And see if it picks up anything.

- Garrett
Title: Re: Google Calendar Switch
Post by: S-F on June 15, 2013, 04:04:44 pm
@ Garret,

How exactly does the gcalinterval work?
Title: Re: Google Calendar Switch
Post by: garrettwp on June 15, 2013, 04:49:29 pm
It works by grabbing events upto the gcalinterval value. So if you have it set for twelve hours, it will looks for the next event in that time frame. Once it finds an event, it will setup a timer to trigger on that time. It will than fire / trip the plugin and grab the next event.

- Garrett

Title: Re: Google Calendar Switch
Post by: S-F on June 15, 2013, 05:12:42 pm
Ahhhhhh. I had been under the impression that it was the interval at which the plugin would check the calendar. So, for my particular scenario, I have my house start reminding me to go to bed around 8 PM. I have all day events for when I don't work, which presumably begin at 12:00 AM. If I set the gcalinterval to 4.5 hours it would be triggered at 7:30 PM if there were a no work event the entire next day?
Title: Re: Google Calendar Switch
Post by: gavinog on June 27, 2013, 06:00:33 pm
Sorry, I couldn't see an answer to this in the threat, or anyone ask it, so it's probably a really basic question.

I did a quick test with the calendar plugin and got it working, triggering a scene which just turns on a lamp. How do I get the lamp to turn off now, when the event is finished.. I realise this is probably quite basic and independent of the calendar plugin, but couldn't figure it out. The Vera interface really is not very intuitive.
Title: Re: Google Calendar Switch
Post by: Frasier on June 27, 2013, 06:16:34 pm
You'll need to create another scene to turn off the device unless you add a timer within the scene to switch it after your chosen delay.
Title: Re: Google Calendar Switch
Post by: gavinog on June 27, 2013, 06:46:59 pm
All sorted, thanks a lot for the help Frasier!
Title: Re: Google Calendar Switch
Post by: Bamsefar on July 05, 2013, 01:38:09 am
As completly new to Vera Lite, I found this plugin. It triggers great on my two instances, however it does not reset correctly on all-day events (which is what I use) - is there any way to solve this - I would hate to change from all-day events to 00.00 - 23.59 events...
Title: Re: Google Calendar Switch
Post by: Bamsefar on July 08, 2013, 03:25:43 am
One more question: Since a manual press on the key "CHECK" will resolve the issue with full day appointments not being refreshed, any chance one can trigger a "CHECK" automaticly thru http or something ?
Title: Re: Google Calendar Switch
Post by: xben007 on July 08, 2013, 03:33:28 am
I'd love to get an answer to this question too (I use a standard bank holidays calendar and obviously all events are "day events")
Title: Re: Google Calendar Switch
Post by: S-F on July 08, 2013, 04:23:10 am
I use all day events all the time and they work just fine. For what it's worth.
Title: Re: Google Calendar Switch
Post by: Bamsefar on July 09, 2013, 12:19:09 pm
One more question: Since a manual press on the key "CHECK" will resolve the issue with full day appointments not being refreshed, any chance one can trigger a "CHECK" automaticly thru http or something ?

And YES there is a workaround that at least works on my box. What I have done is create a scene which only purpose is to fire two http get commands at 00.05 each day. To do that I have a short LUUP code, which does the trick (do observer that you need to replace some parts, xxx = IP / yy = DeviceID for the GCal device):

Code: [Select]
local status, result = luup.inet.wget("http://xxx.xxx.xxx.xxx:3480/data_request?id=lu_action&output_format=json&DeviceNum=yy&serviceId=urn:utz-com:serviceId:GCal1&action=GCalCheck&&rand=0.6405106370233815", 5)
This works like a charm for me - let's hope it works for everybody else ?
Title: Re: Google Calendar Switch
Post by: garrettwp on July 09, 2013, 01:32:21 pm
One more question: Since a manual press on the key "CHECK" will resolve the issue with full day appointments not being refreshed, any chance one can trigger a "CHECK" automaticly thru http or something ?

And YES there is a workaround that at least works on my box. What I have done is create a scene which only purpose is to fire two http get commands at 00.05 each day. To do that I have a short LUUP code, which does the trick (do observer that you need to replace some parts, xxx = IP / yy = DeviceID for the GCal device):

Code: [Select]
local status, result = luup.inet.wget("http://xxx.xxx.xxx.xxx:3480/data_request?id=lu_action&output_format=json&DeviceNum=yy&serviceId=urn:utz-com:serviceId:GCal1&action=GCalCheck&&rand=0.6405106370233815", 5)
This works like a charm for me - let's hope it works for everybody else ?

There is no need to call luup.inet.wget to call a luup action with in a scene. Use the following:

Code: [Select]
local GCAL_SID = "urn:utz-com:serviceId:GCal1"
local GCAL_DEV = 5
luup.call_action( GCAL_SID, "GCalCheck", "", GCAL_DEV)

- Garrett
Title: Re: Google Calendar Switch
Post by: Shaigan on July 09, 2013, 03:50:22 pm
I didn't had the idea to check my GCals every days... Shame on me and thank for that ;)
Title: Re: Google Calendar Switch
Post by: garrettwp on July 09, 2013, 09:32:20 pm
The gcal plugin should have a variable to set for how often to check the calendar. I believe the default is 6 hours.

- Garrett

Title: Re: Google Calendar Switch
Post by: Bamsefar on July 10, 2013, 05:18:48 pm
Hi Garrett,

Thanks for the code - I am a bit new to this and thought that would be possible, but I figured the http version out first and since it works I stoped looking ;-)

Reason for running CHECK is since full day events do not disarm themself - however pressing CHECK does work, and by triggering CHECK every night at 01.00 or something will solve this issue. Of course it would be better if the plugin worked instead...
Title: Re: Google Calendar Switch Working with "Other Calendar"
Post by: aecchalet on July 21, 2013, 12:14:56 pm
This plug in was initially written to work with the XML link for the private address for your private google calendar.  I am still trying to get it to work with an "Other Calendar" (google type) that is created by my booking website.  Google's "Other Calendars" are only public and you can't make them private and can't get a XML for a private address.  Has anyone figured out a way to make this plug in work with a google public or "other calendar" type calendar?
I have an event called booked which begins and ends on my booking's check in and out date/time.  If I can get this plug in to work with my "other calendar", I can use this event to serve as my occupied vs unoccupied schedule.
Thanks for any assistance!
Title: Re: Google Calendar Switch Working with "Other Calendar"
Post by: Jamr on July 21, 2013, 05:33:09 pm
This plug in was initially written to work with the XML link for the private address for your private google calendar.  I am still trying to get it to work with an "Other Calendar" (google type) that is created by my booking website.  Google's "Other Calendars" are only public and you can't make them private and can't get a XML for a private address.  Has anyone figured out a way to make this plug in work with a google public or "other calendar" type calendar?
I have an event called booked which begins and ends on my booking's check in and out date/time.  If I can get this plug in to work with my "other calendar", I can use this event to serve as my occupied vs unoccupied schedule.
Thanks for any assistance!

I cant get it to work either.
My Other Calendar that gets data from my booking web site does have a XML link. What is the difference between the public ones and the private ones?
aecchalet, Are you able to get a XML link to your Other calendar? If so, are you able to see the calendars data in the app? I can do both of those and I still can't get it to work.
Title: Re: Google Calendar Switch
Post by: aecchalet on July 22, 2013, 02:25:09 pm
I can't get the XML links from my "other calendars" (public calendars) to work with this plugin.  There must be something peculiar to the private XML link that it allows it to work with this plugin but not public XML links.
Title: Re: Google Calendar Switch
Post by: aecchalet on July 22, 2013, 04:10:10 pm
Utz
"other calendars" or public calendars in google don't have an option to create a private link.  Is it possible to modify the program so one can enter the XML link from a public google calendar?
Thanks

Quote
My code is looking for something like:
http://www.google.com/calendar/feeds/XXXXXXXXXXXXX@group.calendar.google.com/private-XXXXXXXXXXXXXXX/basic

using the line
local gcalsrc = lul_settings.NewGCalLink:match("^http://www.google.com/calendar/feeds/(.*)@group.*$")

As your calendar link is something different it does not work. I havent looked at this for a while but there are several options in google to get the private link to a calendar and I suppose you picked the wrong one.
Title: Re: Google Calendar Switch
Post by: korttoma on August 12, 2013, 12:38:48 am
Seems like I'm stuck in the same situation as @Jamr.
Everything seems to be set up correctly but the "gcalnextevent" parameter sais "No Data" nomather what I do.

Br,
Tomas
Title: Re: Google Calendar Switch
Post by: mike Q on August 28, 2013, 11:01:23 pm
Sorry for the repeat, but I don't see an answer to this one...

If the Keyword is not set, so all events trigger the device, is there a variable that contains the event title when it is tripped and when it exits?


I've been trying to find an answer to this question. 

I'd like to be able to pass event titles to Vera Alerts.
Title: Re: Google Calendar Switch
Post by: Bamsefar on September 21, 2013, 08:31:41 am
I have a suggestion: If the google calender is NOT available (as in internet down or something, it does happen you know ;-) ) due to communication problems, it would be rather nice if the last event is stored, and when new date arrives, the same time is active ?

For example, I have an event between 9 and 11 a'clock every day. However one morning when Gcal searches for the calender, it get's a communication error/problem. With some luck it will solve it self - BUT if it does nog, then reuse last event on next day ?
Title: Re: Google Calendar Switch
Post by: mtncomm1 on September 26, 2013, 12:36:48 pm
Anyone have issues with Google Calendar switch causing Vera to go into a continual lua restart loop?

I have a Virtual Switch that triggers a PLEG scene. When the VSwitch is On, PLEG runs scene for "Occupied" device schedules at cabin. When VSwitch is Off, PLEG runs "Unoccupied" device schedules.

I want to add GCal Switch to turn the VSwitch On or Off, based on Occupied or Unoccupied keywords in Google calendar. When I tested it, Vera went into a continual lua startup loop. Only after removing the GCal Switch plugin, did everything return to normal.

Anyone else encounter this issue? Could it be a bug or incompatibility with too many virtual switches (GCal, virtual switch & PLEG) in the mix?

Thank you in advance for any input or ideas.
Title: Re: Google Calendar Switch
Post by: garrettwp on September 26, 2013, 03:33:08 pm
Nope, been running it for over a year, every day with out an issue.

- Garrett

Title: Re: Google Calendar Switch
Post by: RichardTSchaefer on September 26, 2013, 05:24:18 pm
You may have pushed Vera over the memory limit.

What type of Vera ?
Home many and what type of devices do you have ? (Z-Wave, Insteon, Plugin,
Light, Dimmer, Security Sensor, ...)

Do you have  USB stick for the Log ?

Title: Re: Google Calendar Switch
Post by: mtncomm1 on September 26, 2013, 09:27:29 pm
You may have pushed Vera over the memory limit.

What type of Vera ?
Home many and what type of devices do you have ? (Z-Wave, Insteon, Plugin,
Light, Dimmer, Security Sensor, ...)

Do you have  USB stick for the Log ?

Vera2 UI5 1.5.622
Not likely, minimal devices (under 5) on this one for testing purposes only.
No on the USB stick.

I did uninstall and reinstall GCal (for the third time) and it seems to be working now. Will try it on the "target" Vera Lite and see how it goes.

Thanks for the input.
Title: Re: Google Calendar Switch
Post by: Jericho48 on September 29, 2013, 03:05:47 am
Greetings!

I'm having a problem with this plug-in.  Specifically, despite setting up the plug-in per the published instructions (http://code.mios.com/trac/mios_google-calendar-plugin/ (http://code.mios.com/trac/mios_google-calendar-plugin/)), I am getting "No data" for the "gcalnextevent" variable.  The plug-in appears to be reading the calendar no problem, but fails to parse out the title of any event in a calendar entry.

I noticed other forum members having similar problems with this plug-in.  I also noticed that there does not seem to be a fix for the bug, or even a decent idea as to what is wrong.  So I did a little troubleshooting myself and I "think" I've narrowed down the culprit to one of two things:  1) Google Apps (http://www.google.com/intx/en/enterprise/apps/business/ (http://www.google.com/intx/en/enterprise/apps/business/)) GCals in general, or 2) Google Apps GCal with hyphens (a minus sign like this "-" ) in their domain name and/or email address.

I've set up a live demonstration top show the problem.

For starters, I set up a Test Google Calendar on a normal Google account, one with an email address ending in @gmail.com.  The calendar's private XML URL is:

https://www.google.com/calendar/feeds/nh23j6uhcmfe6511oda1fkifkc%40group.calendar.google.com/private-cc07b93fa99b5e3203eec4dfca7c28ad/basic

If you set up the Google Calendar Plugin, under the "Control" tab, using 1) the above URL for the "Link" to the Calendar and 2) leave the "Keyword" box blank, the plug-in functions as advertised.  Namely after placing the above information into the appropriate boxes and clicking the "Check" button you should see the event "Normal GCal: Good" show up.  Note also you can see the calendar on the plugin's "Calendar" tab.

Now let us move to a Google Calendar in a Google Apps account.

Before we get started, be advised that in Google Apps accounts "Private Addresses" for primary and secondary calendars (like the one you need for the "XML" file to make this plug-in work) are NOT shared by default with users outside of the Google App domain.  Thus, you must have your Google Apps site administrator turn that feature "ON" or there is no way this will work.

I completed that on my domain, so we can go onto the next step.  Namely, I control a Google Apps account with the domain "The-Green-Family.org."  On it, I created a test account that has the following private Google Calendar XML URL:

http://www.google.com/calendar/feeds/the-green-family.org_qv21k5bu3nnfb4butn4cq5okjg%40group.calendar.google.com/private-88d695cccbe4b554ec8455698074530d/basic

If you go through the same procedure as outlined above (loading the URL into the Google Calendar Plugin and so forth) and click the "Check" button, the event will display "No data."  Note that it display's "No data" even though you can see the calendar on the plugin's "Calendar" tab.

Thus, my "guess" is the Google Calendar Plugin cannot parse an event name from a Google Apps calendar.  Another problem could be with my domain name itself.  That is the plugin may not like the hyphens in my domain name (The-Green-Family.org) in-between "The," "Green," and "Family." 

Anyway, although I "think" I found the problem, I have no idea how to solve it  ::)  Thus, I was hoping psykokwak or whoever has taken the reins of this project update it to fix this little bug. 

I stand ready to assist if needed.  Till then, good luck and good hunting!

v/r
-Jericho48
Title: Re: Google Calendar Switch
Post by: EOppie on November 11, 2013, 12:00:21 am
Sorry if I am missing it here...however I think I am searching for StartDelta/EndDelta settings.

I downloaded the plugin from the MiOS marketplace, and was able to set it up with two different calendars.  My work schedule and my wife's vary, so setting a simple daily schedule doesn't work. I want to setup a morning "wakeup scene" for each of us, however I obviously want this to trigger prior to the start time in the calendar.

The other catch is we have a different commute time than one another, so I would need the "pre-trigger" to be different depending on the calendar.

Any idea on how to make this happen?

Thanks!
Title: Deleting *one* GCal Sensor instance
Post by: ih8gates on November 11, 2013, 02:28:27 pm
I have an extra Gcal Sensor device that I'd like to delete. I created an extra sensor before I understood how to use the sensor's "gcalkeyword" and "gcalval" to handle multiple possibilities in my code.

Now, I'd like to delete the extra gcal device. I believe that the one I want to delete is the first one that the plugin created.

After clicking delete, I get the first - expected - dialog asking "Do you want to delete this device?"

Then, I get a second that reads "Remove this plugin and any devices this plugin created?"

Which I DON'T want. I just want to remove the device. Hitting "cancel" on this second dialog aborts the whole process - the device isn't deleted.

Is there a way to delete this device? Is it "special" because it was the first one?
Title: Re: Google Calendar Switch
Post by: S-F on November 11, 2013, 02:46:23 pm
I think this applies to ALL gcal devices created. I have never been able to remove one without removing all of them. So now I just leave the one I don't want there blank and stupid doing nothing until I find a need for it and repurpose it.
Title: Re: Google Calendar Switch
Post by: Freddan101 on November 18, 2013, 02:55:09 am
This is a long thread so sorry if I missed it.

Is there a way to trigger events before the calendar entry? I would like to start the car heater using an entry that states when I'll be leaving home combined with the outdoor temperature. The colder it is the earlier the car heater will start, or not at all it it's "too warm".
Title: Re: Google Calendar Switch
Post by: S-F on November 18, 2013, 07:04:26 am
Yep. That's a great idea that I've thought about plenty. Unfortunately the GCal Switch is pretty simple and can only be used to trigger events immediately or after the event. It's an oft requested feature that somehow never made it to the main stream. There was a patch posted earlier in the thread which provided this functionality but for some reason unknown to me it never made it to the app store version.   :'(
Title: Re: Google Calendar Switch
Post by: Freddan101 on November 18, 2013, 05:49:07 pm
Yep. That's a great idea that I've thought about plenty. Unfortunately the GCal Switch is pretty simple and can only be used to trigger events immediately or after the event. It's an oft requested feature that somehow never made it to the main stream. There was a patch posted earlier in the thread which provided this functionality but for some reason unknown to me it never made it to the app store version.   :'(
Sorry to hear that this is not possible in the current version. It would be nice to let the plugin search for the next key word entry in the calendar and return the date and time. This way you could treat the trigger anyway you like.
Title: Re: Google Calendar Switch
Post by: ih8gates on November 23, 2013, 11:24:49 am
Can I get a bit of clarification on the timing of the GCal switch?

From reading over this thread, I understand that gcalinterval is how far into the future the plugin will look for calendar entries.

When the sensor is "tripped", it will look for the next calendar entry within gcalinterval.

When the plugin sees no event scheduled within the gcalinterval, how long will it wait until checking the calendar again - the gcalinterval period?


The practical issue I'm trying to understand: There's no event scheduled for the next 3.5hrs (gcalinterval of 12,600). If I put something on the calendar that's 4 hours from now, do I need to open the Gcal sensor and hit "check" to get it to look at the calendar?

I'm trying to figure out how much I can administrate just from the calendar and when I need to ask the sensor to re-check the calendar.

Am I correct that the sensor won't check the calendar again if it's found its next item within the gcalinterval? Meaning that if the next event that the sensor knows about is 3 hours out, if I put something on the calendar that's 2.5hrs out, the sensor won't know about that until I hit "check".

Thanks!
Title: Re: Google Calendar Switch
Post by: S-F on November 23, 2013, 03:43:43 pm
You never need to hit the Check button. The look ahead is simply like a cache of the calendar data. The sensor will be tripped for as long as the calendar entry is active.
Title: Re: Google Calendar Switch
Post by: ih8gates on November 23, 2013, 09:24:22 pm
I'm not saying that I hit the check button each time generally. I'm just wondering what conditions I can add a new event and not hit check. For instance, if I add an event to the calendar that's happening 10 minutes from now, obviously, the calendar sensor won't see it.
Title: Re: Google Calendar Switch
Post by: S-F on November 23, 2013, 11:29:33 pm
What? Why not?


I must admit that it does take much too long for the plugin to see the calendar in a new instance of the plugin,,,,

That being said, I see, basically, instantaneous results from the current implementation. I have only hit the check button when trying to verify that a new instance of the plugin is working,
Title: Re: Google Calendar Switch
Post by: ih8gates on November 24, 2013, 08:32:13 am
What? Why not?

The plugin doesn't check the calendar constantly, it does so periodically. The period isn't entirely based on gcalinterval.

Title: Re: Google Calendar Switch
Post by: fabstar81 on December 24, 2013, 07:59:54 am
is the default interval 21600 milliseconds, or seconds?
Title: Re: Google Calendar Switch
Post by: ih8gates on December 24, 2013, 08:11:56 am
is the default interval 21600 milliseconds, or seconds?

Seconds.
Title: Re: Google Calendar Switch
Post by: flyveleder on December 26, 2013, 07:30:45 am
Hi,

nice plugin ;-)

However - I am sure I missed something somewhere, but is it correct that it can only handle 1 keyword ? This makes it pretty unusable to me ...

I.e. - if I enter the keyword "LOCK_DOOR" - and this is entered in the calendar, gcal is tripped. But then it will do nothing it I enter any other words like "UNLOCK_DOOR" - or "LIGHTS_OUT" ...

Could be nice if you could write more or less anything, and then have PLEG handle what happens depending on which keywords were triggered.

Brgds,
Martin
Title: Re: Google Calendar Switch
Post by: garrettwp on December 26, 2013, 08:02:33 am
You can, read the thread. Start here: http://forum.micasaverde.com/index.php?topic=7558.msg102546.msg#102546 and work your way down.

- Garrett

Title: Re: Google Calendar Switch
Post by: flyveleder on December 26, 2013, 08:25:22 am
You can, read the thread. Start here: http://forum.micasaverde.com/index.php?topic=7558.msg102546.msg#102546 and work your way down.

Beautiful! - works immediately after I removed the keyword from Gcal. plugin. (should be described elsewhere ...)

Thanks Garret
Martin
Title: Re: Google Calendar Switch
Post by: flyveleder on December 26, 2013, 09:12:13 am
Do I understand it correctly :

If I want to trigger something at a certain time, I need to create an event longer than the update frequency to be sure that it actually triggers ?
I.e. making a LIGHTS_OFF at 15:00 - would be clever to make it from 15:00-15:10 to be sure that it fires ?

/Martin
Title: Re: Google Calendar Switch
Post by: petewill on January 02, 2014, 03:41:22 pm
Hi All,

I am having some trouble getting this to work.  When I put in my private xml feed it will not set.  I can however see my calendar on the calendar tab of the device.  Can someone tell me what I'm doing wrong?  I downloaded this app from the Install Apps section in the Vera GUI.  I have version 1.251.  I noticed in this thread that some people were installing it manually from an attachment.  Is that what I should do instead?

Thanks,

Pete
Title: Re: Google Calendar Switch
Post by: S-F on January 02, 2014, 05:15:16 pm
Yeah, for some reason it can take a while for that to stick. It has happened to me every time I've installed an instance of this plugin. Just be patient and report back if it doesn't work after a few hours or so.
Title: Re: Google Calendar Switch
Post by: gmjones on January 03, 2014, 05:16:45 pm
I have installed the app and I can see the calendar when I select the Calendar tab on the device. However, it never matches any event names I have put on the calendar. When I hit CHECK it just says No data. I can see the event on the calendar tab. Is there something I am missing?
Title: Re: Google Calendar Switch
Post by: ih8gates on January 04, 2014, 04:44:26 pm
Be sure that you're using the *public* XML URL. I missed that when I first set up my calendar logic.
Title: Re: Google Calendar Switch
Post by: parkerc on January 05, 2014, 02:44:12 am
Hi

Is anyone using elements of the google calendar plugin with any of the TTS solutions that are available with Vera eg. Sonos ? Just wondering if I could make it tell me what is planned for the day?
Title: Re: Google Calendar Switch
Post by: ih8gates on January 05, 2014, 07:13:37 am
I don't believe that you are going to be able to get it to do what you are thinking. It sounds like you want a summary of your calendar, and the plugin doesn't really work that way. It acts more like a motion sensor that trips at the time of a calendar entry.
Title: Re: Google Calendar Switch
Post by: parkerc on January 05, 2014, 07:39:20 am
Ok, thanks I was wondering if speaking the full day ahead of events was a bit to much. ;)

But I was just sill wondering if part of the trip (or maybe I advance ) if I could extract the full text of the date/time entry in the calendar so it could be spoken?

E.g

in 10 minutes " The Heating will be turned on"
In 10 minutes "you have a meeting with john"

Or maybe I could just have it as part of the Sonos Say command and nothing to do with the GCAL? The GCAL simply trips when there's an entry and this fires a Sonos Say script via a scene to say it.

Does anyone know how you could you extract the full text from a google calendar entry ?

Just thinking out loud
Title: Re: Google Calendar Switch
Post by: ih8gates on January 05, 2014, 01:27:14 pm
You'll get the text in a variable. You can also pass an additional variable by putting it in {braces}


local gCalDeviceNo = 60 -- GCal Sensor device number
local GS_SID = "urn:utz-com:serviceId:GCal1" -- GCal Sensor Service ID
local eventVar = luup.variable_get (GS_SID, "gcalval", gCalDeviceNo )
local eventTitle = luup.variable_get (GS_SID, "gcalkeyword", gCalDeviceNo )



Here's some code that I use to schedule announcements and reminders: http://forum.micasaverde.com/index.php/topic,18783.msg142177.html#msg142177
Title: Re: Google Calendar Switch
Post by: SM2k on January 10, 2014, 12:02:11 pm
Hi

Is anyone using elements of the google calendar plugin with any of the TTS solutions that are available with Vera eg. Sonos ? Just wondering if I could make it tell me what is planned for the day?

I'd really like to see this! I use the sonos plugin each morning to happily chatter about the weather for the day, and any recurring reminders like "take out the trash" if I haven't already opened the garage door, but the piece I'm missing is to sound off any pertinent reminders about the days events. As of the last time I looked at this plugin, it has a clear list of the titles of upcoming appointments which it parses to decide if/when to trigger the sensor, but it doesn't expose that list. I think it'd be pretty cool if it would store a list of all upcoming events along with their start/end timestamps as a json encoded string inside a luup variable. I admit I haven't kept up with the code for this plugin though. I locked mine to a (possibly older) version when my startDelta/endDelta patch wasn't accepted as part of the main release.
Title: Re: Google Calendar Switch
Post by: S-F on January 10, 2014, 01:00:32 pm
I think it'd be pretty cool if it would store a list of all upcoming events along with their start/end timestamps as a json encoded string inside a luup variable.

It would also be pretty cool if I defecated golden eggs and had so many that I was putting them in my toilet bowl tank to displace water. Alas I do not. If I did though you can bet I'd be paying someone to make this plugin a little more capable and address some of the needs people repeatedly voice.
Title: Re: Google Calendar Switch
Post by: SM2k on January 10, 2014, 01:24:45 pm
I'll be happy to add the feature myself, but as I'm not the owner of the codebase all I can do is submit a patch.
Title: Re: Google Calendar Switch
Post by: S-F on January 10, 2014, 02:08:04 pm
There have been useful patches in the past that never made their way into the plugin. Who's the boss of this plugin? Maybe the whole plugin system needs to be revamped. If a developer doesn't tend to their plugin for a certain amount of time maybe it should be opened up to let someone else take the reins?

But anything you can contribute would be greatly appreciated!
Title: Re: Google Calendar Switch
Post by: SM2k on January 12, 2014, 03:05:18 pm
I really can't comment on utz's responsiveness. The fact is I haven't paid attention. I did go back and port my delta patch to the latest code as I found I was very far behind--so it's entirely understandable for him not to take the time to port my patch forward. The attached files are the latest code (version 1.251) plus the addition of the startDelta and endDelta parameters. Only 3 of the 5 files (D_GCal.json, I_GCal.xml, and S_GCal.xml) have been changed, but I kept them together for completeness. I hope these files are adopted upstream because it's much easier to submit patches when I'm not working off of a forked codebase.
Title: Re: Google Calendar Switch
Post by: garrettwp on January 12, 2014, 11:28:59 pm
The last time utz posted was over a year ago. You could try contacting him or ask mcv for ownership of the plug-in.

I believe gengen was maintaining the plugin. You could get in contact with him.

- Garrett
Title: Re: Google Calendar Switch
Post by: tyfoon on January 19, 2014, 04:26:49 am
I use it to control my Danfoss Living connects that are battery powered.

I enter my calendar items (dedicated to vera) as I normally would in a calendar ; e.g. 'kids at home' starts at 13:00 and ends at 21:00. And event triggers the change in temp to the danfoss.

Does the event only fire once (at 13:00) or multiple times (x times in the calendar period)?

I see 'transmit OK' under the Danfoss several times a day while I would think it actually has nothing to transmit. This decreases battery live significantly.

Title: Re: Google Calendar Switch
Post by: ih8gates on January 21, 2014, 08:41:02 am
The event should only fire once, as it happens. Think of it like a motion sensor - it's "tripped" for as long as your calendar event is on. But it only trips once at the beginning and then is "not tripped" at the end.
Title: Re: Google Calendar Switch
Post by: kyle.dawson on February 10, 2014, 10:30:16 am
I have see where others have this error, but not see how to fix.   I add URL via set.  Does not do anything but reload and I can see calendar in tab.  But never shows date.  Look at logs I see this


50      02/10/14 10:17:09.404   luup_log:36: GCAL: query url: http://www.google.com/calendar/feeds/########################@group.calendar.google.com/public/basic?alt=json&fields=entry/title,entry/gd:when&singleevents=t
50      02/10/14 10:17:09.405   luup_log:36: GCAL: query status: 200 <0x2b6ab680>
01      02/10/14 10:17:09.408   ^[[31;1mLuaInterface::CallFunction_Startup-1 device 36 function GCalStartup failed [string "..."]:130: attempt to index field 'gd$when' (a nil value)^[[0m <0x2b6ab680>
01      02/10/14 10:17:09.408   ^[[31;1mLuImplementation::StartLua running startup code for 36 I_GCal.xml failed^[[0m <0x2b6ab680>


FYI... I removed my calendar URL from this post.  But when I open that URL in new windows with out being logged into Google, I get calendar date in text info.

Title: Re: Google Calendar Switch
Post by: BulldogLowell on February 10, 2014, 10:55:17 am
are you waiting until the unit makes a calendar call?

It took mine some time to see the calendar in the Calendar tab.

I also changed the gcalinterval to 300, that gives me 5minute updates to the calendar.
Title: Re: Google Calendar Switch
Post by: kyle.dawson on February 10, 2014, 12:03:18 pm
Yes I wait and I can see the calender in the tab.  But it sill has the error and really does not work.  I also tried 300, but not sure meaning of that value.

Per another post:

From reading over this thread, I understand that gcalinterval is how far into the future the plugin will look for calendar entries.

Title: Re: Google Calendar Switch
Post by: garrettwp on February 10, 2014, 12:53:43 pm
Not sure what your issue is. What does your calendar entries look like?

The gcalinterval is the time of when the plugin will poll the calendar. So if you have it set to say 1800 seconds, it will poll the calendar and look for information within the 30 minute time frame. If it finds an event, it will set that event up to be triggered at it's set time. When that event fires, the plugin poll the calendar again to queue up the next event. If there are no new events in that 30 minute time frame, the plugin will wait another 30 minutes to poll the calendar again. Think of it as the time of how often to retrieve the calendar data and how far to look into the calendar for events.

- Garrett
Title: Re: Google Calendar Switch
Post by: kyle.dawson on February 10, 2014, 02:08:13 pm
I found out my issue.  My Calendar would only share free/busy time, not all details. So the code was looking for attributes that were not there.  I put Share all details to public and it works great. Thanks for you help. Would be nice to update plugin doc to list these requirements, just to be sure people do not have issue, but love the plugin.




Title: Re: Google Calendar Switch
Post by: petewill on February 10, 2014, 10:32:57 pm
Hi All,

I am still having problems getting this app to work.  Do I need to have a link to my public rss feed?  I read in the app help page that private works but some people on this thread are using public.  On the calendar tab it says "Events from one or more calendars could not be shown here because you do not have the permission to view them"so maybe that's a dumb question but I'd rather use private so my calendar can't bee seen by the world so I thought I'd ask.  I have tried a few different things and the app still says calendar not set. 

Sorry for not following up on my first post.  Apparently I forgot to press "Notify" and never knew someone responded.
Title: Re: Google Calendar Switch
Post by: kyle.dawson on February 11, 2014, 01:03:46 am
I was able to get my private link to work, but it should be XML not RSS I think.  Try XML link not RSS.
Title: Re: Google Calendar Switch
Post by: petewill on February 11, 2014, 08:21:00 am
Kyle,

Thanks for the reply. You are correct it's an XML feed, not RSS.  I wrote that wrong.  I was using the XML feed already though and still no luck. 

I just tried to uninstall/reinstall to see if that would help and it didn't.

Is this what your link looks like?  http://www.google.com/calendar/feeds/EMAILADDRESS/private-RANDOMSTRINGOFCHARACTERS/full
Title: Re: Google Calendar Switch
Post by: S-F on February 11, 2014, 11:15:00 am
@ petewill,

Yes that's correct.
Title: Re: Google Calendar Switch
Post by: petewill on February 11, 2014, 03:16:12 pm
I did some more playing with the plug in and it seems that I'm still missing something.  I tried changing some of the advanced settings to see if I could tell what the problem was and unfortunately I couldn't.  Maybe it will give someone who knows more than me a better idea of what my problem is though.  It seems the calendar tab is looking only at the 'gcalsrc' field to populate data (see screenshot attachment).  It didn't seem like the 'gcallink' was changing anything.

Any ideas what I can try next?  Should I be using different different device_file and impl_file files?  I just downloaded the plugin from the Apps page.

Thanks.
Title: Re: Google Calendar Switch
Post by: BulldogLowell on February 11, 2014, 03:21:26 pm
you went to your calendar in google calendar and selected Calendar Settings... you then selected Private Address XML and copied that link, correct?
Title: Re: Google Calendar Switch
Post by: petewill on February 11, 2014, 07:38:38 pm
you went to your calendar in google calendar and selected Calendar Settings... you then selected Private Address XML and copied that link, correct?

Yup.  If I paste the xml link into a browser it displays my calendar info. 
Title: Re: Google Calendar Switch
Post by: BulldogLowell on February 11, 2014, 08:07:43 pm
I created a 2nd calendar on Google and linked that one.  I only schedule events for Vera on that calendar.  My keyword happens to be EVENT.  Try that yet?

Perhaps you may have some Outlook events that the App is struggling in in your main calendar?
Title: Re: Google Calendar Switch
Post by: petewill on February 11, 2014, 10:27:32 pm
Bulldoglowell, thanks!

That worked!  I created a new calendar added it to the plugin and it is showing tripped during one of my events.  The strange thing is I didn't really have anything in my main calendar as it was to be used specifically for vera. 

I am still unable to see the calendar tab of the plugin.  It says I don't have rights to view it.  Is anyone else having that problem?  If not, what is your value for Advanced Tab > gcalsrc say?  Is it just your email address?
Title: Re: Google Calendar Switch
Post by: BulldogLowell on February 11, 2014, 10:43:50 pm
mine took an hour or so to display right... weird.

wait and see...?

my gcalsrc looks like this:

1rbcgdhlqlej9cb6iq919bhl9o@group.calendar.google.com
Title: Re: Google Calendar Switch
Post by: petewill on February 12, 2014, 09:17:37 am
Bulldoglowell,

I really appreciate your help!  Your gcalsrc looks just like mine.  Not sure why I can't see the calendar in the calendar tab of the device.  I will continue to monitor it and do some testing when I get some more time.  The main thing is the actual events are triggering how they should but.  I can always check the calendar from the google calendar interface.

On a side note, you may want to modify (if you haven't already) the string of characters before the @group.calendar.google.com.  I think that's your private key.

Next step for me, if it's possible, is to get vera alerts to translate my google calendar events to tts so I can get announcements like "take out the trash".  Need to do more research on that though.

Once again, I appreciate your help!
Title: Re: Google Calendar Switch
Post by: BulldogLowell on February 12, 2014, 09:27:35 am
Bulldoglowell,

I really appreciate your help!  Your gcalsrc looks just like mine.  Not sure why I can't see the calendar in the calendar tab of the device.  I will continue to monitor it and do some testing when I get some more time.  The main thing is the actual events are triggering how they should but.  I can always check the calendar from the google calendar interface.

On a side note, you may want to modify (if you haven't already) the string of characters before the @group.calendar.google.com.  I think that's your private key.

Next step for me, if it's possible, is to get vera alerts to translate my google calendar events to tts so I can get announcements like "take out the trash".  Need to do more research on that though.

Once again, I appreciate your help!

No problem on the assistance, I struggled with that one evening too.

I did modify the string before I posted. 8)
Title: Google Calendar Switch Not Reading Calendar
Post by: Stuart on February 12, 2014, 06:05:55 pm
I too have been having troubles with the calendar switch not working.  Mine had been working for some time and after some fiddling - ceased to work - so I removed the plugin, rebooted added the plugin back etc (several iterations).  Here is the current situation.

1)  If the calendar is shared publicly - it works - but like others, I do not want to share publicly.
2)  The link 'Set' is at best 'flakey'.  During initial install - there is no gcalsrc / gcallink variables under the advanced tab.  'Set' often does nothing and the only way to get it to populate those variables is to do something to force a 'save' by changing the plugin name or similar.
3)  When it does finally save the link information it seems to change it from https://www.google.com/calendar/feeds/[email]%40gmail.com/private-[number]/basic (i.e. from the private XML link) to https://www.google.com/calendar/feeds/[email]@gmail.com/private-[number]/full
4)  The instructions say to use the private address link - which makes sense to me as I thought the intent was that the calendar could be read without making it public.

Edit:  I figured it out - at least mostly:
1.  Google Calendar DOES NOT have to be made public.
2.  If the calendar is not public - use the PRIVATE link
3.  When entering the link in the 'set' field - it can take a long time before it connects - so patience is needed.
4.  The main issue I had was the plugin not seeing 'nested' events i.e. an event that occurred on a day with an all day event.  Will ask if this is possible / how in a separate post.

Any thoughts / guidance / approaches to troubleshooting would be appreciated.  Of course - it is possible that this never worked as I imagined and that in the past I had inadvertently had by calendar set as public ??
Title: Re: Google Calendar Switch
Post by: kyle.dawson on February 12, 2014, 08:04:43 pm
Bulldolowell,

     Sorry I did not get back to you, busy with work stuff.  Glad to see it is finally working.  As for the tab view, what browser are you using?  Also, look to hard refresh the page, most times it is "shfit R", maybe clear cache.  Also, you mentioned you played with the advanced settings, did you put back to original values?

Petewill,

     I am looking to do same thing.  Have my google calendar TTS to my sonos speakers in the house, "Take out the trash", "Time to mow the lawn". I am using Vera Alerts, but can not see to get the sonos link from this notification.  I can control my sonos and use TTS, just not via the notification and then Vera Alerts.  If you find info on this, let me know.  I will do the same.


Kyle

Title: Re: Google Calendar Switch
Post by: petewill on February 12, 2014, 10:31:11 pm
Kyle,

I just did some research and I found this:

To access a Device Variable in Vera you need 3 pieces of information:

1) Device ID
2) Service ID
3) Variable Name



I then found this:
...
To find it [Service ID] ... goto the advanced tab ... let your mouse hover over the variable name.
It will show you the serviceid ... Double check your device # while you are at it.

Despite finding this great info I still can't get gcal variables in tts.  I got this to work:
{tone:tts}The temperature is {Device([32].TemperatureSensor.CurrentTemperature)}

but not this:
{tone:tts}google calendar test {Device([53].GCal.gcalkeyword)}

Has anyone been able to get gcal to work with Vera Alerts TTS? 

Also, I triple checked I'm using the correct device ID.

Thanks,

Pete
Title: Re: Google Calendar Switch
Post by: Stuart on February 14, 2014, 05:56:09 pm
Well - I spoke too soon and am going around in circles.  I even tried adding in an additional plugin instance and all that got me was a refresh loop ....   Deleted plugin, rebooted, started again  :P

Now I'm just totally confused, having had the calendar plugin working for quite a while to not working at all ......... by that I mean I can see the calendar in the tab - but it is not seeing any events - it stubbornly reports "calendar not set".

Currently:   There is no entry in gcalkeyword.  gcalscr is populated with a subset of the gcallink value - and these do correspond to the link obtained from google calendar with the exception that in gcallink - it gets changed so that it ends with with /full and not /basic (which was used to set it).


1.  Does the calendar need to be an additional calendar - by that I mean not the main calendar.

The reason I ask is that the private link for the main calendar is of the form https://www.google.com/calendar/feeds/[email]%40gmail.com/private- [number]/basic.  i.e there is no mention of  group.calendar.google.com.  Earlier threads indicated that group.calendar.google.com was needed - and the only way I can get this to happen is with an additional calendar ?
If I try the main calendar then gcalsrc = [email]@google.com. If I try the additinal calendar then gcalscr= [number]@group.calendar.google.com

2.  Does the calendar need to be shared in any way ?

Thanks in advance

Title: Re: Google Calendar Switch
Post by: petewill on February 14, 2014, 08:15:02 pm
Stuart,

I just went through something that sounds very similar to what you're going through.  The only way I could get it to show up is by creating an additional calendar (not my main one).  After I did that it would trigger based on my events.  I still do not see it in the calendar tab.  I'm not as concerned about that though.

Pete
Title: Re: Google Calendar Switch
Post by: reynoldino on February 15, 2014, 10:28:34 am
My vera crashes on the GCal switch:

Code: [Select]
50 02/15/14 16:25:00.131 luup_log:22: GCAL: Timer: Event has just started ! <0x2d735680>
06 02/15/14 16:25:00.132 Device_Variable::m_szValue_set device: 22 service: urn:utz-com:serviceId:GCal1 variable: gcalval was:  now:  #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2d735680>
06 02/15/14 16:25:00.132 Device_Variable::m_szValue_set device: 22 service: urn:utz-com:serviceId:GCal1 variable: gcalkeyword was:  now: Noomy_lamp_aan #hooks: 4 upnp: 0 v:(nil)/NONE duplicate:0 <0x2d735680>
07 02/15/14 16:25:00.146 Event::Evaluate 4 Convectorput aan scene Convector op 19 is false repeat 0/-1 <0x2d735680>
2014-02-15 16:25:00 - LuaUPnP Terminated with Exit Code: 245
2014-02-15 16:25:00 - LuaUPnP crash

Any suggestions? I have 2 triggers using the calendar switch. This only happens with one of them.
Title: Re: Google Calendar Switch
Post by: eli167 on February 20, 2014, 09:30:36 am
Please help, I have downloaded the GCal Sensor and can not get it too work, I have my calender set up it sees it correctly, i can not find any documantaion on the varables in the advance tab, this is what I have now but the  Variables  i dont know what to put
Device #130
Controlled via No parent/
Device params
name          GCal Sensor
device_type   urn:schemas-utz-com:device:GCal:1
altid 
ip 
mac 
manufacturer 
model 
room_num 
id_parent 
embedded 
disabled 
restricted 
device_file  D_GCal.xml
id            130
room          0
time_created  1392848373
plugin        1338
impl_file      I_GCal.xml
local_udn     uuid:4d494342-5342-5645-0082-000001c9cdc3

Variables

Tripped         0
gcalkeyword 
gcalval 
gcalinterval  21600
gcalnextevent 20/02/14 09:00:00 Home
gcalon        Home
gcalsrc       hvd4tok1ojh2kpoteop3k7flfs@group.calendar.google.com
gcallink      http://www.google.com/calendar/feeds/hvd4tok1ojh2kpoteop3k7flfs@group.calendar.google.com/private-4e99f573af9c06e0af7b002c9d9976a8/full
LastUpdate    0
Armed         1
New service:   
New variable:   
New value: 
 
Title: Re: Google Calendar Switch
Post by: BulldogLowell on February 20, 2014, 10:44:19 am
 it is "armed" and you have a keyword set so it looks OK

Did you create a 2nd calendar in google?  I had to do that and a few others found that worked.

my only other comment is that your gcal interval is long and is reaching out into the future pretty far (6hours)  is that how you intend to trigger your calendar to trigger?
Title: Re: Google Calendar Switch
Post by: eli167 on February 20, 2014, 02:13:35 pm
No I can chage that. It is one of my calenders not my main one. but i can not get it to start or stop my light or anything for that matter.
Title: Re: Google Calendar Switch
Post by: BulldogLowell on February 20, 2014, 02:28:36 pm
you may wish to create a third calendar and make sure that no other device is using that while you get this set up.  That worked for me.  I needed a clean calendar.

Title: Re: Google Calendar Switch
Post by: eli167 on February 20, 2014, 02:54:39 pm
I can add another one but i got 6 Calenders set up. i am looking I need to know how and what each variable does, that might be my problem
Title: Re: Google Calendar Switch
Post by: garrettwp on February 20, 2014, 05:03:48 pm
Please help, I have downloaded the GCal Sensor and can not get it too work, I have my calender set up it sees it correctly, i can not find any documantaion on the varables in the advance tab, this is what I have now but the  Variables  i dont know what to put
Device #130
Controlled via No parent/
Device params
name          GCal Sensor
device_type   urn:schemas-utz-com:device:GCal:1
altid 
ip 
mac 
manufacturer 
model 
room_num 
id_parent 
embedded 
disabled 
restricted 
device_file  D_GCal.xml
id            130
room          0
time_created  1392848373
plugin        1338
impl_file      I_GCal.xml
local_udn     uuid:4d494342-5342-5645-0082-000001c9cdc3

Variables

Tripped         0
gcalkeyword 
gcalval 
gcalinterval  21600
gcalnextevent 20/02/14 09:00:00 Home
gcalon        Home
gcalsrc       hvd4tok1ojh2kpoteop3k7flfs@group.calendar.google.com
gcallink      http://www.google.com/calendar/feeds/hvd4tok1ojh2kpoteop3k7flfs@group.calendar.google.com/private-4e99f573af9c06e0af7b002c9d9976a8/full
LastUpdate    0
Armed         1
New service:   
New variable:   
New value:

Everything looks OK. It's reading your calendar and picking up your next event. How do you have your scene setup?

- Garrett

Title: Re: Google Calendar Switch
Post by: eli167 on February 20, 2014, 10:34:47 pm
Just a light off foe a simple test
Title: Re: Google Calendar Switch
Post by: Stuart on February 22, 2014, 06:23:29 pm
I've been doing some investigation around the sometimes unpredictable calendar behavior as well as other 'strange behavior' with PLEG and combination switch.  I have come to the conclusion that one or other or both of the following come into play (1) the browser version you are using and (2) whether or not the plugin is coded 'defensively' and by that I mean forcing internal variables to know states at startup etc.

On the calendar plugin - I took a look at the code.  Earlier versions we coded to only work with an additional calendar whereas later versions dropped that constraint.  My calendar is now working just fine with the main calendar, no public sharing and using the private link.   I can see no reason why variations around the particular calendar would matter.  What I did notice was depending on what browser I used (IE vs Firefox vs Chrome) there were apparently different levels of success in getting the calendar to work.  IE 10 works best at using 'set' and 'check' but will not display the calendar in the calendar tab.

For PLEG - It seemed to 'loose it's mind' sometimes in that it would apparently become corrupted as to the configuration - to the point where it simply refused to load after some changes or threw spurious errors at start-up.  I suspect that the way firefox and chrome manage their internal cache could have something to do with this.  I've seen the issue before on some software where you have to make sure you close the browser for changes to be correctly saved.  Again IE seems more reliable in this regard although I could not get to reproducible test cases.

The Combination switch would not work with chrome because chrome refused to display all the available settings for some devices.  IE would although sometimes one had to select a different devise category and then the one you wanted for it to display the available settings.  Firefox was a bit hit and miss too but generally seemed OK.

In all IE 10 (not my first choice for daily use) seemed to give the most consistent results.  Oh - and my access to vera is almost always remote - so this may influence the results too

Hope this helps others who have been wrestling with the calendar (and other) plugins
Title: Re: Google Calendar Switch
Post by: Stuart on March 11, 2014, 10:50:32 pm
Periodically Google Calendar Switch looses it's mind and goes to 'untriggered' before my all day event ends.  It does so precisely at the timezone offset before midnight - taking into account daylight savings.  I.e. today the calendar event ended at 6:00 pm MST.

Anyone got any idea why ?  I'm suspicious there is a code bug as the only recent change was that I removed the keyword so I could trigger on two different event types.
Title: Re: Google Calendar Switch
Post by: Gringokarlos on March 17, 2014, 10:13:07 am
Hi Guys - first post, and a new vera user (so be gentle).  I'm trying to set up my vera to trigger on a calendar for a vacation rental property.  I want to automate thermostats and water heater using the rental calendar at VRBO.

I'm able to import the VRBO calendar into google calendar as an "other calendar", but it appears that these "other calendars" can't be shared.  Any idea how to get that VRBO calendar to trigger scenes?  It could be as simple as triggering on the word "reserved".  Still haven't figured out how to tell when to turn off (when the reservation ends).  I'm hoping that's simple once I hopefully import the calendar.

Thanks
Title: Re: Google Calendar Switch
Post by: ww73 on March 29, 2014, 04:19:14 pm
Looks like the plugin does not support 2 events that happen at the same time.  Can someone confirm?

I'm using the gcal plugin to trigger wake up lights in my kids room.  Sometimes they need to wake up at the same time and sometimes not.

It's not a big deal to create a separate gcal plugin for each kid, but would have been nice if concurrent events was supported.
Title: Re: Google Calendar Switch
Post by: ww73 on March 29, 2014, 05:09:53 pm
Looks like I spoke too soon.

Creating a 2nd gcal plugin would have the same problem as they would both see the 1st concurrent event but not the second.  Plus I couldn't get the 2nd instance to actually see the calendar.

Then I decided to delete the 2nd gcal plugin, which deleted both and uninstalled the app.

So then I re-installed the app, tried my best to set the gcallink and gcalsrc variables, but no luck reading the calendar.

Sigh...

I found some documentation here:  http://code.mios.com/trac/mios_google-calendar-plugin/

But it's pretty old and doesn't help.  Currently my reinstalled gcal plugin is saying "No data".  Not sure what I can do next...
Title: Re: Google Calendar Switch
Post by: S-F on March 29, 2014, 06:38:51 pm
I have a bunch of gcal devices.

I always find that they take a while to start working. Sometimes hours. I dunno why.

Second is that every entry I have begins at the same time, which is 12:00 AM as I use all day entries. I'm not sure if this makes it different or not but I have had no issues at all like you are experiencing. Maybe I'm not following you correctly. You are talking about two separate calendar entries, right?
Title: Re: Google Calendar Switch
Post by: ww73 on March 30, 2014, 12:32:54 am
It eventually worked.  Strange that the plugin found the calendar after I switched from the full feed to basic.

Then I spaced the wakeup events 1 minute apart and set the gcalinterval to 60s.

The test was successful.  We'll see on Monday if it turns on the lights correctly.

The funniest thing was that the kids would turn the lights off but the wake up light's ramp up function will turn the lights back on.  :D
Title: Re: Google Calendar Switch
Post by: Stuart on April 10, 2014, 01:44:59 pm
Having wrestled with a few 'funny' behaviors on the GCal switch - I took the liberty of diving into the code and made some enhancements as follows:

   --Fixed issue with early termination of all day events.start-max and start-min changed to local time
      when in an all day event.
   -- Fixed issue with strToTime substring extraction, made variables local, changed logic for detecting an event without hh:mm:ss
   -- Commented out unnecessary test for gcalon == nil which could delay first calendar check by gcalinterval
   -- Altered panel to show start and end of the next event or day month if an all day event
   -- Some restructuring of functions to more clearly support the above

This was all pretty much motivated by all day events not working properly.  They may work for some but not others based on a combination of local timezone, gcalinterval and possibly local variations on the google calendar behavior.  Essentially google calendar presents all day events in local (as opposed to utc time).   Specifically something like "2014-4-10" (which by definition is local time).  This is different to other events which are returned in utc time.

So the main change was to recognize an all day event and change the google requests to use local time.

Here is the changed file which can simply be downloaded over the install from the marketplace.

I'd appreciate any feedback - especially if there are residual bugs .... :-)

BTW - I did most of the testing with gcalinterval to 3600 (1 Hr)


Title: Re: Google Calendar Switch
Post by: SM2k on April 11, 2014, 11:07:05 am
Having wrestled with a few 'funny' behaviors on the GCal switch - I took the liberty of diving into the code and made some enhancements as follows:

   --Fixed issue with early termination of all day events.start-max and start-min changed to local time
      when in an all day event.
   -- Fixed issue with strToTime substring extraction, made variables local, changed logic for detecting an event without hh:mm:ss
   -- Commented out unnecessary test for gcalon == nil which could delay first calendar check by gcalinterval
   -- Altered panel to show start and end of the next event or day month if an all day event
   -- Some restructuring of functions to more clearly support the above

This was all pretty much motivated by all day events not working properly.  They may work for some but not others based on a combination of local timezone, gcalinterval and possibly local variations on the google calendar behavior.  Essentially google calendar presents all day events in local (as opposed to utc time).   Specifically something like "2014-4-10" (which by definition is local time).  This is different to other events which are returned in utc time.

So the main change was to recognize an all day event and change the google requests to use local time.

Here is the changed file which can simply be downloaded over the install from the marketplace.

I'd appreciate any feedback - especially if there are residual bugs .... :-)

BTW - I did most of the testing with gcalinterval to 3600 (1 Hr)

I've submitted patches to the code (uploaded to the thread just as you did) that have been outstanding for more than a year. I've been unable to reach the author.
Title: Re: Google Calendar Switch
Post by: S-F on April 11, 2014, 02:46:23 pm
Maybe it's time to submit an entirely new plugin to the app store?
Title: Re: Google Calendar Switch
Post by: Stuart on April 17, 2014, 09:42:16 pm
Maybe it's time to submit an entirely new plugin to the app store?

I'd be willing to have a go at new version - I'd need help understanding how to package / post it to the marketplace.  I really only have one functional  idea as an addition (and I know precisely nothing about how this might be accomplish ):  I know how to track it in code but not how to express it in a device .....

--Being able to respond on an calendar event where keyword matches 'x'  (as now) and also when that calendar event finishes (independently of other events).  This would allow overlapping / nested calendar events.  So in essence it changes the calendar from a simple switch to an multi-switch device.  But maybe PLEG could / should be used for this level of complexity ?

Rather than simply re-packaging the accumulated efforts of many - here are some random thoughts for streamlining the code:

- Keep the exiting version functionality (and code where appropriate)
- incorporate the start and end delta capabilities from SM2K described here  http://forum.micasaverde.com/index.php/topic,7558.msg91635.html#msg91635 (http://forum.micasaverde.com/index.php/topic,7558.msg91635.html#msg91635)
- make the code a little more lightweight at execution time (there's a lot of encoding / decoding of parameters that, it seems, could be explicitly passed) - and accompanying loading / unloading of 
- make an assumption that the vera unit and the calendar are in the same time zone (report back if not).  This would help eliminate code to work-around some of google's nuances.  Does anyone see a situation where you would want your calendar in a different timezone than the settings on your vera ?  Would indicate that you were doing the mental math when entering events in the calendar.
- look ahead a full 24 hrs for events (again just enables some simplification - not sure anyone would care, it would not be noticeable)
- a variable calendar refresh interval (as now) which simply guarantees a minimum refresh interval

What other functional ideas ?  Cosmetic Ideas ?












Title: Re: Google Calendar Switch
Post by: ft9 on April 18, 2014, 05:05:47 pm
Maybe the ability of matching the keyword not only in the event name but also in event description!  ::)
Title: Re: Google Calendar Switch
Post by: mda on April 18, 2014, 05:08:34 pm
An option to be case insensitive and support for keywords with spaces in them would be great.


Sent from my iPhone using Tapatalk
Title: Re: Google Calendar Switch
Post by: Freddan101 on April 19, 2014, 03:47:45 am
I would love to be able to trigger on an calendar event in the future, say 5h from now (or whatever one wishes).

In this way it would be very easy to program the car heater. The event is set when I'm supposed to leave home. The plugin triggers say 5h before the event and then some logic takes care of when the heater is started depending on outdoor temp.
Title: Re: Google Calendar Switch
Post by: EOppie on April 21, 2014, 12:09:00 pm
I may be missing somewhere in the thread that this doesn't work...but I wanted to check  ;D

I uploaded the versions of the plugin that have the "Deltas" included in them, and they show in the Vera interface.

Problem is...they do not seem to be doing anything.

The calendar event is for 7:00am, however I would like for the status to change two hours prior...so I thought I would put in a negative start delta (-02:00:00) however that doesn't seem to do anything.

Am I inputting the time incorrect?  Or something else.

Thanks!
Title: Re: Google Calendar Switch
Post by: SM2k on April 21, 2014, 01:44:51 pm
I may be missing somewhere in the thread that this doesn't work...but I wanted to check  ;D

I uploaded the versions of the plugin that have the "Deltas" included in them, and they show in the Vera interface.

Problem is...they do not seem to be doing anything.

The calendar event is for 7:00am, however I would like for the status to change two hours prior...so I thought I would put in a negative start delta (-02:00:00) however that doesn't seem to do anything.

Am I inputting the time incorrect?  Or something else.

Thanks!

The delta is an integer for the number of minutes to offset. try -120.
Title: Re: Google Calendar Switch
Post by: SM2k on April 21, 2014, 02:07:59 pm
What other functional ideas ?  Cosmetic Ideas ?

One of the biggest drawbacks of the current plugin is that you need a completely separate instance of the plugin for each type of calendar event you want to monitor. I remember reading a comment from @RichardTSchaefer somewhere in the forums that each toplevel device (aka. no parent) takes about 50M RAM for it's own lua environment.

The approach that the iPhone locator plugin takes is to have one master device that controls separate daughter devices for each phone you want to track. Ideally the gcal plugin could take a similar approach where each event to monitor from the same calendar could create a separate virtual device without requiring a new plugin.

Obviously the above suggestion is more invasive than other suggestions or patches so far--so I'm not sure if a major rewrite would be needed or not--but the core logic itself is already responsible for sorting out the events it's interested in.
Title: Re: Google Calendar Switch
Post by: garrettwp on April 21, 2014, 02:16:52 pm
What other functional ideas ?  Cosmetic Ideas ?

One of the biggest drawbacks of the current plugin is that you need a completely separate instance of the plugin for each type of calendar event you want to monitor. I remember reading a comment from @RichardTSchaefer somewhere in the forums that each toplevel device (aka. no parent) takes about 50M RAM for it's own lua environment.

The approach that the iPhone locator plugin takes is to have one master device that controls separate daughter devices for each phone you want to track. Ideally the gcal plugin could take a similar approach where each event to monitor from the same calendar could create a separate virtual device without requiring a new plugin.

Obviously the above suggestion is more invasive than other suggestions or patches so far--so I'm not sure if a major rewrite would be needed or not--but the core logic itself is already responsible for sorting out the events it's interested in.

It's actually about 2MB of ram per plugin give or take. You also do not need a new plugin for each keyword you want to look for. I added code well over a year ago to the plugin that allowed for acting on the calendar event based on the keyword in the scene. So you can have one calendar and than create new scenes with a different keyword to check against the plugin.

- Garrett
Title: Re: Google Calendar Switch
Post by: SM2k on April 21, 2014, 02:42:12 pm

It's actually about 2MB of ram per plugin give or take. You also do not need a new plugin for each keyword you want to look for. I added code well over a year ago to the plugin that allowed for acting on the calendar event based on the keyword in the scene. So you can have one calendar and than create new scenes with a different keyword to check against the plugin.

- Garrett

Ah! Very good to know! Was that code incorporated into the official plugin? I never noticed anything in the gcal interface.

2MB vs 50 eh? Clearly my memory is rusty :)
Title: Re: Google Calendar Switch
Post by: garrettwp on April 21, 2014, 02:47:46 pm
Yes, you'll have to create a scene and in the advanced tab, you'll select the gcal plug-in and choose in the drop down "A keyword matches".

- Garrett

Title: Re: Google Calendar Switch
Post by: SM2k on April 21, 2014, 03:09:57 pm
Yes, you'll have to create a scene and in the advanced tab, you'll select the gcal plug-in and choose in the drop down "A keyword matches".

- Garrett

Very nice! Good job. Correct me if I'm wrong, but that can only run a scene when a calendar event starts, correct? Some of my logic uses both the start and stop time of calendar events.
Title: Re: Google Calendar Switch
Post by: S-F on April 21, 2014, 07:48:58 pm
Ya know what would be a really BIG change? The ability to delete a single instance of the plugin. Why can't you do that now anyway?
Title: Re: Google Calendar Switch
Post by: qwen3579 on April 21, 2014, 08:43:04 pm
Yes, you'll have to create a scene and in the advanced tab, you'll select the gcal plug-in and choose in the drop down "A keyword matches".

- Garrett

Very nice! Good job. Correct me if I'm wrong, but that can only run a scene when a calendar event starts, correct? Some of my logic uses both the start and stop time of calendar events.

I don't see the "A keyword matches" setting in the Advanced settings - see attached.

Ya know what would be a really BIG change? The ability to delete a single instance of the plugin. Why can't you do that now anyway?

Yes. This was driving me crazy when I had to remove an instance.
Title: Re: Google Calendar Switch
Post by: garrettwp on April 21, 2014, 09:34:45 pm
Ya know what would be a really BIG change? The ability to delete a single instance of the plugin. Why can't you do that now anyway?

This is a bug in Vera and beyond our control.

- Garrett

Title: Re: Google Calendar Switch
Post by: Freddan101 on April 22, 2014, 02:53:18 am

I may be missing somewhere in the thread that this doesn't work...but I wanted to check  ;D

I uploaded the versions of the plugin that have the "Deltas" included in them, and they show in the Vera interface.

Problem is...they do not seem to be doing anything.

The calendar event is for 7:00am, however I would like for the status to change two hours prior...so I thought I would put in a negative start delta (-02:00:00) however that doesn't seem to do anything.

Am I inputting the time incorrect?  Or something else.

Thanks!
I realize that the feature I requested above to be able to trigger on future events may already exist in one of the patches. Have I understood this right?
Title: Re: Google Calendar Switch
Post by: garrettwp on April 22, 2014, 03:02:27 am
Yes, you'll have to create a scene and in the advanced tab, you'll select the gcal plug-in and choose in the drop down "A keyword matches".

- Garrett

Very nice! Good job. Correct me if I'm wrong, but that can only run a scene when a calendar event starts, correct? Some of my logic uses both the start and stop time of calendar events.

I don't see the "A keyword matches" setting in the Advanced settings - see attached.

Ya know what would be a really BIG change? The ability to delete a single instance of the plugin. Why can't you do that now anyway?

Yes. This was driving me crazy when I had to remove an instance.

Sorry it is under the trigger tab. You'll need to create a new trigger and select the gcal device. Than select "A calendar event matches keyword".

- Garrett
Title: Re: Google Calendar Switch
Post by: qwen3579 on April 22, 2014, 06:54:37 am

Sorry it is under the trigger tab. You'll need to create a new trigger and select the gcal device. Than select "A calendar event matches keyword".

- Garrett

Thanks Garrett!
Title: Re: Google Calendar Switch
Post by: SM2k on April 22, 2014, 09:09:53 am
I realize that the feature I requested above to be able to trigger on future events may already exist in one of the patches. Have I understood this right?
[/quote]

That's exactly what the start delta is designed to do. The plugin will trigger at the number of minutes *added* to the actual start of the calendar event. Thus if you want the sensor to fire 2 hours before a calendar event, use a start delta of -120.
Title: Re: Google Calendar Switch
Post by: EOppie on April 22, 2014, 11:42:29 am
I realize that the feature I requested above to be able to trigger on future events may already exist in one of the patches. Have I understood this right?

You have understood correctly.  Here is a zip that contains the most recent patch files I could find.
Title: Re: Google Calendar Switch
Post by: Freddan101 on April 22, 2014, 03:53:27 pm
Thank you very much. This will solve my car heater logic.

Hopefully we will have a new plugin version soon with all fixes included.
Title: Re: Google Calendar Switch
Post by: Stuart on April 23, 2014, 07:25:58 pm
Maybe the ability of matching the keyword not only in the event name but also in event description!  ::)

I'm just finishing up some pretty major structural changes and should have an alpha drop  in the next couple of days.  Trying to make this all backward compatible ....

This includes the following keyword matching approach (if gcalon is specified):
1) The event title (less any parameter {}), description and keyword are case insensitive-- so 'Test Event' = 'test event' = 'TeSt EVeNT'
2) White apace is trimmed from the start and end of title, description and keyword - this just makes it a little more robust to typo's
3) Any parameter is left as-is
4) Keyword (or phrase)  if used must be an exact match for the title
5)Keyword can match anywhere in the description but whole words only: keyword 'description test' ~= 'a description testy word' but does = 'a description test word'

If no keyword is used Garrett's enhancements of a year or so ago are intact

I think this gives some reasonable flexibility

Title: Re: Google Calendar Switch
Post by: Stuart on April 23, 2014, 07:31:44 pm
I would love to be able to trigger on an calendar event in the future, say 5h from now (or whatever one wishes).

In this way it would be very easy to program the car heater. The event is set when I'm supposed to leave home. The plugin triggers say 5h before the event and then some logic takes care of when the heater is started depending on outdoor temp.

I'll incorporate SM2K's start end delta patches into the next round of changes --  once I have the patch for the marketplace version out.

The restructuring I have done was with that in mind - so it will be a simple upgrade - and at that stage, I'll probably be ready have it available it in the marketplace as GCallII
Title: Re: Google Calendar Switch
Post by: Stuart on April 23, 2014, 07:34:52 pm
An option to be case insensitive and support for keywords with spaces in them would be great.


Sent from my iPhone using Tapatalk

Done - please see notes above
Title: Re: Google Calendar Switch
Post by: Stuart on April 23, 2014, 07:51:12 pm
What other functional ideas ?  Cosmetic Ideas ?

One of the biggest drawbacks of the current plugin is that you need a completely separate instance of the plugin for each type of calendar event you want to monitor. I remember reading a comment from @RichardTSchaefer somewhere in the forums that each toplevel device (aka. no parent) takes about 50M RAM for it's own lua environment.

The approach that the iPhone locator plugin takes is to have one master device that controls separate daughter devices for each phone you want to track. Ideally the gcal plugin could take a similar approach where each event to monitor from the same calendar could create a separate virtual device without requiring a new plugin.

Obviously the above suggestion is more invasive than other suggestions or patches so far--so I'm not sure if a major rewrite would be needed or not--but the core logic itself is already responsible for sorting out the events it's interested in.

Part of the restructuring I'm in the process of may be useful:
I'm maintaining backward compatibility but think I have a way to handle nested events (at least to one level of nesting).   What I mean by this is adding in another parameter gcalnestedevent (say) which is just a device property.  It does not trigger the device but I still track the start and stop times and set it with the event name or "" as appropriate.  I believe PLEG would see that as a device property transition and be coaxed to behave accordingly.

So you'd have the ability (for example) to have an all day event triggered by a keyword (or not)  and also react to within day events with a single instance of the plug-in.

Does that sound at all useful ?

Other changes I've already made include:
1) treating consecutive all day events as one single event (i.e. no off - on transition at midnight)
2) similarly 2 consecutive events of the same name that end-start at the same time are treated as one event
3) overlapping events - the second one triggers when the first is finished (if they have the same keyword or no keyword is specified)  - but could also be treated as nested (see above)

Events with the same start time are ambiguous as to which one triggers (all other things being equal) - but that's really what PLEG / Scenes are for :-)



Title: Re: Google Calendar Switch
Post by: EOppie on April 24, 2014, 04:25:08 pm
Alright, I tried using -120 as the "Start Delta" offset.  I put it in via the Advanced tab, but it had no impact on when it was triggered.

I then tried to put it in under the Control tab, and get a "No Implementation" error.

Ideas?
Title: Re: Google Calendar Switch
Post by: Stuart on April 24, 2014, 05:03:34 pm
Maybe the ability of matching the keyword not only in the event name but also in event description!  ::)

I'm just finishing up some pretty major structural changes and should have an alpha drop  in the next couple of days.  Trying to make this all backward compatible ....

This includes the following keyword matching approach (if gcalon is specified):
1) The event title (less any parameter {}), description and keyword are case insensitive-- so 'Test Event' = 'test event' = 'TeSt EVeNT'
2) White apace is trimmed from the start and end of title, description and keyword - this just makes it a little more robust to typo's
3) Any parameter is left as-is
4) Keyword (or phrase)  if used must be an exact match for the title
5)Keyword can match anywhere in the description but whole words only: keyword 'description test' ~= 'a description testy word' but does = 'a description test word'

If no keyword is used Garrett's enhancements of a year or so ago are intact

I think this gives some reasonable flexibility

Ok (small drum roll) - here it is .....   This upgrade is for the standard marketplace version (see description above).  I should have the start / end delta version in the next couple of days (day job willing).  I've tested it pretty well so hopefully no major issues.  Please note especially that I push everything to uppercase to facilitate case insensitive triggering -- so if you have an event that looks for a particular keyword or event name -- make sure your test is upper case too !

Note also that here is a short (<5 sec) delay when the calendar first initializes.  If you press the  'check' button, it should update immediately  - so none of the previous 'wait a few hours'.

Also - especially note that the vera and google calendar are on the same timezone (can't imagine why they would not be)

Any and all feedback welcome - more to come.

Title: Re: Google Calendar Switch
Post by: EOppie on April 28, 2014, 10:59:14 pm
Alright, I tried using -120 as the "Start Delta" offset.  I put it in via the Advanced tab, but it had no impact on when it was triggered.

I then tried to put it in under the Control tab, and get a "No Implementation" error.

Ideas?

Downloaded the new xml file, still shows the same error when trying to set an offset (-120)

I am excited to see someone much smarter than I taking a look into this plugin again though!  Thanks for your work!
Title: Re: Google Calendar Switch
Post by: Stuart on May 06, 2014, 08:14:06 pm
Here is a new version of the calendar Switch - Google Calendar II.   After a couple of more days testing I'll try to get it released through the marketplace.  It's almost a complete rewrite but without the original authors and other contributors along the way - it would have been impossible for me to get this working.  So many thanks to all ....

Along the way I made some UI changes (took some things off the control tab and placed them in the advanced tab) as well as minor changes to most of the variable names - having said that, it should be 100% backward compatible with the original version currently in the marketplace.

It has the following features:
This includes the following keyword matching approach (if gc_On is specified):
1) The event title (less any parameter {}), description and keyword are case insensitive-- so 'Test Event' = 'test event' = 'TeSt EVeNT'
2) White apace is trimmed from the start and end of title, description and keyword - this just makes it a little more robust to typo's
3) Any parameter is left as-is
4) Keyword (or phrase)  if used must be an exact match for the title
5)Keyword can match anywhere in the description but whole words only: keyword 'description test' ~= 'a description testy word' but does = 'a description test word'
6)Start and End delta are supported
7) I added two new controls gc_ignoreAllDayEvent and gc_ignoreKeyword which do as they imply.  The rationale was to allow greater flexibility and enable some fairly complex interactions if more than one plugin is deployed.
8) Start and End Delta and the minimum calendar refresh  interval (gc_Interval) are all in minutes
9) gc_LastRefresh shows when the calendar was last checked

It's a work in progress ...... so appreciate any suggestions and especially finding any bugs ...

Newer version is here:

 http://forum.micasaverde.com/index.php/topic,7558.msg174853.html#msg174853 (http://forum.micasaverde.com/index.php/topic,7558.msg174853.html#msg174853)




Title: Re: Google Calendar Switch
Post by: Don Diego on May 07, 2014, 06:09:15 am
Here is a new version of the calendar Switch - Google Calendar II.   After a couple of more days testing I'll try to get it released through the marketplace.  It's almost a complete rewrite but without the original authors and other contributors along the way - it would have been impossible for me to get this working.  So many thanks to all ....

Along the way I made some UI changes (took some things off the control tab and placed them in the advanced tab) as well as minor changes to most of the variable names - having said that, it should be 100% backward compatible with the original version currently in the marketplace.

It has the following features:
This includes the following keyword matching approach (if gc_On is specified):
1) The event title (less any parameter {}), description and keyword are case insensitive-- so 'Test Event' = 'test event' = 'TeSt EVeNT'
2) White apace is trimmed from the start and end of title, description and keyword - this just makes it a little more robust to typo's
3) Any parameter is left as-is
4) Keyword (or phrase)  if used must be an exact match for the title
5)Keyword can match anywhere in the description but whole words only: keyword 'description test' ~= 'a description testy word' but does = 'a description test word'
6)Start and End delta are supported
7) I added two new controls gc_ignoreAllDayEvent and gc_ignoreKeyword which do as they imply.  The rationale was to allow greater flexibility and enable some fairly complex interactions if more than one plugin is deployed.
8) Start and End Delta and the minimum calendar refresh  interval (gc_Interval) are all in minutes
9) gc_LastRefresh shows when the calendar was last checked

It's a work in progress ...... so appreciate any suggestions and especially finding any bugs ...

Attached zip file contains the latest together with some brief instructions

Stuart

  Thanks for your efforts. Neat app.

    Don
Title: Re: Google Calendar Switch
Post by: Stuart on May 07, 2014, 09:20:13 am
Don --

you are most welcome.

Last night I noticed a 'woops' to do with triggering events without a keyword (gc_On) and forwarding the Event Name to other plugins (I suspect a typo on my part).  Hope to have it fixed later today.
Title: Re: Google Calendar Switch
Post by: Stuart on May 07, 2014, 03:49:43 pm
Google Calendar Switch II

I noticed a couple of inconsistencies in naming and also a bug (or two) which may or may not have been noticeable.  These are now fixed.
As part of this - I tidied up the presentation order of variables in the advanced tab, added an additional information parameter gc_TriggeredEvent which for a triggered event will equal gc_NextEvent ( a rename of of gc_Event).  Changed the parameter name gc_On to gc_Keyword (for consistency).

It's looking pretty solid in my vera - so hopefully in yours too  :D

Due to the name changes and such - it is best to uninstall the last version - reboot - and then install following the included instructions.  I have not updated the descriptions in the instructions yet but will do so shortly.

 I think this is pretty close to warrant submission to the marketplace - would really love it if all y'all can break something first tho  :P

This is version 0.9 
Title: Re: Google Calendar Switch
Post by: Freddan101 on May 07, 2014, 04:22:57 pm
Great work, Stuart. Thank you. Looking forward to test it.
Title: Re: Google Calendar Switch
Post by: qwen3579 on May 07, 2014, 05:02:38 pm
Google Calendar Switch II

I noticed a couple of inconsistencies in naming and also a bug (or two) which may or may not have been noticeable.  These are now fixed.
As part of this - I tidied up the presentation order of variables in the advanced tab, added an additional information parameter gc_TriggeredEvent which for a triggered event will equal gc_NextEvent ( a rename of of gc_Event).  Changed the parameter name gc_On to gc_Keyword (for consistency).

It's looking pretty solid in my vera - so hopefully in yours too  :D

Due to the name changes and such - it is best to uninstall the last version - reboot - and then install following the included instructions.  I have not updated the descriptions in the instructions yet but will do so shortly.

 I think this is pretty close to warrant submission to the marketplace - would really love it if all y'all can break something first tho  :P

This is version 0.9

I removed my old plugin and ensured the old files were gone. I then followed the instructions.

1. the gCal app no longer shows in the list of installed Apps (no big deal)
2. Using the Set function on the Control tab did not work. I had to manually enter enter the URL into the gc_Link field on the Advanced tab.
3. I do not have a gc_On variable. According to the documentation, this is where I would enter my keyword, correct? I found that the gc_Keyword is where I enter this. -Not currently in documentation.

EDIT:
The plugin is performing the opposite of what it's supposed to. When I don't have a keyword specified, it is tripped (red), showing my all-day event for today (robert off). When I have a keyword entered (off) for gc_Keyword, it is static (green), and does not show the event.

Title: Re: Google Calendar Switch
Post by: Stuart on May 07, 2014, 06:40:55 pm

I removed my old plugin and ensured the old files were gone. I then followed the instructions.

1. the gCal app no longer shows in the list of installed Apps (no big deal)
2. Using the Set function on the Control tab did not work. I had to manually enter enter the URL into the gc_Link field on the Advanced tab.
3. I do not have a gc_On variable. According to the documentation, this is where I would enter my keyword, correct? I found that the gc_Keyword is where I enter this. -Not currently in documentation.

EDIT:
The plugin is performing the opposite of what it's supposed to. When I don't have a keyword specified, it is tripped (red), showing my all-day event for today (robert off). When I have a keyword entered (off) for gc_Keyword, it is static (green), and does not show the event.

Hi -- Some answers - hopefully useful

(1) I may be wrong but I do not think that installing the app this way will make it show up in the list of installed apps - my guess is it will only show up that way if installed from the marketplace.
(2) The Set function on the control tab will not immediately populate the gc_Link field on the advanced tab.  I think this is a mios 'feature' the code certainly updates the variable immediately.  I have found that it's necessary to do a "reload' before the variables show up (or possibly F5 to refresh the browser page).  I've never entered the value directly into the gc_Link field myself - so suspect there is a latency or browser aspect at work here.
(3) That's one of the things that I had not updated in the documentation as yet

On the operational semantics - I've hopefully preserved the behavior from the original Google Calendar switch:   If no keyword is set then any event will enable the plugin to trigger.  If a keyword is set then only those that match the keyword can trigger.  So what you are describing seems to be what is intended.  This is the behavior when both gc_IgnoreKeyword and gc_ignoreAllDayEvent are false.

To this 'standard' behavior I added gc_ignoreAllDayEvent which effectively 'hides' an all day event and allows you to trigger on other events during the day.  I also added gc_IgnoreKeyword so you can use gc_Keyword as a way of saying "ignore events with this keyword".

So - by way of exampe - lets say I have
An all day event "All Day"
An event "A keyword" in the near future
An event "Not a Keyword" in the near future

and I have the following .....
gc_Keyword = a keyword
gc_ignoreKeyword = true
gc_ignoreAllDayEvent = true

then the plugin will trigger on the event "Not a Keyword" -- because all day events and any events with the keyword do not (logically) exist

if I change gc_ignoreAllDayEvent = false then it would trigger on "All Day" because it's as if no keyword were set and events with the keyword do not (logically) exist

if I next change gc_ignoreKeyword = false then it would trigger on "A Keyword" -- i.e. we are back to the 'standard' behavior

and lastly with gc_ignoreKeyword = false and gc_ignoreAllDayEvent = true then it will trigger on the event "A Keyword" (but if there was an All Day event called "A Keyword" it would be ignored)

Hopefully - this behavior makes sense - if not or if something else makes sense, please let me know.
Title: Re: Google Calendar Switch
Post by: qwen3579 on May 07, 2014, 07:34:05 pm
(1) I may be wrong but I do not think that installing the app this way will make it show up in the list of installed apps - my guess is it will only show up that way if installed from the marketplace.
(2) The Set function on the control tab will not immediately populate the gc_Link field on the advanced tab.  I think this is a mios 'feature' the code certainly updates the variable immediately.  I have found that it's necessary to do a "reload' before the variables show up (or possibly F5 to refresh the browser page).  I've never entered the value directly into the gc_Link field myself - so suspect there is a latency or browser aspect at work here.

1 - Hmm... That may be the case. I thought I had installed the previous version manually as well, but I may be mistaken.
2 - I did the whole Reload, Reboot, Refresh the browser dance, several times, and it would never take. Only after entering manually into the variable did it work.

3 - See attached. You can see that I have an all-day event for today with the word "off" in it. My keyword is set to "OFF" as well. My ignore variables are set to false. So, it should be triggered at this time. However, if I remove the keyword, then the plugin is triggered.

The plugin used to function the opposite of this - only triggered when the keyword condition is true.
Title: Re: Google Calendar Switch
Post by: Stuart on May 07, 2014, 10:46:35 pm

1 - Hmm... That may be the case. I thought I had installed the previous version manually as well, but I may be mistaken.
2 - I did the whole Reload, Reboot, Refresh the browser dance, several times, and it would never take. Only after entering manually into the variable did it work.

3 - See attached. You can see that I have an all-day event for today with the word "off" in it. My keyword is set to "OFF" as well. My ignore variables are set to false. So, it should be triggered at this time. However, if I remove the keyword, then the plugin is triggered.

The plugin used to function the opposite of this - only triggered when the keyword condition is true.

I'll have to defer to the MUCH more experienced plugin developers on why things don't seem to take.  The marketplace version had similar issues in my experience.   I have also seen different behavior with different browsers.  Even now the calendar tab will not display in the version of IE I have (I tend to use firefox) .  The mios documentation is pretty thin to say the least and much of the UI and behind the scenes behavior seems to be 'tribal knowledge' and mostly 'trial and error' in my case.  If there is a way to improve variable changes propagating to the advanced tab I'd love to know how.

I have not got around to writing up a comprehensive set of explanations but this is what it currently says (relates to gc_Keyword)
"If set this specifies the event name (exactly) or description (anywhere) to match.  The plugin will force it to upper case."

In other words the value of gc_keyword is used (provided gc_ignoreKeyword is false) to look for an exact match with the whole event name or if there is a description entered it looks for the keyword (or phrase) somewhere in the description.

So in your case with the keyword "off" it's looking for an event name that is exactly "off" - although it does not care about case.   If you set your keyword to "robert off" then it would trigger on your all day event because there was an exact match.  Alternatively you could put something like "the restaurant is off the main road" in the description and the keyword 'off" would see that as an event to trigger on because "off" is somewhere in the description.

This behavior is somewhat arbitrary - in the original marketplace version it was an exact match (from memory ) and it did not look at the description.
I could add a switch gc_KeywordExact that looked for an exact match (if true) and a match anywhere in the event name (if false).  Seems like a partial match in the description makes sense always ?  What do others think ?

Thanks for all this feedback as I'll roll it up into the instructions.

EDIT:  One thing just occurred to me regarding setting the gc_Link.  Did you copy the link information from your prior calendar plugin and try to use that in the Set function of the control tab ?  If so that will not work.  The form or the url from google is https:// ....../basic.  When it's used in the set function it's reformatted to http:// ....../full and that format is placed into gc_Link (as well as a portion extracted to create gc_Source).  If you input into the Set Link function something copied from the gc_Link field it will not work.

Title: Re: Google Calendar Switch
Post by: qwen3579 on May 08, 2014, 06:54:59 am
I'll have to defer to the MUCH more experienced plugin developers on why things don't seem to take.  The marketplace version had similar issues in my experience.   I have also seen different behavior with different browsers.  Even now the calendar tab will not display in the version of IE I have (I tend to use firefox) .  The mios documentation is pretty thin to say the least and much of the UI and behind the scenes behavior seems to be 'tribal knowledge' and mostly 'trial and error' in my case.  If there is a way to improve variable changes propagating to the advanced tab I'd love to know how.

In other words the value of gc_keyword is used (provided gc_ignoreKeyword is false) to look for an exact match with the whole event name or if there is a description entered it looks for the keyword (or phrase) somewhere in the description.

So in your case with the keyword "off" it's looking for an event name that is exactly "off" - although it does not care about case.   If you set your keyword to "robert off" then it would trigger on your all day event because there was an exact match.  Alternatively you could put something like "the restaurant is off the main road" in the description and the keyword 'off" would see that as an event to trigger on because "off" is somewhere in the description.

This behavior is somewhat arbitrary - in the original marketplace version it was an exact match (from memory ) and it did not look at the description.
I could add a switch gc_KeywordExact that looked for an exact match (if true) and a match anywhere in the event name (if false).  Seems like a partial match in the description makes sense always ?  What do others think ?

Thanks for all this feedback as I'll roll it up into the instructions.

EDIT:  One thing just occurred to me regarding setting the gc_Link.  Did you copy the link information from your prior calendar plugin and try to use that in the Set function of the control tab ?  If so that will not work.  The form or the url from google is https:// ....../basic.  When it's used in the set function it's reformatted to http:// ....../full and that format is placed into gc_Link (as well as a portion extracted to create gc_Source).  If you input into the Set Link function something copied from the gc_Link field it will not work.

I think I know the reason your calendar does not show up in the tab - it is because you are not authenticated to Google, with that account, in that browser session. I had to sign into mine, and my wife's accounts, to get the data to show there (I have a plugin for each of our calendars).

Okay, that makes sense. It is functioning as you describe here. But in the previous version, I simply had my keyword set to "off" and it would trigger on an event name, or description, when the word "off" was included anywhere. But as long as we know the "how and why" then that's all that matters.  ;D

Yes, I did copy the URL from my old plugin, so that is likely the case.

Thanks for the updated plugin and the help.
Title: Re: Google Calendar Switch
Post by: Stuart on May 08, 2014, 09:50:52 am

I think I know the reason your calendar does not show up in the tab - it is because you are not authenticated to Google, with that account, in that browser session. I had to sign into mine, and my wife's accounts, to get the data to show there (I have a plugin for each of our calendars).


Ah Ha !!   Thanks.  I don't use IE often ... and that's exactly the reason ....
Title: Re: Google Calendar Switch
Post by: Stuart on May 08, 2014, 03:22:16 pm
Google Calendar II Documentation

This post is where I will place and update the documentation for Google Calendar II

Title: Re: Google Calendar Switch
Post by: qwen3579 on May 13, 2014, 08:09:45 am
So I woke up this morning and found that my morning wakeup scene did not fire due to the gCal plugin being tripped, as is designed. However, my event was yesterday, not today. The trigger did not fall back today - see attached.

As you can see, gc_nextEventTime is correctly reporting No Event.
Title: Re: Google Calendar Switch
Post by: Stuart on May 13, 2014, 06:54:01 pm
So I woke up this morning and found that my morning wakeup scene did not fire due to the gCal plugin being tripped, as is designed. However, my event was yesterday, not today. The trigger did not fall back today - see attached.

As you can see, gc_nextEventTime is correctly reporting No Event.

I have just seen the exact error on my own system.  Unfortunately - I'm out of town until the weekend.  I'm pretty sure I know where the problem is (one or other of two) .  In the meantime - I'vemade further improvements and have submitted the code for review for release to the marketplace.  There is one technical aspect they'd like me to change - which I'll do on the weekend too.
So I'll post the agregate over the weekend.

In the meantime -- you could try two things:
(1) add a short event that will not trip the calendar so that the new day has at least one event, or
(2) instead of triggering you scene on the plugin itself being tripped - trigger it on a calendar even = "ABCXYX" .  This way the event name will not be what you are triggering on at  the ened of the day and should terminate even though the plugin itself is still triggered.  (Hope this makes sense)
Title: Re: Google Calendar Switch
Post by: qwen3579 on May 13, 2014, 08:47:21 pm
Yes, that does make sense.  I'll give that a try.
Title: Re: Google Calendar Switch
Post by: Stuart on May 18, 2014, 05:10:25 pm
Here is the 1.1 version which I hope will be available through the marketplace in the next few days.  There are some additional improvements and at least one bug fix (all day event not stopping) since the 0.9 release.  See the documentation here for more details:

http://forum.micasaverde.com/index.php/topic,7558.msg175074.html#msg175074 (http://forum.micasaverde.com/index.php/topic,7558.msg175074.html#msg175074)

Note that the file names have changed and there has been some other internal renaming.  It was difficult to distinguish between l and II depending on fonts - so GCAlII was changed to GCal_II ).

So please delete any older version and re-install from scratch (following the documentation).  This is the last time I will do this to all y'all (promise) and from now on updates should all be through the marketplace.
Title: Google Calendar Switch II
Post by: Stuart on May 20, 2014, 03:25:56 pm
It's official  --  Google Calendar II has been released to the marketplace  :D

It retains the core functionality of the original marketplace version but has been almost completely rewritten / restructured to hopefully allow easier onging improvements.  Along the way I fixed a couple of 'quirks' and added some previously suggested functionality as well as some new capabilities.   In any case - it would not have been possible without the original authors / reviewers / 'early adopters' etc.

Among the additionl capabilities are:
- start end end delta
- keyword exact or partial match
- keyword match on description
- ignore events with keyword
- ignore all day events
- more info on the operating status

The documentation and install instructions are here:
http://forum.micasaverde.com/index.php/topic,7558.msg175074.html#msg175074 (http://forum.micasaverde.com/index.php/topic,7558.msg175074.html#msg175074)

If you find bug, vague  documentation or have a suggestion for added functionality - just post to this forum.

Title: Re: Google Calendar Switch
Post by: ft9 on May 20, 2014, 05:54:14 pm
Hello Stuart,
Great work with improving the original plug-in. Just a quick question: is it possible to send parameter values in keywords?
Let's say i want to turn my heater on 60 minutes before i wake up, can I use something like /heater{-60} in event description?
Regards

Sent from my GT-N7100 using Tapatalk

Title: Re: Google Calendar Switch
Post by: Stuart on May 20, 2014, 06:10:08 pm
Hello Stuart,
Great work with improving the original plug-in. Just a quick question: is it possible to send parameter values in keywords?
Let's say i want to turn my heater on 60 minutes before i wake up, can I use something like /heater{-60} in event description?
Regards

Sent from my GT-N7100 using Tapatalk

Not in the current version - but we could agree a convention that is different to the existing { } for passing parameters.   Something like (say) heater [-60,0] to mean start 60 minutes early and finish on time.  I could probably also allow heater [-60,0] {70} which would alter the start and stop times as well as allow you to use the parameter to set the temp.

As I think about it - having the option to pass in start delta and end delta on a per event basis is a nice addition. It would probably make sense to ignore gc_StartDelta and gc_EndDelta settings for any event where EventName [x,y] was used.

Maybe by the end of the week?  I'm on my tablet till then and it's a pain trying to do anything serious.  Also I'm going to release updates through the marketplace and am not sure if that adds a delay.

Anyone agree / disagree with this feature ?
Title: Re: Google Calendar Switch
Post by: ft9 on May 21, 2014, 05:35:17 am
That would be perfect! Hope everybody agrees.

Sent from my GT-N7100 using Tapatalk

Title: Re: Google Calendar Switch
Post by: kiethr on May 22, 2014, 09:37:11 pm
I guess I am doing something wrong.  I can't seem to get this to work.  I have used the first version with no issues.  I uninstalled the old plug in and installed the new.  Added the link to my calendar which did appear as expected.  I am using it as a trigger and using "a calendar event matched key word"  My event is called WORK WAKE UP.  It appears the GCal_II device finds my event and changes its state to "tripped" the guy turns red, but the light associated with the trigger doesn't turn on.

Thanks
Title: Re: Google Calendar Switch
Post by: Stuart on May 22, 2014, 11:59:22 pm
I guess I am doing something wrong.  I can't seem to get this to work.  I have used the first version with no issues.  I uninstalled the old plug in and installed the new.  Added the link to my calendar which did appear as expected.  I am using it as a trigger and using "a calendar event matched key word"  My event is called WORK WAKE UP.  It appears the GCal_II device finds my event and changes its state to "tripped" the guy turns red, but the light associated with the trigger doesn't turn on.

Thanks

Using "a calendar event matches keyword" requires you to supply the name of the event in the trigger (note all upper case).  Is that what you are doing ?  A screen shot or two would help (especially how you defined the trigger).  If the guy turns red as expected then it seems like the issue may be in the way the trigger is defined.
Title: Checking? Hang for Google Calendar Switch
Post by: davidw on May 23, 2014, 12:23:11 am
I just loaded the plugin (from the app market) and set the link. I can see the calendar in the 2nd tab (in cp.mios interface), but when I click "check", it hangs on "checking?" forever. I tried the feed URL in my browser and got a correct JSON back with my test event in it. See the decode error below.

50   05/22/14 21:11:13.327   luup_log:19: GCal_II: Requested url: http://www.google.com/calendar/feeds... <0x2d41b680>
50   05/22/14 21:11:13.327   luup_log:19: GCal_II: url status: 200 <0x2d41b680>
02   05/22/14 21:11:13.328   luup_require duplicate json <0x2d41b680>
01   05/22/14 21:11:13.329   LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:104: attempt to call field 'decode' (a nil value) <0x2d41b680>
31   05/22/14 21:11:13.330   AlarmManager::Run finish callback for alarm 0x11ba798 entry 0x10c8f00 type 7 id 3 param=0x1133d50 entry->when: 1400818273 time: 1400818273 tnum: 0 slow 1 duration 0 <0x2d41b680>

I downloaded all the source files directly and found that one of them (json.lua) does not get installed when you use the app market.  The 'decode' function is required for the device to work, and that function is in json.lua.

Once I uploaded json.lua into the /usr/lib/lua directory, everything worked as advertised.
Title: Re: Google Calendar Switch
Post by: kiethr on May 23, 2014, 08:05:28 am
Ha, my brain wasn't thinking right last night, in the key word match I put 3 thinking that I wanted it to match all three words of the trigger. I will update it with the name of the calendar event. Sometime I wonder about my self ;)


Sent from my iPhone
Title: Re: Checking? Hang for Google Calendar Switch
Post by: Stuart on May 23, 2014, 10:33:32 am
I downloaded all the source files directly and found that one of them (json.lua) does not get installed when you use the app market.  The 'decode' function is required for the device to work, and that function is in json.lua.

Once I uploaded json.lua into the /usr/lib/lua directory, everything worked as advertised.

Many thanks for this.  I had assumed that json.lua was part of the standard install of vera.  Probably in my case it got installed with the original google calendar plugin.  I'll contact the mios team and find out how to package it into the pluging.
Title: Google Calendar II V1.2
Post by: Stuart on May 23, 2014, 01:33:27 pm
Version 1.2 is pending approval / release to the marketplace.

Calendar events can now be defined with individual start and end delta's as follows:
Also -- I added a restriction that an event less than one minute in duration would be ignored (it was possible with poor selection of start and end delta's to have an event finish before it started   :P  )


Events can be named in the calendar as a word or words (do not use quotes)
e.g. "Occupied" or "Wake Up"

In addition there are two optional elements (either or both can be used) that can be added after the event name :
Event Name  {some parameters}  [x,y]
The portion excluding anything in {} and [] is the event name.
The portion in {} is used to populate gc_Value and can be used by other plugins as input.
The portion in [] specifies a start(x) and end(y) delta (in minutes) for that event only.

gc_StartDelta and gc_EndDelta are still there and apply globally to all events except those that use the new  [x,y] option.

So - for example, one could have an event in the calendar to  start at 07:00 and finish at 09:00 as "wake up [-30,5] {70}"
It would actually start at 06:30 (the -30) and finish at 9:05 (the 5) and your scene could use the gc_Value of 70 to set the temperature.

For those who are on V1.1 and comfortable with a manual update - here is the update file




Title: Re: Google Calendar Switch
Post by: AEBogdan on May 26, 2014, 10:18:43 am
Excellent plug-in!

After using it this week, I came up with two features that would make it perfect for my particular needs. Both seem like they should fit into the way the plug-in works.

The first is a trigger event type of "A calendar event goes inactive". This event type would trigger at the calendar event's Start_DateTime+Duration+End_Delta. (On "All Day" events set Start_DateTime to start of first day and the Duration to 24 * Number_Of_Days.) This would allow me to easily run a scene after an event ends without having to add additional calendar entries or additional complex background logic not associated with calendar entries.

Second, as I understand it the delta values can be entered globally for all events or in the calendar text, but for my situation the best place for them would be in the trigger event definitions. This would allow default deltas to change for specific keywords without special codes being needed on the calendar itself, thus allowing my wife to enter her calendar events as always, while I can still have different deltas based on the keywords used.

As far as I can tell these features don't exist yet?

Thanks for all the hard work on updating this!
Title: Re: Google Calendar Switch
Post by: Stuart on May 26, 2014, 12:24:35 pm
Excellent plug-in!

The first is a trigger event type of "A calendar event goes inactive". This event type would trigger at the calendar event's Start_DateTime+Duration+End_Delta. (On "All Day" events set Start_DateTime to start of first day and the Duration to 24 * Number_Of_Days.) This would allow me to easily run a scene after an event ends without having to add additional calendar entries or additional complex background logic not associated with calendar entries.

You should take a look at the wonderful PLEG plugin.  I use it for just this sort of thing - because it allows you to do things on both start and end of triggers, other plugin values, schedules and delays etc etc.  You can get very creative or just keep it simple.

It makes us all look good because we don't have to wrestle with such logic in our own plugins !!   Specifically - you can create a simple sequence that (say) does something when the all day event starts and something else when it finished.  For example - I have an all day event called "Occupied" which warms up a rental cottage when it is booked and sets it to lower temperatures when there is no event called "Occupied".

Actually - I started off with a simple version and then expanded it to a state sequence (just because I could  ::) )

PLEG handles this perfectly.
Title: Re: Google Calendar Switch
Post by: Stuart on May 26, 2014, 12:43:24 pm

Second, as I understand it the delta values can be entered globally for all events or in the calendar text, but for my situation the best place for them would be in the trigger event definitions. This would allow default deltas to change for specific keywords without special codes being needed on the calendar itself, thus allowing my wife to enter her calendar events as always, while I can still have different deltas based on the keywords used.

If I understand you correctly - you are suggesting that the value for gc_Keyword be able to be defined something like this:

"Keywords [x,y]  -  where all events that match the keyword have a specific start / end delta ?  independent of the global values and without needing to put [x,y] in the event description in the calendar ?

This could be an other variation but would only work for the ONE keyword that is defined in gc_Keyword.  It should  be fairly easy to add - so I'll go ahead and take a look.

If you are suggesting multiple keywords being able to be defined for each plugin instance -  each with it's own [x,y] start and end delta i.e. gc_Keyword1, gc_Keyword2, gc_Keyword3 -- I had thought of such a scheme.  The problem is - how many ? and the advanced tab ends up being long .....

An alternative to this is that you create additional plugin instance for each keyword [x,y] combination (each with a single keyword).  If there was a lot of requests for the multiple keyword variation then it might be worth the added complexity - but I'd prefer to wait and see how much interest there was before going ahead.

Title: Re: Google Calendar Switch
Post by: garrettwp on May 26, 2014, 01:02:58 pm

Second, as I understand it the delta values can be entered globally for all events or in the calendar text, but for my situation the best place for them would be in the trigger event definitions. This would allow default deltas to change for specific keywords without special codes being needed on the calendar itself, thus allowing my wife to enter her calendar events as always, while I can still have different deltas based on the keywords used.

If I understand you correctly - you are suggesting that the value for gc_Keyword be able to be defines something like this:

"Keywords [x,y]  -  where all events that match the keyword have a specific start / end delta ?  independent of the global values and without needing to put [x,y] in the event description in the calendar ?

This could be an other variation but would only work for the ONE keyword that is defined in gc_Keyword.  It should  be fairly easy to add - so I'll go ahead and take a look.

If you are suggesting multiple keywords being able to be defined for each plugin instance -  each with it's own [x,y] start and end delta i.e. gc_Keyword1, gc_Keyword2, gc_Keyword3 -- I had thought of such a scheme.  The problem is - how many ? and the advanced tab ends up being long .....

An alternative to this is that you create additional plugin instance for each keyword [x,y] combination (each with a single keyword).  If there was a lot of requests for the multiple keyword variation then it might be worth the added complexity - but I'd prefer to wait and see how much interest there was before going ahead.

Glad to see you are working on revamping this plugin. The problem with creating new instances of the plugin, since this plugin does not have a parent device, the more instances you create, the memory is consumed by Vera. You have two options to over come this. Create a parent device for the Google calendar switch and populate new child devices. Or you can add the complexity of allow for multiple keywords with the value and delta options. It may be easier to accommodate the multiple keyword support. I was the original person to add support for multiple keywords via the advanced tab due to not wanting to create several instances of the plugin and not consume more memory than needed.

- Garrett
Title: Re: Google Calendar Switch
Post by: Stuart on May 26, 2014, 01:43:24 pm

Second, as I understand it the delta values can be entered globally for all events or in the calendar text, but for my situation the best place for them would be in the trigger event definitions. This would allow default deltas to change for specific keywords without special codes being needed on the calendar itself, thus allowing my wife to enter her calendar events as always, while I can still have different deltas based on the keywords used.

If I understand you correctly - you are suggesting that the value for gc_Keyword be able to be defines something like this:

"Keywords [x,y]  -  where all events that match the keyword have a specific start / end delta ?  independent of the global values and without needing to put [x,y] in the event description in the calendar ?

This could be an other variation but would only work for the ONE keyword that is defined in gc_Keyword.  It should  be fairly easy to add - so I'll go ahead and take a look.

If you are suggesting multiple keywords being able to be defined for each plugin instance -  each with it's own [x,y] start and end delta i.e. gc_Keyword1, gc_Keyword2, gc_Keyword3 -- I had thought of such a scheme.  The problem is - how many ? and the advanced tab ends up being long .....

An alternative to this is that you create additional plugin instance for each keyword [x,y] combination (each with a single keyword).  If there was a lot of requests for the multiple keyword variation then it might be worth the added complexity - but I'd prefer to wait and see how much interest there was before going ahead.

Glad to see you are working on revamping this plugin. The problem with creating new instances of the plugin, since this plugin does not have a parent device, the more instances you create, the memory is consumed by Vera. You have two options to over come this. Create a parent device for the Google calendar switch and populate new child devices. Or you can add the complexity of allow for multiple keywords with the value and delta options. It may be easier to accommodate the multiple keyword support. I was the original person to add support for multiple keywords via the advanced tab due to not wanting to create several instances of the plugin and not consume more memory than needed.

- Garrett

Understood and agreed.  In my mind - it's really a question of 'how much / how many"  If only one or two people want this functionality - is the memory overhead a big deal ?  I have no idea how tight (in practical terms, for the average user) memory is on the vera ???   Having said that, allowing for (say) three specific keywords with defined start / end delta's would not be too 'ugly'.  Your "any keyword' support (i.e. keyword blank in the advanced tab) is still there of course - so I'm guessing that's what you referred to versus a method of specifying multiple keywords ??

Thinking out aloud - another approach is to allow a list of keywords (with or without start end delta) and trigger on any events match - might be the tidiest approach ..... or was that your mod ?
Title: Re: Google Calendar Switch
Post by: ft9 on May 26, 2014, 07:45:08 pm
Hello.
I installed app 1.1 from marketplace and then manually updated to 1.2 with the file posted a few posts above but in installed apps sections, stills shows 1.1. Is this right? Coincidentally or not, I'm having troubles setting start and end delta per event, and this is one of the differences between 1.1 and 1.2
Thanks


Sent from my GT-N7100 using Tapatalk

Title: Re: Google Calendar Switch
Post by: AEBogdan on May 26, 2014, 08:01:52 pm
I was thinking along the lines Garrett suggested. Add the delta feature under the "A calendar event matches keyword" event type that is assigned under the Advanced Triggers tab to a Scene. This allows using the current ability to have multiple keywords trigger different scenes with a single calendar instance, just adding the delta flexibility.
Title: Re: Google Calendar Switch
Post by: Stuart on May 27, 2014, 01:55:16 am
I was thinking along the lines Garrett suggested. Add the delta feature under the "A calendar event matches keyword" event type that is assigned under the Advanced Triggers tab to a Scene. This allows using the current ability to have multiple keywords trigger different scenes with a single calendar instance, just adding the delta flexibility.

"A calendar event matches keyword"  really means "A calendar event matches any keyword" because it's up to the scene to decide if the calendar event name applies to it.  So at that level - one could use the global gc_StartDelta and gc_EndDelta settings.

Having said that - I made some changes today and will more fully test tomorrow - which I think give a great deal of flexibility:

1) Multiple keywords can be defined in gc_Keyword - each separated by a semi-colon ";"  In effect an OR of multiple keywords
2) Each keyword can have an optional start / end delta defined by [x,y]
e.g. key [-5,10]; keyword 2; key three [20,-5]

if used - keyword start / end settings take precedent over any start /  end delta defined in an event name
e.g. key [-10,10] as the event name would be used as such if no keyword were defined but if gc_Keyword was set to key[-5,10]; ....  then the start / end in gc_Keyword would be used.

if used - event name start / end settings take precedent over the global gc_Startdelta and gc_EndDelta

I am also working with the mios dev folks to agree a method for including a utility module (in my case json.lua) in a plugin.  It's a long story but the nuances of their version control software mean that I cannot 'include' jsaon.lua in GCal_II because that module has already been included the original GCal.  If you already used the original - then no issue, if you have not - then it's a problem.  Bottom line - hope to have this (and the changes described above) released by the end of the week.
Title: Re: Google Calendar Switch
Post by: Stuart on May 27, 2014, 06:30:57 pm
Hello.
I installed app 1.1 from marketplace and then manually updated to 1.2 with the file posted a few posts above but in installed apps sections, stills shows 1.1. Is this right? Coincidentally or not, I'm having troubles setting start and end delta per event, and this is one of the differences between 1.1 and 1.2
Thanks


Sent from my GT-N7100 using Tapatalk

You will not see  a version # difference with the manual update.

What sort of problem are you encountering?
Title: Re: Google Calendar Switch
Post by: ft9 on May 27, 2014, 07:14:45 pm
Per event start and end delta doesn't work for me, only default values, set on plugin's advanced tab.
My description is /aq[-30,10]    Being /aq my keyword, is syntax correct?
How can I check plugin version when manually installed? (Just to be sure I'm using latest version)

Thanks
Title: Re: Google Calendar Switch
Post by: Stuart on May 27, 2014, 07:26:18 pm
Per event start and end delta doesn't work for me, only default values, set on plugin's advanced tab.
My description is /aq[-30,10]    Being /aq my keyword, is syntax correct?
How can I check plugin version when manually installed? (Just to be sure I'm using latest version)

Thanks

See if removing the / helps i.e. name your event aq[-30,10].  I did not test with "strange" characters  ;D   Also what does the display panel for the event look like - is it showing the times for the event as depicted in the calendar ?  Is it adjusting for the gc_StartDelta and gc_EndDelta ?

Title: Re: Google Calendar Switch
Post by: ft9 on May 27, 2014, 07:43:47 pm
I tried to remove the / with the same results. Panel shows the event adjusted with gc_StartDelta and gc_EndDelta. It ignores event parameter completely.

Sent from my GT-N7100 using Tapatalk

Title: Re: Google Calendar Switch
Post by: Stuart on May 27, 2014, 11:25:55 pm
I tried to remove the / with the same results. Panel shows the event adjusted with gc_StartDelta and gc_EndDelta. It ignores event parameter completely.

Sent from my GT-N7100 using Tapatalk

I took a quick look at the 1.2 code and don't immediately see why it isn't working (my current test setup is a couple of revisions further on and it works there just fine)

This may sound a bit pedantic - but earlier you mentioned ag[x,y] in the description.  Do you mean the event name or do you mean the event description ?  It will not look for [x,y]  in the description .
Title: Re: Google Calendar Switch
Post by: ft9 on May 28, 2014, 06:36:06 am
That's the problem then. I have it in the description. Later I'll test on event name.
Anyway, is it possible to make it look on description as well? This way events don't have to appear like geek code :-)
Thank you

Sent from my GT-N7100 using Tapatalk

Title: Re: Google Calendar Switch
Post by: Stuart on May 28, 2014, 07:03:53 am
Anyway, is it possible to make it look on description as well? This way events don't have to appear like geek code :-)
Thank you

Sent from my GT-N7100 using Tapatalk

Incremental steps ......   ;D

Just adding to be able to be extracted from the description is straightforward enough -- but there needs to be a precedence - what if it's in both places ?  title and description ?  Who wins ?
Title: Re: Google Calendar Switch
Post by: ft9 on May 28, 2014, 07:31:20 am
In both even better, so one can choose wherever likes.

EDIT: Just checked and keyword with start and end delta works on event name.

Sent from my GT-N7100 using Tapatalk

Title: Re: Google Calendar Switch
Post by: AEBogdan on May 28, 2014, 08:47:03 pm
Stuart,

You mentioned that PLEG could trigger actions at the end of a Calendar event, not just the start. I'm not seeing how this is done. Any chance I could get you to explain your method? Thanks!

Al
Title: Re: Google Calendar Switch
Post by: Stuart on June 02, 2014, 12:48:52 am
Stuart,

You mentioned that PLEG could trigger actions at the end of a Calendar event, not just the start. I'm not seeing how this is done. Any chance I could get you to explain your method? Thanks!

Al
There are many ways and there is good set of documentation in the PLEG thread but, by way of a simple example:

Lets say you have:
 a PLEG trigger defined like this: EventOccupied when Calendar: Armed calendar event is Active

and two conditions like this:
Occupied when  EventOccupied
NotOcupied when !EventOccupied

and associated with each you define some actions.

In this example - a set of actions associated with the calendar event becoming active and a different set of actions (perhaps to undo the first) when the calendar event ceases to be active.

Hope this helps - but working through the documentation and the PLEG thread is highly recommended.

Title: Google Calendar Switch II - Version 1.3
Post by: Stuart on June 04, 2014, 10:22:34 am
Google Calendar Switch II - Version 1.3 has been released in the marketplace.   :o

There are a number of changes but backward compatibility is retained.

The simple ones:
-- The plugin checks for the existence on the vera of a module used to encode / decode json - if it's not there it downloads it.  Users of the original GC already have this installed because it was part of that package.
-- a new parameter gc_debug is defaulted to 'false' meaning that debug messages will not be put into the vera logs.  This is because the more interesting messages are displayed on the front panel.  If you need to debug - just change this to 'true' (no quotes)

Now the main changes:

1.  As before - gc_Keyword can be left blank and the plugin can trigger on all events
2.  You can now specify one or more keywords in gc_Keyword.  Each keyword is separated by a semi-colon ; .So you can trigger (or ignore) on several specific keywords. Note especially that the first keyword in the list that matches a calendar event is the one that is used.
3.  start and end delta can be specified in [] e.g. [-5,5] and parameters in {} e.g. {70}
     a.  [x,y] and {parameter} info can be placed in the keyword or event name or description in any combination
     b.  the order of precedence is keyword, event name, description, default
     c.  only the first [x,y] or {parameter} found will be used (i.e. the order of precedence).  This way, the higher order of precedence overrides anything 'lower down'
     d.  the defaults for [x,y] are the values for gc_startDelta and gc_endDelta and the default parameter is "" (i.e. nothing)

This gives considerable flexibility - so Caveat Emptor  ::)

A keyword example:
Test 1 [-10,-10];  Word [-7,7] {cold}
specifies two keyword the first will match calendar events 'Test' and specifies a start delta of -10 and a stop delta of -10.  The second keyword will match calendar events 'Word' and specifies a start delta of -7 and a stop delta of 7 as well as a parameter 'cold'

If there was an event with the name 'Word' and 'test 1' in the description - the first keyword would match the description (see precedence) and so that keywords [x,y]  would be used.
On the other hand an event with the name 'test 1 and 'word' in the description would also be matched by the first keyword

Some uses:
So - for those who like 'pretty' event names in their calendars ... the description can contain the keyword match and optionally the start/end delta and a parameter
Similarly - if you have specific events that you want to trigger and each has a default start / end delta - you can specify this in the keywords
Or - if you really really wanted to (probably not a good idea), you could specify a keyword with no start end delta or parameter, put the parameter in the event name and the start end delta in the description.
Or ......

Personally, I'd pick a simple style and stick to it .... ;D

enjoy.




Title: Re: Google Calendar Switch
Post by: ft9 on June 04, 2014, 05:39:38 pm
Great improvement!
I'll test it when its available in the marketplace.
Title: Re: Google Calendar Switch
Post by: korttoma on June 05, 2014, 01:05:14 am
Thanks allot Stuart for taking the time to improve this great plugin.

The installation procedure is a bit unclear to me though.
You mention that "backward compatibility is retained", what exactly do you mean? Backward compatible with previous version of your plugin or the old GCal plugin?
I have the previous version of GCal installed so do I uninstall?
Will your plugin just update the old one?
If I don't uninstall the old one and install your plugin will I then have 2 plugins installed?

I basically only have one GCal device for marking holidays with an all day event but it is used in allot of PLEG conditions so what would be the smoothest way to update to your plugin?
Should I even bother to update since I will not be using all the fancy new features right now.

I have struggled with some memory issues in the past with my veralite so I carefully consider everything I install. Do you know if your GCal consumes any considerable amount more then the previous GCal plugin?

Thanks again for all your work Stuart!

Regards,
Tomas
Title: Re: Google Calendar Switch
Post by: Stuart on June 05, 2014, 03:10:24 pm
Thanks allot Stuart for taking the time to improve this great plugin.

The installation procedure is a bit unclear to me though.
You mention that "backward compatibility is retained", what exactly do you mean? Backward compatible with previous version of your plugin or the old GCal plugin?

By 'backward compatible' - I was refering to the functionality.  In othe words - the default behavior is the same as the original GCal.  The code is almost completely rewritten.  I did this to fix some problems in the original (mostly to do with all day events) and to make ongoing changes (i.e. the fancy stuff) easier to incorporate.  So GCal_II is a replacement not a code upgrade.

You don't need to remove the original (as GCal_II has it's own code) but on the other hand - you don't need two plugins !

You might want to download the newer version, make sure it works for you and then delete the old version.  Or - if the old version works for you --  just keep using it.

For PLEG - you should only need to modify your trigger definitions to 'point' to the new plugin.  Note that if you are triggering on a specific event name - they are now all forced to upper case.
Title: Re: Google Calendar Switch
Post by: roquej on June 06, 2014, 12:33:39 am
I have an issue and would greatly appreciate the help.  I placed the keyword Vacation in the gc_Keyword field. I then defined a scene with the trigger  "calendar even matches keyword" = VACATION. However, the trigger is not working. The plugin is recognizing the calendar event, but the scene is not triggering.

Any suggestions? 

Thank you in advance.
Title: Re: Google Calendar Switch
Post by: korttoma on June 06, 2014, 02:04:25 am
Thanks for clarifying things for me Stuart  ;)
Title: Re: Google Calendar Switch
Post by: Stuart on June 06, 2014, 10:06:36 pm
I have an issue and would greatly appreciate the help.  I placed the keyword Vacation in the gc_Keyword field. I then defined a scene with the trigger  "calendar even matches keyword" = VACATION. However, the trigger is not working. The plugin is recognizing the calendar event, but the scene is not triggering.

Any suggestions? 

Thank you in advance.

Hi -- well I checked this on my system and did have some strange behavior .....  :'(

Could you  try one thing first - just to verify that the plugin is working (more or less).   Instead of using "calendar even matches keyword"  change the trigger to "A calendar event is active" or "An armed calendar event is active" and make sure the scene triggers.  I'm suggesting this since you have a keyword set anyway.  Usually, you'd only use "calendar even matches keyword" if you have no keyword set in the advanced tab (i.e. match any event).  The wording is a bit confusing but it's the same as was used on the original plugin -- I probably should change it ....   What you did was ok though - just that I probably haven't tested it recently that way - although in theory it should not matter as there is no code to specifically test for this (there is a definition but that hasn't been changed for a long time).

Also - do / did you have the original plugin installed in the past ?  The reason why I ask is that I was able to reproduce (I think) what you are experiencing - in fact, when the trigger was set to "calendar even matches keyword" - it looked like my vera was looping.   I tried several combinations and all worked except "calendar even matches keyword".  What I then did was I tried the original plugin - and it misbehaved in the same way.   So I deleted all versions - force removed all the files 'rm *Gcal*' and then reinstalled GCal_II.   All is now well ...... which is both good and not so good as , to my level of knowledge, it defies logic --

Let me know and we can get to the bottom of it.  I may need to solicit the help of some of the 'big gun' developers though

EDIT:  Still looping.  I'll have to dig deeper .....
Title: Re: Google Calendar Switch
Post by: roquej on June 07, 2014, 12:48:08 pm
Stuart,

I had tried all of your suggestions already, including deleting all the old files and reinstalling.  Everything works when triggering on "A calendar event is active" or "An armed calendar event is active". However, the sensor doesn't trigger and Vera goes into a loop when using "calendar event matches keyword". I have also tried with a keyword in gc_Keyword, without keywords, and multiples keywords. Same results. 

Way over my head at this stage.   Going to leave it in your capable hands!

Again, thank you for great work and help.
Title: Re: Google Calendar Switch
Post by: AEBogdan on June 07, 2014, 01:19:48 pm
Any possibility my use of the "calendar even matches keyword" is why my Vera now locks up occasionally after a Reload? The LUUP engine does not reload. I did a reset and restore yesterday and today to get Vera functioning again. Both times it happened after trying to add a simple scene. It's either one of three plug-ins I updated/installed this week or the low memory issue I've read about. May need to learn some of the more advanced debugging techniques now.
Title: Re: Google Calendar Switch
Post by: Stuart on June 07, 2014, 01:46:37 pm
Any possibility my use of the "calendar even matches keyword" is why my Vera now locks up occasionally after a Reload? The LUUP engine does not reload. I did a reset and restore yesterday and today to get Vera functioning again. Both times it happened after trying to add a simple scene. It's either one of three plug-ins I updated/installed this week or the low memory issue I've read about. May need to learn some of the more advanced debugging techniques now.

YES !!  Absolutely.  This is what I am seeing on my vera as I try to figure out what's happening (see above)   :P
http://forum.micasaverde.com/index.php/topic,7558.msg179672.html#msg179672

 For me it is only when when I try to use "calendar even matches keyword" in a trigger for a scene.  Looks like it is causing the vera to reload (and loop) when the next event occurs.    If I use "A calendar event is active" or "An armed calendar event is active" as the trigger then everything seems normal.

The calendar event matches keyword functionality is not actually a code thing - other than setting the value of gc_TrippedEvent.  There is code that defines what "calendar even matches keyword" means but that is in a file that I have not touched for quite a while - and which is copied form the previous plugin.  Having said that - the code that defines the event is a bunch of array definitions and could easily have a typo.

At this time - I'm suspecting there may be a bug in mios and I will try to have a conversation with the mios developers Monday.  The reason I suspect a bug is this:
IF I USE PLEG - and trigger on "calendar even matches keyword" - everything seems to work just fine.  This is how I did all the testing (my bad) and probably why I did not see this issue before.  So there is something different between how mios is reacting to the internal event and how PLEG is reacting (but why behave differently ?).

In the meantime - could I suggest one of the following approaches:  (1) Use PLEG or (2) define multiple keywords and use "An armed calendar event is active".

Apologies to all .....

Title: Re: Google Calendar Switch
Post by: AEBogdan on June 07, 2014, 09:05:35 pm
Spent over six hours trying to get Vera working again. Been doing resets and restoring backups and then deleting the plug-in and trying to reset scene controllers I have that don't reinstall correctly. Before I can get Vera fully operational again it starts freezing up or becoming inaccessible.

Should uninstalling the Google Calendar plug-in be good enough or do I need to manually delete files as well? Any suggestions or thoughts? Do you expect a fix any time soon, as my Vera is dead until I figure out how to get around whatever is happening.
Title: Re: Google Calendar Switch
Post by: Stuart on June 07, 2014, 09:25:13 pm
Spent over six hours trying to get Vera working again. Been doing resets and restoring backups and then deleting the plug-in and trying to reset scene controllers I have that don't reinstall correctly. Before I can get Vera fully operational again it starts freezing up or becoming inaccessible.

Should uninstalling the Google Calendar plug-in be good enough or do I need to manually delete files as well? Any suggestions or thoughts? Do you expect a fix any time soon, as my Vera is dead until I figure out how to get around whatever is happening.

Sounds like you may have something else going on as well.   With the GCal_II problem, all I had to do was remove the trigger that was trying to use "calendar even matches keyword" and everything went back to normal.  Uninstalling the plugin should eliminate it as a possible culprit since vera should not try to run anything to do with the plugin (even though the files are still there).

If you have uninstalled GCal_II - to be absolutely sure, you could try the the following:

In Apps --> Develop Apps --> Test Luup code (Lua)

insert and run (Go) the following - which will remove all the files associated with GCal_II. 

  local filename = "/etc/cmh-ludl/*GCal_II*"
  local filefound = os.execute("rm " .. filename)

Also - try a reboot.   Setup --> Network and WiFi --> Reboot

Hope this helps

Title: Re: Google Calendar Switch
Post by: Stuart on June 07, 2014, 11:38:09 pm
Stuart,

I had tried all of your suggestions already, including deleting all the old files and reinstalling.  Everything works when triggering on "A calendar event is active" or "An armed calendar event is active". However, the sensor doesn't trigger and Vera goes into a loop when using "calendar event matches keyword". I have also tried with a keyword in gc_Keyword, without keywords, and multiples keywords. Same results. 

Way over my head at this stage.   Going to leave it in your capable hands!

Again, thank you for great work and help.

Thanks for your patience.  I've sent a note to the Mios developers to see if they can offer some insight or some debugging technique.   So probably Monday before I hear back.  It could be something silly on my part (like a typo) or it could be a bug or ..... something .....


Title: Re: Google Calendar Switch
Post by: Stuart on June 08, 2014, 04:15:55 pm
I  have (I think) identified the circumstances when "Calendar event matches keyword" fails:

If the mios event trigger is defined with notification, it fails.  If the mios event trigger is defined with no notification (see screenshot) it succeeds.  I'm using the term mios here to differentiate from PLEG which always seems to work.  Once the failure occurs (e.g. because notification was on - see screenshot)  - it looks like you have to remove the trigger and recreate it (without notification) to get it to work.

Note that the wording is slightly different in the screen shots "An event has specified name" is the same as  "Calendar event matches keyword"  -- and will hopefully be more meaningful in the future

I'll see what the mios developers have to say as to how to fix
Title: Re: Google Calendar Switch
Post by: mike Q on June 12, 2014, 08:43:01 pm
I use the calendar switch to control our morning routine.  I put an entry on the calendar for days that our kids don't have school so all the morning routines associated with school don't run.

I have a battery powered accessory switch by my main exit to the house.   When I leave I press this button and vera runs a scene to shut down the house.
I'd also like it at this point to read off any events that I have schedule for the day.

Is there a way to get a list of events schedule for the whole day or for a window of time?
Title: Re: Google Calendar Switch
Post by: Stuart on June 12, 2014, 11:34:34 pm

I'd also like it at this point to read off any events that I have schedule for the day.

Is there a way to get a list of events schedule for the whole day or for a window of time?
Could you explain more fully what you mean. GCall_II will monitor and trigger all relevant events, independently of your front door switch.  I'm unsure of what you mean by "read off any events that I have scheduled for the day"  (which in effect it does anyway)  and "get a list of events schedule for the whole day or for a window of time".   What would you want to do with such a list ?  How would you want it displayed ?

Other than looking in the calendar - I'm not sure what the intent of your question is, so I'm unsure how to answer.
Title: Re: Google Calendar Switch
Post by: mike Q on June 13, 2014, 12:19:49 am

I'd also like it at this point to read off any events that I have schedule for the day.

Is there a way to get a list of events schedule for the whole day or for a window of time?
Could you explain more fully what you mean. GCall_II will monitor and trigger all relevant events, independently of your front door switch.  I'm unsure of what you mean by "read off any events that I have scheduled for the day"  (which in effect it does anyway)  and "get a list of events schedule for the whole day or for a window of time".   What would you want to do with such a list ?  How would you want it displayed ?

Other than looking in the calendar - I'm not sure what the intent of your question is, so I'm unsure how to answer.

Basically what I want is an array of gcalkeyword or gcalnextevent. 

Right now when a calendar event triggers, I can do something like this:

str2 = luup.variable_get(DEV_GCAL,"gcalkeyword", GCAL)
luup.call_action(DEV_ALERT, "SendAlert", {Message = str2, Recipients = ""}, VERAALERT )

and my houses "voice" will speak whatever the event is.

I'd like to make it so it can speak all the schedules events for the day.

Say on my calendar I have 3 events for today, 11:00am doctors app, 12:30 lunch with wife, 4:00pm paragliding with Jim.

I want to be able to activate a scene that fires off some luup code that would go to the calendar and read off the 3 events

So something like this pseudo code:

For each calendar event do
{
    str2 = luup.variable_get(DEV_GCAL,"gCalNextEvent", GCAL)
    luup.call_action(DEV_ALERT, "SendAlert", {Message = str2, Recipients = ""}, VERAALERT )
}
Title: Re: Google Calendar Switch
Post by: Stuart on June 13, 2014, 09:42:16 am
Basically what I want is an array of gcalkeyword or gcalnextevent. 


Ok - I understand.  In fact, I had anticipated that but had not got around to implementing anything.  There is a variable gc_jasonEvents set aside for the purpose.   The question now is "what information".  If we just take the raw json calendar output for events that would cause a trigger - we'd get something like this (don't worry about the order - I'd fix that ...)

[{"gd$when":[{"endTime":"2014-06-13T12:00:00.000-06:00","startTime":"2014-06-13T10:30:00.000-06:00"}],"content":{"type":"text","$t":""},"title":{"type":"text","$t":"Third event"}},{"gd$when":[{"endTime":"2014-06-13T10:00:00.000-06:00","startTime":"2014-06-13T09:00:00.000-06:00"}],"content":{"type":"text","$t":""},"title":{"type":"text","$t":"second Event"}},{"gd$when":[{"endTime":"2014-06-13T08:30:00.000-06:00","startTime":"2014-06-13T08:00:00.000-06:00"}],"content":{"type":"text","$t":""},"title":{"type":"text","$t":"First Event"}}]

This seems quite a lot of info - but maybe not since each user could simply load it into an array and extract what they want.  I think though that changing the dates to the effective date / time i.e. taking into account any start and end delta's if used - would make sense.

Or a simpler format with only the effective start , end datetime and event names ? 

What are your thoughts ?
Title: Re: Google Calendar Switch
Post by: mike Q on June 13, 2014, 11:44:29 pm
Basically what I want is an array of gcalkeyword or gcalnextevent. 


Ok - I understand.  In fact, I had anticipated that but had not got around to implementing anything.  There is a variable gc_jasonEvents set aside for the purpose.   The question now is "what information".  If we just take the raw json calendar output for events that would cause a trigger - we'd get something like this (don't worry about the order - I'd fix that ...)

[{"gd$when":[{"endTime":"2014-06-13T12:00:00.000-06:00","startTime":"2014-06-13T10:30:00.000-06:00"}],"content":{"type":"text","$t":""},"title":{"type":"text","$t":"Third event"}},{"gd$when":[{"endTime":"2014-06-13T10:00:00.000-06:00","startTime":"2014-06-13T09:00:00.000-06:00"}],"content":{"type":"text","$t":""},"title":{"type":"text","$t":"second Event"}},{"gd$when":[{"endTime":"2014-06-13T08:30:00.000-06:00","startTime":"2014-06-13T08:00:00.000-06:00"}],"content":{"type":"text","$t":""},"title":{"type":"text","$t":"First Event"}}]

This seems quite a lot of info - but maybe not since each user could simply load it into an array and extract what they want.  I think though that changing the dates to the effective date / time i.e. taking into account any start and end delta's if used - would make sense.

Or a simpler format with only the effective start , end datetime and event names ? 

What are your thoughts ?

I'd be happy with a simpler format with date, start/end time and description (name).   The raw string would probably suffice too but it would take me some time to figure out how to parse it.

Title: Google Calendar II V 1.5
Post by: Stuart on June 15, 2014, 05:42:06 pm
Here is a preview of GCal_II V1.5  I'll be submitting it to the marketplace in a day or two - waiting to see if the mios developers are able to shed light on the reload loop issue mentioned earlier.

This version fixes a small bug (may or may not have been noticable) and adds new functionality.

There is a new variable gc_jsonEvents.  This variable is populated with a summary of the eligible events for use by other plugins / scenes.   gc_jsonEvents is json encoded with each entry comprising the effective start time, end time and name of the event.  Effective means that the event satisfies any keywords etc and also takes into account any start and end delta's.  By way of example - here are three events.

[{'eventEnd':1402867800,'eventStart':1402866000,'eventName':'FIRST EVENT'},{'eventEnd':1402869000,'eventStart':1402868400,'eventName':'SECOND EVENT'},{'eventEnd':1402870200,'eventStart':1402869900,'eventName':'THIRD EVENT'}]

To use the variable - it's simplest to decode the json into a table and then treat like an array.  Note that the start and end times are utc - so you will have to manipulate them to suit your needs.  To help illustrate - here is some test code I used:
local GCAL_SID = "urn:srs-com:serviceId:GCal2"
local myGooglePlugin = 45 ? change to be your GCal_II plugin device #
-- load the jason package
package.loaded.json = nil
local json = require("json")
local jsonEvents = luup.variable_get(GCAL_SID, "gc_jsonEvents", myGooglePlugin)
local eventList =json.decode(jsonEvents)

local numberEvents = table.getn(eventList)
local startevent, startDate, startTime, endevent, eventname, event
for i = 1,numberEvents do
  startevent = eventList[ i ].eventStart
  --startEvent = os.date("%Y-%m-%dT%H:%M:%S", startevent)
  startDate = os.date("%Y-%m-%d", startevent)
  startTime = os.date("%H:%M:%S", startevent)
  endevent = eventList[ i ].eventEnd
  endTime = os.date("%H:%M:%S", endevent)
  eventname = eventList[ i ].eventName
  event = "On " .. startDate .. " event " .. eventname .. " will start at " .. startTime .. " and end at " .. endTime
  luup.log(event)
end
-- unload json module
package.loaded.json = nil


There is only one file changed I_GCall_II.xml (attached).  Load it on the normal manner.
Ignore i.e. do not use the previous incorrectly spelled  placeholder gc_jasonEvents.  This will hang around until the plugin is deleted and then re installed (easiest to do when the marketplace version comes out)

Please provide any feedback.

EDIT:  Fixed a bug on 6/20/14 that would occur when there were no valid events  Version 1.5.2 .  File is here http://forum.micasaverde.com/index.php/topic,7558.msg181632.html#msg181632 (http://forum.micasaverde.com/index.php/topic,7558.msg181632.html#msg181632)
Title: Re: Google Calendar Switch
Post by: resq93 on June 16, 2014, 02:37:36 pm
Excuse my ignorance.... Where do the numbers in the { } after a keyword get saved? How would I incorporate the value in a PLEG condition?

M
Title: Re: Google Calendar Switch
Post by: Stuart on June 16, 2014, 03:11:39 pm
Excuse my ignorance.... Where do the numbers in the { } after a keyword get saved? How would I incorporate the value in a PLEG condition?

M

Info in {} is stored in a gc_Value for the current event. that is to say, it is not populated until the event Triggers.

In PLEG go to Inputs --> Device Properties, select your GCAL_II plugin and then you have access to all the properties - in this case gc_Value..
Title: Re: Google Calendar Switch
Post by: resq93 on June 16, 2014, 04:32:30 pm
Thank you. That works however the { } seem to included as well as part of the value. Is there any way to show only the numbers?
Title: Re: Google Calendar Switch
Post by: Stuart on June 16, 2014, 05:44:10 pm
Thank you. That works however the { } seem to included as well as part of the value. Is there any way to show only the numbers?

Yes ! Use this version of I_GCall_II.xml V1.5.1.  A previous "woops" on my part - must learn to follow my own specs  8)

P.S. If you are testing by looking at the advanced tab ....   remember to F5 in the browser to force the display to update otherwise it's hard to tell if something worked or not  (I know  ::) )

EDIT:  Bug fixed version 1.5.2 is here http://forum.micasaverde.com/index.php/topic,7558.msg181632.html#msg181632 (http://forum.micasaverde.com/index.php/topic,7558.msg181632.html#msg181632)
Title: Re: Google Calendar Switch
Post by: resq93 on June 16, 2014, 07:08:22 pm
Thank you, I will try that. On another note, I changed the interval time to 1 week and yet even when I check it it still shows no event today. The original version showed the next event regardless if it occurred in the next 24 hours. Am I doing something wrong?
Title: Re: Google Calendar Switch
Post by: Stuart on June 16, 2014, 07:42:39 pm
Thank you, I will try that. On another note, I changed the interval time to 1 week and yet even when I check it it still shows no event today. The original version showed the next event regardless if it occurred in the next 24 hours. Am I doing something wrong?

No - nothing wrong.  I changed the working  little from the original as it made things easier to interpret and there seemed little advantage to the original scheme.

In GCal_II the value of  gc_Interval (minutes) sets the minimum maximum time between checks of the calendar.  It will check the calendar at the start and end of each 'valid' event (i.e. an event that will cause it to trigger).  Also - if the time between the end of one valid event and the next valid event is more than gc_Interval, then it will check gc_Interval minutes after the first event and so on until the start of the next event.   So if there are no events in the near future it will check every gc_Interval minutes to see if anything has changed.

Each check of the calendar looks at a 24 hr window from 'now' (negative startDelta and positive endDelta will alter this a bit).  So events more than 24 hrs from 'now' will not be seen.

 The default value for gc_Interval is 3 hrs as a compromise between 'annoying' google (and vera) too often and seeing new events in the calendar.  If you place a new event in the calendar and it's less than 3 hrs from now - it may not be seen unless the plugin had a check scheduled before the new event (either another event or just lucky).   So - if you NEEDED a new event to be seen and it was scheduled in the next 3 hrs (or gc_Interval minutes if you use something other than the default) you'd need to press the check button on the plugin to force an update.

Setting gc_intterval to a large number (like 24hrs  - or one week  :-\ runs the risk of not seeing newly entered events) and setting it less than the default is likely a waste of vera resources (and maybe google will get upset with you if it's really small  :o )

Hope this explanation helps 
Title: Re: Google Calendar Switch
Post by: mike Q on June 19, 2014, 09:55:22 pm
I'm trying to use the new gc_jsonEvents variable.

I'm doing the following.   (logging 1,2... for debug purposes).  My calendar has 1 all day event and 2 other events.

package.loaded.json = nil
luup.log("****** 1")
local json          = require("json")
luup.log("****** 2")
local jsonEvents    = luup.variable_get(DEV_GCAL, "gc_jasonEvents", GCAL)
luup.log("****** jsonEvents" .. jsonEvents)
local eventList     = json.decode(jsonEvents)
luup.log("****** 4")

I seem to be crashing on the json.decode(jsonEvents). (I never make it to ***** 4).

luup_log:0: ****** 1 <0x2e4f1680>
50   06/19/14 21:51:31.398   luup_log:0: ****** 2 <0x2e4f1680>
50   06/19/14 21:51:31.398   luup_log:0: ****** jsonEvents <0x2e4f1680>
01   06/19/14 21:51:31.399   LuaInterface::CallFunction_Scene Scene  47 failed /usr/lib/lua/json.lua:373: unexpected termination of JSON while looking for object ({ or [ or ' or " or number or boolean or null expected) <0x2e4f1680>

Any ideas?

FYI, I'm not sure how to install the .xml file posted here so that may be part of the problem.   I just uploaded the file using the luup files->upload under develop apps.
Title: Re: Google Calendar Switch
Post by: Stuart on June 20, 2014, 12:25:23 pm
Mike,
Im traveling so a quick reply.  It looks like you have a typo getting the gc_jsonEvents variable.

more info -- specifically, it's gc_jsonEvents not gc_jasonEvents.  Easy to do - I did it several times ......

Ignore i.e. do not use the previous incorrectly spelled  placeholder gc_jasonEvents.  This will hang around until the plugin is deleted and then re installed (easiest to do when the marketplace version comes out)
Title: Re: Google Calendar Switch
Post by: mike Q on June 20, 2014, 05:24:01 pm
Mike,
Im traveling so a quick reply.  It looks like you have a typo getting the gc_jsonEvents variable.

more info -- specifically, it's gc_jsonEvents not gc_jasonEvents.  Easy to do - I did it several times ......

Ignore i.e. do not use the previous incorrectly spelled  placeholder gc_jasonEvents.  This will hang around until the plugin is deleted and then re installed (easiest to do when the marketplace version comes out)

Yes you did.  :)   I got  "gc_jasonEvents" from the variable name on the advanced tab of the calendar device.
Title: Re: Google Calendar Switch
Post by: Stuart on June 20, 2014, 05:26:53 pm
Yes you did.  :)   I got  "gc_jasonEvents" from the variable name on the advanced tab of the calendar device.

Working now ?   gc_jsonEvents should appear lower down on the advanced tab.
Title: Re: Google Calendar Switch
Post by: mike Q on June 20, 2014, 05:51:02 pm
Sort of.

luup_log:0: ****** jsonEvents[{'eventEnd':1407729600,'eventStart':1402718400,'eventName':'VERA: NO SCHOOL'}] <0x2f3e3680>

The eventName appears to be "VERA: NO SCHOOL".

But eventname is NIL after doing eventname = eventList.eventName.
Title: Re: Google Calendar Switch
Post by: Stuart on June 20, 2014, 07:00:37 pm
Sort of.

luup_log:0: ****** jsonEvents[{'eventEnd':1407729600,'eventStart':1402718400,'eventName':'VERA: NO SCHOOL'}] <0x2f3e3680>

The eventName appears to be "VERA: NO SCHOOL".

But eventname is NIL after doing eventname = eventList.eventName.

I see the problem -the array is , of course, indexed but the [] did not show up with a simple cut and paste.  Parsing the array should look like this:
for i = 1,numberEvents do
       startevent = eventList[ i ].eventStart
--      startEvent = os.date("%Y-%m-%dT%H:%M:%S", startevent)
      startDate = os.date("%Y-%m-%d", startevent)
      startTime = os.date("%H:%M:%S", startevent)
       endevent = eventList[ i ].eventEnd
      endTime = os.date("%H:%M:%S", endevent)
       eventname = eventList[ i ].eventName
      event = "GCal_II: On " .. startDate .. " event " .. eventname .. " will start at " .. startTime .. " and end at " .. endTime
       luup.log(event)
  end

Title: Re: Google Calendar Switch
Post by: Stuart on June 20, 2014, 11:41:50 pm
Version 1.5.2  Fixed a bug that occurred when there were no events - I introduced it when adding the gc_jsonEvents code.

Also note that if you have debug turned on then you will see entries in the log file (these are just examples)  which should help with your own debugging
50      06/20/14 21:53:24.578   luup_log:45: GCal_II: There were 2  events retrieved
50      06/20/14 21:53:24.579   luup_log:45: GCal_II: Effective Event Name  TWO VACATION[5,-5]{70}
50      06/20/14 21:53:24.580   luup_log:45: GCal_II: Effective Event Name  VACATION ONE[5,-5]{70}
50      06/20/14 21:53:24.608   luup_log:45: GCal_II: On 2014-06-20 event VACATION ONE will start at 21:05:00 and end at 21:55:00
50      06/20/14 21:53:24.609   luup_log:45: GCal_II: On 2014-06-20 event TWO VACATION will start at 22:05:00 and end at 22:55:00

If you are parsing the gc_jsonEvents variable it's a good idea to test it before trying to iterate it.  e.g.
function getJson()
      local jsonEvents = luup.variable_get(GCAL_SID, "gc_jsonEvents",lul_device)

     if (jsonEvents == "[]") then
       return
     end


     local eventList =json.decode(jsonEvents)
     local numberEvents = table.getn(eventList)
     local startevent, startDate, startTime, endevent, eventname, event
     for i = 1,numberEvents do
          ..................
end
Title: Google Calendar II V1.5 release in Marketplace
Post by: Stuart on June 23, 2014, 04:49:56 pm
Version 1.5 should be available in the marketplace tomorrow ( 24th June).  This release fixes one or two small bugs and provides access to event information for other plugins or your own code (see post above as well as the documentation).

It would be best - but is not essential, to first remove any older versions of GCal_II.  This is simply to remove an unused and incorrectly spelled variable (i.e. gc_jasonEvents is not used)

I received feedback from the mios team about the issue where a trigger (using "an event has a specified name") with a notification would cause a reload loop.  They believe it is somewhere on their side ("a back-end problem") but said they will not be able to troubleshoot it for a while.  So for now you can either create a trigger and NOT have a notification or use PLEG (which in my testing works fine).

Here's the updated documentation.

For those who have been following the "bouncing ball"  attached is the I_GCAL_II.xml file that corresponds to the marketplace version.
Title: Re: Google Calendar Switch
Post by: sclodeca on June 25, 2014, 05:31:39 pm
Not sure if this is related to Version 1.5 but my plugin failed to activate on an event yesterday and when I clicked on any button, I received a "Device Not Ready" popup.

I deleted and re-installed the plugin from the marketplace and still receive the Device Not Ready error whenever I attempt to use the plugin - Set, Check, Arm, Bypass.

Any help debugging this is appreciated. 
Title: Re: Google Calendar Switch
Post by: Stuart on June 25, 2014, 06:01:06 pm
Not sure if this is related to Version 1.5 but my plugin failed to activate on an event yesterday and when I clicked on any button, I received a "Device Not Ready" popup.

I deleted and re-installed the plugin from the marketplace and still receive the Device Not Ready error whenever I attempt to use the plugin - Set, Check, Arm, Bypass.

Any help debugging this is appreciated.

I just uninstalled and then reinstalled from the marketplace and got the same problem.

I checked the files and what has happened is that the mios folks did not release the correct build of 1.5  into the marketplace.  I will get them to rectify that.

The affected file is two posts up,   I_GCal_II.xml.  Download this file to your machine and then go to
Apps-->Develop Apps --> Luup Files
Under "Upload Files" use Browse to select the file you downloaded and check the box below marked "Restart Luup after upload" and then "Go"

Once the reload is complete the plugin should greet you with "The Calendar link is not set .."





Title: Re: Google Calendar Switch
Post by: sclodeca on June 25, 2014, 06:30:13 pm
That did it. Thanks much!

;D
Title: Re: Google Calendar Switch
Post by: duiffie on June 26, 2014, 04:32:38 am
My GCal_II plugin just automatically updated from v1.3 to v1.7; it now keeps hanging on 'Checking for json.lua'. I had this same issue after upgrading to v1.5. Anything wrong with my setup?
Title: Re: Google Calendar Switch
Post by: duiffie on June 26, 2014, 05:03:18 am
These errors pass by in my LuaUPnP.log:

06   06/26/14 10:59:55.025   Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_jsonEvents was: [] now: [] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
01   06/26/14 10:59:55.027   LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:89: bad argument #2 to 'format' (integer expected, got number) <0x7c20>
01   06/26/14 10:59:55.029   LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:89: bad argument #2 to 'format' (integer expected, got number) <0x8021>
Title: Re: Google Calendar Switch
Post by: Stuart on June 26, 2014, 10:42:09 am
These errors pass by in my LuaUPnP.log:

06   06/26/14 10:59:55.025   Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_jsonEvents was: [] now: [] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
01   06/26/14 10:59:55.027   LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:89: bad argument #2 to 'format' (integer expected, got number) <0x7c20>
01   06/26/14 10:59:55.029   LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:89: bad argument #2 to 'format' (integer expected, got number) <0x8021>

Well the wonders of mios always deliver :-(    My vera, of course, is one of the ones that does not auto update .....

So I just removed my patched v1.5 and installed V1.7 (they are exactly the same ) -- works just fine ... able to see my calendar etc.  So obviously something strange ....

What version of mios are you on ?  Setup --> Firmware ... just in case :-)

Also, can you set gc_debug to true , save (will cause a reload) and get another log -- the GCal_II entries will help me to see where in the code this is happening - and I can then fix it.



Title: Re: Google Calendar Switch
Post by: duiffie on June 26, 2014, 10:59:11 am
Well the wonders of mios always deliver :-(    My vera, of course, is one of the ones that does not auto update .....

So I just removed my patched v1.5 and installed V1.7 (they are exactly the same ) -- works just fine ... able to see my calendar etc.  So obviously something strange ....

What version of mios are you on ?  Setup --> Firmware ... just in case :-)

Also, can you set gc_debug to true , save (will cause a reload) and get another log -- the GCal_II entries will help me to see where in the code this is happening - and I can then fix it.

I'm on 1.5.622.

Results  in the log after setting gc_debug to true and while grepping on GCal:

Code: [Select]
09 06/26/14 16:54:11.926 JobHandler_LuaUPnP::Run device 68 Test2 room 3 type urn:schemas-srs-com:device:GCal:1 id  parent 0/0x8e3360 upnp: 0 <0x400>
09 06/26/14 16:54:11.943 JobHandler_LuaUPnP::Run device 67 Test1 room 10 type urn:schemas-srs-com:device:GCal:1 id  parent 0/0x8e2e20 upnp: 0 <0x400>
06 06/26/14 16:54:18.828 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEvent was: Checking for json.lua now: Checking for json.lua #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x402>
06 06/26/14 16:54:18.829 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEventTime was:  now:  #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x402>
06 06/26/14 16:54:18.892 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEvent was: Checking for json.lua now: Checking for json.lua #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x402>
06 06/26/14 16:54:18.893 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEventTime was:  now:  #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x402>
06 06/26/14 16:54:20.012 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_lastCheck was: 2014-06-26T16:53:52 now: 2014-06-26T16:53:52 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
06 06/26/14 16:54:20.013 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_Keyword was: Test1 now: Test1 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
06 06/26/14 16:54:20.014 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_ignoreKeyword was: false now: false #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
06 06/26/14 16:54:20.015 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_exactKeyword was: true now: true #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
06 06/26/14 16:54:20.016 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_ignoreAllDayEvent was: false now: false #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
06 06/26/14 16:54:20.017 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_jsonEvents was: [] now: [] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
01 06/26/14 16:54:20.019 LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:89: bad argument #2 to 'format' (integer expected, got number) <0x7c20>
06 06/26/14 16:54:20.022 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_lastCheck was: 2014-06-26T16:53:52 now: 2014-06-26T16:53:52 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
06 06/26/14 16:54:20.023 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_Keyword was: Test2 now: Test2 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
06 06/26/14 16:54:20.024 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_ignoreKeyword was: false now: false #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
06 06/26/14 16:54:20.025 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_exactKeyword was: true now: true #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
06 06/26/14 16:54:20.026 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_ignoreAllDayEvent was: false now: false #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
06 06/26/14 16:54:20.028 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_jsonEvents was: [] now: [] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
01 06/26/14 16:54:20.030 LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:89: bad argument #2 to 'format' (integer expected, got number) <0x8021>
Title: Re: Google Calendar Switch
Post by: Stuart on June 26, 2014, 11:47:37 am

I'm on 1.5.622.

Results  in the log after setting gc_debug to true and while grepping on GCal:


Sorry - but can you grep for GCal_II   that will then catch the various debug messages.  I have an idea as to what might cause the issue, but it's strange that it does not happen on my and other vera's .....  looks like a number not being interpreted when used as a string parameter in a function call -- I may have to convert it.  But strange nonetheless ....
Title: Re: Google Calendar Switch
Post by: conchordian on June 26, 2014, 10:37:12 pm
I'm using Google Calendar II - V 1.7 and just in the last few days I'm getting the following error:

http error code: 400

I've re-entered my calendar link, and reloaded without any luck.

Any ideas?

Thanks.
Title: Re: Google Calendar Switch
Post by: Stuart on June 26, 2014, 11:51:56 pm
I'm using Google Calendar II - V 1.7 and just in the last few days I'm getting the following error:

http error code: 400

I've re-entered my calendar link, and reloaded without any luck.

Any ideas?

Thanks.

Can you please turn on debug  gc_debug set to true and then get an log file output for the time when the error occurs (I'm guessing if you press "check" then it will happen immediately after).

What timezone are you in ?  The reason I ask was that I made some small changes to accurately provide a 24hr 'look ahead' and may have introduced a syntax error into the url.  This could cause a 400 error.

EDIT:  I double checked and had put + instead of &2b in the url for + timezones -- so I'm pretty sure that will be the reason (assuming you are in a +ve timezone).
My bad - I tested without forcing a +ve time zone ( I'm -ve  :'(  )

Try the updated file attached - I was able to reproduce (by changing my vera timezone and calendar) and hopefully fix the problem.

BTW were you also in a timezone with a 1/2 hr offset ?
Title: Re: Google Calendar Switch
Post by: Stuart on June 27, 2014, 01:36:45 am

I'm on 1.5.622.

Results  in the log after setting gc_debug to true and while grepping on GCal:


Sorry - but can you grep for GCal_II   that will then catch the various debug messages.  I have an idea as to what might cause the issue, but it's strange that it does not happen on my and other vera's .....  looks like a number not being interpreted when used as a string parameter in a function call -- I may have to convert it.  But strange nonetheless ....

Can you try the updated file above (bottom of prior page) ?  I suspect the error you were getting was timezone related too .....  Are you in a timezone with a 1/2 hr offset ?
Title: Re: Google Calendar Switch
Post by: duiffie on June 27, 2014, 09:40:11 am
Sorry - but can you grep for GCal_II   that will then catch the various debug messages.  I have an idea as to what might cause the issue, but it's strange that it does not happen on my and other vera's .....  looks like a number not being interpreted when used as a string parameter in a function call -- I may have to convert it.  But strange nonetheless ....

Can you try the updated file above (bottom of prior page) ?  I suspect the error you were getting was timezone related too .....  Are you in a timezone with a 1/2 hr offset ?
[/quote]

While grepping on GCal_II and having debug set to true, the only lines catched are (I have 2 GCal_II devices):

Code: [Select]
50 06/27/14 15:33:09.022 luup_log:68: GCal_II: Timezone is 2 hrs and 0.35 min <0x8021>
50 06/27/14 15:33:09.033 luup_log:67: GCal_II: Timezone is 2 hrs and 0.35 min <0x7c20>

I'm located in the Netherlands/Amsterdam (UTC+1 plus currently DST+1, so the current offset is UTC+2). Uploading the latest I_GCal_II.xml didn't help either,  same result as before.
Title: Re: Google Calendar Switch
Post by: Stuart on June 27, 2014, 09:56:50 am

I'm located in the Netherlands/Amsterdam (UTC+1 plus currently DST+1, so the current offset is UTC+2). Uploading the latest I_GCal_II.xml didn't help either,  same result as before.

So the timezone is showing up incorrectly -- that's a clue -- I will try to reproduce based on Amsterdam. Probably later today though.

Out of curiosity -- why two plugins ?   I'd like to understand your use case.

Title: Re: Google Calendar Switch
Post by: Stuart on June 28, 2014, 12:37:32 am

I'm located in the Netherlands/Amsterdam (UTC+1 plus currently DST+1, so the current offset is UTC+2). Uploading the latest I_GCal_II.xml didn't help either,  same result as before.

So the timezone is showing up incorrectly -- that's a clue -- I will try to reproduce based on Amsterdam. Probably later today though.

Out of curiosity -- why two plugins ?   I'd like to understand your use case.

I tested with my vera and the calendar set to Amsterdam timezone.  Everything worked and the timezone showed correctly as 2hr 0 min.  So it's strange that there is a difference on your vera (especially as the difference shows as 0.35 min).   My original intention was to look for why the plugin would not start on your vera  - but I could not definitively find a problem (as it works on mine) .   I did find one suspicious error but ......  without being able to cause a failure, I cannot be sure.

Along the way I noticed a couple of possible edge conditions and fixed those - although none would have caused the error you reported.  I also tested with timezones for Amsterdam, Adelaide Australia and Mountain Time USA.  I added a few more debug messages that may help narrow the location of the issue.

Can you try with the attached version and just one plugin and grep for gc_ (will get us more log info) - I'd like to try and eliminate any possible interactions because of the two instances.

Thanks for your patience.

EDIT: I removed the attachments to several recent post so folks don't accidentally use them.
Title: Re: Google Calendar Switch
Post by: conchordian on June 28, 2014, 01:34:21 am
Can you try with the attached version and just one plugin and grep for gc_ (will get us more log info) - I'd like to try and eliminate any possible interactions because of the two instances.

Thanks for your patience.

That seems to fix it for me, thanks, and yes I am in a positive timezone: +10
Title: Re: Google Calendar Switch
Post by: bubaleta on June 28, 2014, 12:31:48 pm
This file also fixed my http 400 error.
I live in Madrid, Spain.

Thanks a lot
Title: Re: Google Calendar Switch
Post by: duiffie on June 29, 2014, 03:54:18 pm

I'm located in the Netherlands/Amsterdam (UTC+1 plus currently DST+1, so the current offset is UTC+2). Uploading the latest I_GCal_II.xml didn't help either,  same result as before.

So the timezone is showing up incorrectly -- that's a clue -- I will try to reproduce based on Amsterdam. Probably later today though.

Out of curiosity -- why two plugins ?   I'd like to understand your use case.

Two plugins because:

- I have a schedule for my housekeeper once every two weeks which disarms my alarm
- I have a wakeup light (dimmer) installed which runs every workday.

so these have to be seperate devices...
Title: Re: Google Calendar Switch
Post by: duiffie on June 29, 2014, 03:59:10 pm

I'm located in the Netherlands/Amsterdam (UTC+1 plus currently DST+1, so the current offset is UTC+2). Uploading the latest I_GCal_II.xml didn't help either,  same result as before.

So the timezone is showing up incorrectly -- that's a clue -- I will try to reproduce based on Amsterdam. Probably later today though.

Out of curiosity -- why two plugins ?   I'd like to understand your use case.

I tested with my vera and the calendar set to Amsterdam timezone.  Everything worked and the timezone showed correctly as 2hr 0 min.  So it's strange that there is a difference on your vera (especially as the difference shows as 0.35 min).   My original intention was to look for why the plugin would not start on your vera  - but I could not definitively find a problem (as it works on mine) .   I did find one suspicious error but ......  without being able to cause a failure, I cannot be sure.

Along the way I noticed a couple of possible edge conditions and fixed those - although none would have caused the error you reported.  I also tested with timezones for Amsterdam, Adelaide Australia and Mountain Time USA.  I added a few more debug messages that may help narrow the location of the issue.

Can you try with the attached version and just one plugin and grep for gc_ (will get us more log info) - I'd like to try and eliminate any possible interactions because of the two instances.

Thanks for your patience.

EDIT: I removed the attachments to several recent post so folks don't accidentally use them.

Output:
Code: [Select]
06 06/29/14 21:56:15.308 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEvent was: Checking for json.lua now: Checking for json.lua #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x402>
06 06/29/14 21:56:15.310 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEventTime was:  now:  #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x402>
06 06/29/14 21:56:15.382 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEvent was: Checking for json.lua now: Checking for json.lua #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x402>
06 06/29/14 21:56:15.383 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_NextEventTime was:  now:  #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x402>
06 06/29/14 21:56:17.011 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_lastCheck was: 2014-06-29T21:50:24 now: 2014-06-29T21:56:48 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x7c20>
06 06/29/14 21:56:17.013 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_Keyword was: WakeUpLight now: WakeUpLight #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
06 06/29/14 21:56:17.014 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_ignoreKeyword was: false now: false #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
06 06/29/14 21:56:17.016 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_exactKeyword was: true now: true #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
06 06/29/14 21:56:17.017 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_ignoreAllDayEvent was: false now: false #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
06 06/29/14 21:56:17.018 Device_Variable::m_szValue_set device: 67 service: urn:srs-com:serviceId:GCal2 variable: gc_jsonEvents was: [] now: [] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x7c20>
50 06/29/14 21:56:17.019 luup_log:67: GCAL_II:(gc_) timezone is 1 hrs and 59.45 min <0x7c20>
06 06/29/14 21:56:17.023 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_lastCheck was: 2014-06-29T21:50:24 now: 2014-06-29T21:56:48 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x8021>
06 06/29/14 21:56:17.025 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_Keyword was: Housekeeper now: Housekeeper #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
06 06/29/14 21:56:17.026 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_ignoreKeyword was: false now: false #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
06 06/29/14 21:56:17.027 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_exactKeyword was: true now: true #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
06 06/29/14 21:56:17.028 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_ignoreAllDayEvent was: false now: false #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
06 06/29/14 21:56:17.029 Device_Variable::m_szValue_set device: 68 service: urn:srs-com:serviceId:GCal2 variable: gc_jsonEvents was: [] now: [] #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x8021>
50 06/29/14 21:56:17.030 luup_log:68: GCAL_II:(gc_) timezone is 1 hrs and 59.45 min <0x8021>
Title: Re: Google Calendar Switch
Post by: Stuart on June 30, 2014, 12:34:16 am
@duiffie --

I momentarily  reproduce the error on my machine with 2 instances of the plugin.  One of the plugins 'stalled' at "Checking for json.lua"    Is this correct ?

I then pressed reload and the problem corrected itself.   I suspect a race condition at the os level when checking for the json.lua file.  This could take some time to identify the cause ...... you could try rebooting the vera .....

I have added some additional debug messages to try and narrow the problem but they will only show up during reboot (as opposed to reload)

Please try this version and send the error log (starting immediately after a reboot) until and including when the problem occurs.

Title: Re: Google Calendar Switch
Post by: Stuart on June 30, 2014, 02:04:48 pm
@duiffie --

I momentarily  reproduce the error on my machine with 2 instances of the plugin.  One of the plugins 'stalled' at "Checking for json.lua"    Is this correct ?

I then pressed reload and the problem corrected itself.   I suspect a race condition at the os level when checking for the json.lua file.  This could take some time to identify the cause ...... you could try rebooting the vera .....

I have added some additional debug messages to try and narrow the problem but they will only show up during reboot (as opposed to reload)

Please try this version and send the error log (starting immediately after a reboot) until and including when the problem occurs.

Better still - this version has better debugging.   I cannot get it to break my vera (with 2 plugin instances) but maybe you will have better luck :-(
I have tried it both with and without the json.lua files ... and with both plugins on the same calendar and with two different calendars at the same time ....

When you upload, do not check "Restart luup after reload" but instead Setup --> Net & Wi-Fi --> reboot.
Title: Re: Google Calendar Switch
Post by: duiffie on June 30, 2014, 04:01:49 pm
@duiffie --

I momentarily  reproduce the error on my machine with 2 instances of the plugin.  One of the plugins 'stalled' at "Checking for json.lua"    Is this correct ?

I then pressed reload and the problem corrected itself.   I suspect a race condition at the os level when checking for the json.lua file.  This could take some time to identify the cause ...... you could try rebooting the vera .....

I have added some additional debug messages to try and narrow the problem but they will only show up during reboot (as opposed to reload)

Please try this version and send the error log (starting immediately after a reboot) until and including when the problem occurs.

Better still - this version has better debugging.   I cannot get it to break my vera (with 2 plugin instances) but maybe you will have better luck :-(
I have tried it both with and without the json.lua files ... and with both plugins on the same calendar and with two different calendars at the same time ....

When you upload, do not check "Restart luup after reload" but instead Setup --> Net & Wi-Fi --> reboot.

Done, I've sent you a PM
Title: Re: Google Calendar Switch
Post by: Stuart on June 30, 2014, 11:48:36 pm
@duiffie --

This does not seem to be anything to do with json.lua.  The logs show that it is recognized as being there.  The message stays visible because the plugin does not get to the next stage.  The error seems to be this:

01   06/30/14 21:41:50.023   LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:113: bad argument #2 to 'format' (integer expected, got number) <0x7c20>

I've taken out the code immediately following the last successful debug message and coded it a different way.  The old code looked like this:

timezone = "&amp;2b" .. string.format("%02d:%02d",timezone,timezonemin)

for some reason, on your vera, timezonemin is 59.9333 but on mine (set for Amsterdam and other, even hour timezones) it's 00  so that could be the "integer expected, got number" issue.

Try this and let me know. V 1.8.2
Title: Re: Google Calendar Switch
Post by: duiffie on July 01, 2014, 01:15:42 am
@duiffie --

This does not seem to be anything to do with json.lua.  The logs show that it is recognized as being there.  The message stays visible because the plugin does not get to the next stage.  The error seems to be this:

01   06/30/14 21:41:50.023   LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:113: bad argument #2 to 'format' (integer expected, got number) <0x7c20>

I've taken out the code immediately following the last successful debug message and coded it a different way.  The old code looked like this:

timezone = "&amp;2b" .. string.format("%02d:%02d",timezone,timezonemin)

for some reason, on your vera, timezonemin is 59.9333 but on mine (set for Amsterdam and other, even hour timezones) it's 00  so that could be the "integer expected, got number" issue.

Try this and let me know. V 1.8.2

Great, that seems to fix it!

Could the timezonemin difference have something to do with my vera using ntp as a timesource instead of the builtin rdate?
Title: Re: Google Calendar Switch
Post by: Stuart on July 01, 2014, 10:13:12 am

Great, that seems to fix it!

Could the timezonemin difference have something to do with my vera using ntp as a timesource instead of the builtin rdate?

I don't think different time references would be it.  The timezone offset is basically calculated by asking mios what time is it now (in local time) and what time is it now(in utc) and doing the subtraction. So the offset being reported should just be the equivalent of an indirect lookup in the timesone table.   i.e the same table  that gets used when you set the timezone for your vera.  All i do is then break it into hours and minutes

I think there is a rounding difference -- but I'd expect all vera to behave the same.  Mine is a vera lite - so maybe there is a slight difference among the vera models (but again - I'd expect at the same release level for them to behave the same).  There is always the possibility of a difference in hardwdare ......

Anyway - the main change I made as a result of this, and as a precaution, was forces the minutes offset to the nearest integer ....   


 
Title: Re: Google Calendar Switch
Post by: baxy_AU on July 07, 2014, 05:10:24 am
I have just installed the plugin (v1.7) and am also seeing http error code 400 has the fix been submitted to the app store for this?
Title: Re: Google Calendar Switch
Post by: Stuart on July 07, 2014, 10:23:04 pm
I have just installed the plugin (v1.7) and am also seeing http error code 400 has the fix been submitted to the app store for this?

The fix has not been submitted to the apps store - so please use  the version of I_GCal_II.xml about two posts above.  I am doing some general tidy up and will post a version 1.8 soon.
Title: Re: Google Calendar Switch
Post by: Stuart on July 16, 2014, 11:16:29 am
Updated Version

Attached is the latest version which incorporates a couple of upgrades.  I will release this to the marketplace in a few days - but wanted to make sure there were no residual bugs (hence this beta).  I've tested it pretty heavily and also recently started to use ZeroBrane for Vera for development and testing.  ZB for Vera is highly recommended for anyone doing plugin work (or even just luup scenes) as it allows you to  interactively test on the vera device - and sometimes what works on one Lua interpreter does not work as you would hope in the vera environment :-(.  ZB for Vera really helps when that happens

This will probably be the last functional upgrade for a while.  Google will be deprecating the api version that is used to access the calendar and it will not be available come November.   So I have to come to grips with the new authentication scheme on google's V3 api.  This is non-trivial stuff .....

The enhancement to this version are basically two:
(1) gc-debug is no longer true / false but a number defaults to 1
0 = no debug messages
1 = minimal debug, basically checking calendar, device tripped, next check time
2= more detailed operating information
3 = unusual error conditions, probably only used when troubleshooting

(2) a new variable gc_retrip default to true and it's companion variable gc_TrippedID (just used for internal purposes)
This is used for back to back events with the same name e.g. repeating all day events i.e. any events with the same name where the end time of the previous event is the same as the start time of the next (same name) event.
if gc_retrip is true, then the plugin will treat the events as separate i.e. finish the first and trigger on the second.  In this way you can have the same trigger repeated using the calendar.  For example, if they were all day events - there would be a trigger each day at midnight.
if gc_retrip is false then the plugin will treat such events as one continuous event i.e. triggering on the start of the first one and finishing at the end of the last one.  For example, three all day events in a row with the same name would trigger at the start of day one and finish at the end of day three.

Hope someone finds this useful :-)

This version will show in the logs a V1.8.4
Title: Re: Google Calendar Switch
Post by: duiffie on July 16, 2014, 02:33:23 pm
Updated Version

Attached is the latest version which incorporates a couple of upgrades.  I will release this to the marketplace in a few days - but wanted to make sure there were no residual bugs (hence this beta).  I've tested it pretty heavily and also recently started to use ZeroBrane for Vera for development and testing.  ZB for Vera is highly recommended for anyone doing plugin work (or even just luup scenes) as it allows you to  interactively test on the vera device - and sometimes what works on one Lua interpreter does not work as you would hope in the vera environment :-(.  ZB for Vera really helps when that happens

This will probably be the last functional upgrade for a while.  Google will be deprecating the api version that is used to access the calendar and it will not be available come November.   So I have to come to grips with the new authentication scheme on google's V3 api.  This is non-trivial stuff .....

The enhancement to this version are basically two:
(1) gc-debug is no longer true / false but a number defaults to 1
0 = no debug messages
1 = minimal debug, basically checking calendar, device tripped, next check time
2= more detailed operating information
3 = unusual error conditions, probably only used when troubleshooting

(2) a new variable gc_retrip default to true and it's companion variable gc_TrippedID (just used for internal purposes)
This is used for back to back events with the same name e.g. repeating all day events i.e. any events with the same name where the end time of the previous event is the same as the start time of the next (same name) event.
if gc_retrip is true, then the plugin will treat the events as separate i.e. finish the first and trigger on the second.  In this way you can have the same trigger repeated using the calendar.  For example, if they were all day events - there would be a trigger each day at midnight.
if gc_retrip is false then the plugin will treat such events as one continuous event i.e. triggering on the start of the first one and finishing at the end of the last one.  For example, three all day events in a row with the same name would trigger at the start of day one and finish at the end of day three.

Hope someone finds this useful :-)

This version will show in the logs a V1.8.4

This version again hangs on 'Checking for json.lua'. Does this version contain the previous fix for that?
Title: Re: Google Calendar Switch
Post by: Stuart on July 16, 2014, 04:25:57 pm
@Duiffie
Could you please change gc_debug to 3
And send me the log? greg on gc_
It does have the changes and worked fine on my machine with multiple tests.  The additional debug should tell us pretty quickly what's happening.
Title: Re: Google Calendar Switch
Post by: duiffie on July 17, 2014, 01:58:46 am
@Duiffie
Could you please change gc_debug to 3
And send me the log? greg on gc_
It does have the changes and worked fine on my machine with multiple tests.  The additional debug should tell us pretty quickly what's happening.

That did the trick... gc-debug was still set to false, it did not change to 1 after uploading the new xml. After changing it manually to 3 on your request (per device), all started to work. The error I got while the value was set to false was:

Code: [Select]
LuaInterface::CallFunction_Timer-5 function GCalMain failed [string "..."]:543: attempt to compare nil with number
Title: Re: Google Calendar Switch
Post by: lammy on July 20, 2014, 11:31:52 am
can someone tell me how to upload the file to my vera lite?
sorry but im a newbie at this.
Title: Re: Google Calendar Switch
Post by: Stuart on July 20, 2014, 02:16:33 pm
can someone tell me how to upload the file to my vera lite?
sorry but im a newbie at this.

Apps--> Develop Apps --> Luup Files --> Browse
Select the file you want to upload (in this case I_GCAL_II.xml)
Check the box "Restart Luup after upload"
Press "Go"

I'll be posting the latest version (1.9.0) to the marketplace tomorrow if you want to do it that way.  Essentially the same as the post above but made the default setting more robust (i.e. overwrite incompatible defaults from prior plugin versions)

In the meantime - here it is V1.9.0
Title: Re: Google Calendar Switch
Post by: CudaNet on July 30, 2014, 02:36:51 pm
I seem to be having some problems getting a consistent trigger event (Plugin V1.9 from Apps/Install Apps). My use case is simple, I'm basically entering a calendar event in Calendar, Event = Key{ParmA; ParmB}.
In Vera, I have the following configured for the trigger :

[1] Type of event: A Calendar Event is Active.
[2] Status?: Device is Active
[3] [For testing purposes only] Send me a notification when the event occurs.

On the plug-in, the GCal is in an armed state (green). Now I'm watching the plug-in and it knows the event is going to occur (timestamp and event appear perfectly). As soon as the time is reached, I see the device icon change states (red), I receive an email notification but my LUUP code doesn't execute. On a trigger, I have LUUP evaluating the following containers:

gc_TrippedEvent
gc_Value

When I peek at Advanced, both of these fields appear to be empty until I restart LUUP,  then voila, my LUUP code executes and I now see values within those fields and they remain (I assume until the next event).  Any thoughts or am I just using this wrong ?

Title: Re: Google Calendar Switch
Post by: Stuart on July 30, 2014, 03:11:26 pm
I seem to be having some problems getting a consistent trigger event (Plugin V1.9 from Apps/Install Apps). My use case is simple, I'm basically entering a calendar event in Calendar, Event = Key{ParmA; ParmB}.
In Vera, I have the following configured for the trigger :

[1] Type of event: A Calendar Event is Active.
[2] Status?: Device is Active
[3] [For testing purposes only] Send me a notification when the event occurs.

On the plug-in, the GCal is in an armed state (green). Now I'm watching the plug-in and it knows the event is going to occur (timestamp and event appear perfectly). As soon as the time is reached, I see the device icon change states (red), I receive an email notification but my LUUP code doesn't execute. On a trigger, I have LUUP evaluating the following containers:

gc_TrippedEvent
gc_Value

When I peek at Advanced, both of these fields appear to be empty until I restart LUUP,  then voila, my LUUP code executes and I now see values within those fields and they remain (I assume until the next event).  Any thoughts or am I just using this wrong ?
I  don't think it's the plugin from what you describe ...

Some ideas to try: (also gc_debug = 3 will give us just about everything that is going on in the plugin - if you grep the log file for gc_)

(1) I have had issues with event notification that the MCV folks have not had time to look into (seems they are all working on UI7).  What happens if you remove the notification ?  Where have you set the notification ? - on the plugin, on your scene, in your LUUP code ?
(2)  Rather than restart LUUP - try refreshing the browser (F5) then looking at the advanced tab - that should show what the actual values are. - but I don't expect it to change any behavior
(3) In the code gc_Vale is set one line before the device Trigger is set and gc_ TrippedEvent, one line after (no reason) - but it's hard to imagine a race condition existing by the time it gets to your scene

The log file will tell  if the plugin is a suspect ....
Title: Re: Google Calendar Switch
Post by: CudaNet on July 30, 2014, 03:26:50 pm
Thanks Stuart,

[1] The notification is just the standard email notification that you check mark on the Scenes>'Name'>Triggers>Edit>Optional.
I only use the notification as a sanity check to verify that at least the scene>trigger is firing.

[2] Will try to refresh rather than restart LUUP and report back.
[3] Agreed but anything is possible.

Don't have the ability to eval the logs from where I'm at.. Can do later tonight if this (or me) can't be remedied.



I seem to be having some problems getting a consistent trigger event (Plugin V1.9 from Apps/Install Apps). My use case is simple, I'm basically entering a calendar event in Calendar, Event = Key{ParmA; ParmB}.
In Vera, I have the following configured for the trigger :

[1] Type of event: A Calendar Event is Active.
[2] Status?: Device is Active
[3] [For testing purposes only] Send me a notification when the event occurs.

On the plug-in, the GCal is in an armed state (green). Now I'm watching the plug-in and it knows the event is going to occur (timestamp and event appear perfectly). As soon as the time is reached, I see the device icon change states (red), I receive an email notification but my LUUP code doesn't execute. On a trigger, I have LUUP evaluating the following containers:

gc_TrippedEvent
gc_Value

When I peek at Advanced, both of these fields appear to be empty until I restart LUUP,  then voila, my LUUP code executes and I now see values within those fields and they remain (I assume until the next event).  Any thoughts or am I just using this wrong ?
I  don't think it's the plugin from what you describe ...

Some ideas to try: (also gc_debug = 3 will give us just about everything that is going on in the plugin - if you grep the log file for gc_)

(1) I have had issues with event notification that the MCV folks have not had time to look into (seems they are all working on UI7).  What happens if you remove the notification ?  Where have you set the notification ? - on the plugin, on your scene, in your LUUP code ?
(2)  Rather than restart LUUP - try refreshing the browser (F5) then looking at the advanced tab - that should show what the actual values are. - but I don't expect it to change any behavior
(3) In the code gc_Vale is set one line before the device Trigger is set and gc_ TrippedEvent, one line after (no reason) - but it's hard to imagine a race condition existing by the time it gets to your scene

The log file will tell  if the plugin is a suspect ....
Title: Re: Google Calendar Switch
Post by: Stuart on July 30, 2014, 03:44:59 pm
Don't have the ability to eval the logs from where I'm at.. Can do later tonight if this (or me) can't be remedied.

Take a look at the info viewer plugin - terrific!.  I actually use it more than directly connecting to the OS .....   It allows remote log viewing and log filtering (among other things).  You can get it here:

http://forum.micasaverde.com/index.php/topic,13477.0.html
Title: Re: Google Calendar Switch
Post by: CudaNet on July 30, 2014, 03:52:06 pm
Very nice ! I'll install that and see what's occuring. Did the refresh and sure enough, the data is there so perhaps there is a timing issue (one which is alleviated with a restart).... I figured if this was an issue that others surely would have reported it. Hmm... Think I'll reboot this thing (ya' never know) and start installing the log tool...

Don't have the ability to eval the logs from where I'm at.. Can do later tonight if this (or me) can't be remedied.

Take a look at the info viewer plugin - terrific!.  I actually use it more than directly connecting to the OS .....   It allows remote log viewing and log filtering (among other things).  You can get it here:

http://forum.micasaverde.com/index.php/topic,13477.0.html
Title: Re: Google Calendar Switch
Post by: Stuart on July 30, 2014, 04:25:47 pm
Very nice ! I'll install that and see what's occuring. Did the refresh and sure enough, the data is there so perhaps there is a timing issue (one which is alleviated with a restart).... I figured if this was an issue that others surely would have reported it. Hmm... Think I'll reboot this thing (ya' never know) and start installing the log tool...

Don't have the ability to eval the logs from where I'm at.. Can do later tonight if this (or me) can't be remedied.

Take a look at the info viewer plugin - terrific!.  I actually use it more than directly connecting to the OS .....   It allows remote log viewing and log filtering (among other things).  You can get it here:

http://forum.micasaverde.com/index.php/topic,13477.0.html

You are also welcome to try this.  It separates I_GCall_II.xml into two files (avoids me having to make some XLM changes when testing on PC vs Vera) but is otherwise identical to the version you have.   I just shifted the assignment for the plugin Tripped / Not Tripped to after the other variables - you never know ......  I'd be very surprised .....

Just download both files and reload.

Would be nice to get a log from the current version first though - just in case there is a difference in behavior .......

Title: Re: Google Calendar Switch
Post by: lammy on July 30, 2014, 06:00:12 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
Title: Re: Google Calendar Switch
Post by: CudaNet on July 30, 2014, 06:02:57 pm
Sorry, work issue came up so I deviated... I'll get logs before loading these files (just downloaded the new Info Viewer plugin) and thanks for the quick responses.

Very nice ! I'll install that and see what's occuring. Did the refresh and sure enough, the data is there so perhaps there is a timing issue (one which is alleviated with a restart).... I figured if this was an issue that others surely would have reported it. Hmm... Think I'll reboot this thing (ya' never know) and start installing the log tool...

Don't have the ability to eval the logs from where I'm at.. Can do later tonight if this (or me) can't be remedied.

Take a look at the info viewer plugin - terrific!.  I actually use it more than directly connecting to the OS .....   It allows remote log viewing and log filtering (among other things).  You can get it here:

http://forum.micasaverde.com/index.php/topic,13477.0.html

You are also welcome to try this.  It separates I_GCall_II.xml into two files (avoids me having to make some XLM changes when testing on PC vs Vera) but is otherwise identical to the version you have.   I just shifted the assignment for the plugin Tripped / Not Tripped to after the other variables - you never know ......  I'd be very surprised .....

Just download both files and reload.

Would be nice to get a log from the current version first though - just in case there is a difference in behavior .......
Title: Re: Google Calendar Switch
Post by: CudaNet 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....
Title: Re: Google Calendar Switch
Post by: Stuart 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

Title: Re: Google Calendar Switch
Post by: CudaNet 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>

Title: Re: Google Calendar Switch
Post by: Stuart 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
Title: Re: Google Calendar Switch
Post by: CudaNet 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
Title: Re: Google Calendar Switch
Post by: Stuart 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 ......
Title: Re: Google Calendar Switch
Post by: ft9 on August 12, 2014, 05:53:33 pm
Thank you so much for your work Stuart!
It has been working great!
Title: Re: Google Calendar Switch
Post by: korttoma on August 12, 2014, 11:47:23 pm
Good work Stuart!  ;)
Title: Re: Google Calendar Switch
Post by: CudaNet 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.
Title: Re: Google Calendar Switch
Post by: guest141575 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.
Title: Re: Google Calendar Switch
Post by: CudaNet 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.
Title: Re: Google Calendar Switch
Post by: Stuart 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 .....


Title: Re: Google Calendar Switch
Post by: Stuart 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)
Title: Re: Google Calendar Switch
Post by: CudaNet 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)
Title: Re: Google Calendar Switch
Post by: CudaNet 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)
Title: Re: Google Calendar Switch
Post by: CudaNet on August 19, 2014, 02:10:30 pm
'gc_triggerNoKeyword' set to 'true' works perfectly. All is well, however the JS didn't take.

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)
Title: Re: Google Calendar Switch
Post by: Stuart on August 19, 2014, 02:36:39 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


Sorry Guys -- too much haste on my part --

Corrected version attached

Title: Re: Google Calendar Switch
Post by: Stuart on August 19, 2014, 02:44:37 pm
@CudaNet
'gc_triggerNoKeyword' set to 'true' works perfectly. All is well, however the JS didn't take

Can you retry again ?  You will at least have to F5 refresh the browser for it to show up in the browser.

If still not showing up - could you check to make sure that the js  file in your vera now reads (on line 4)

var src = get_device_state(device, "urn:srs-com:serviceId:GCal2", "gc_Source", 0);
Title: Re: Google Calendar Switch
Post by: CudaNet on August 19, 2014, 02:46:21 pm
No need to be sorry, I just appreciate you taking the time to make adjustments.. Will load and report back only if issues arise.

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


Sorry Guys -- too much haste on my part --

Corrected version attached
Title: Re: Google Calendar Switch
Post by: CudaNet on August 19, 2014, 03:14:04 pm
Odd, I DL'd the JS file again, re-loaded and voila - it took... Not sure what happened the first two times I tried. Perhaps Vera is getting super flaky on me these days. Case and point... My father came by my house this morning to pick up a USB cable and Vera greeted him like 8 times (infinite loop), had to reboot her on the spot...

@CudaNet
'gc_triggerNoKeyword' set to 'true' works perfectly. All is well, however the JS didn't take

Can you retry again ?  You will at least have to F5 refresh the browser for it to show up in the browser.

If still not showing up - could you check to make sure that the js  file in your vera now reads (on line 4)

var src = get_device_state(device, "urn:srs-com:serviceId:GCal2", "gc_Source", 0);
Title: Re: Google Calendar Switch
Post by: CudaNet on August 19, 2014, 03:22:36 pm
Stuart, just re-ran my tests.. From what I can tell, everything is working as intended. Thanks for making the changes available so quickly...
So what needs to happen in order for this plugin to have it's own board ? It certainly should considering your efforts moving forward for V3 support.

Just sayin !
Title: Re: Google Calendar Switch
Post by: Stuart on August 19, 2014, 06:03:35 pm
Stuart, just re-ran my tests.. From what I can tell, everything is working as intended. Thanks for making the changes available so quickly...
So what needs to happen in order for this plugin to have it's own board ? It certainly should considering your efforts moving forward for V3 support.

Just sayin !

No idea how to get a board allocated but  have forwarded to a moderator ....   who knows ......
Title: Re: Google Calendar Switch
Post by: Stuart on August 19, 2014, 06:13:51 pm
I posted an update for release with the two patches discussed above.
Title: Re: Google Calendar Switch
Post by: guest141575 on August 20, 2014, 12:44:50 pm
I posted an update for release with the two patches discussed above.

Thank You Stuart. The altered files work well.  :)
Title: Re: Google Calendar Switch
Post by: destinet on August 22, 2014, 10:25:11 am
Hi! I just install the plugin but missing some doc. I put me private xml link to my calendar. In the keyword i put test and in my google calendar i put a meeting a t 10am for test. In the plugin i see the even in the calendar tab but it didn't light up at 10am. If i click check it's stuck a checking....not sure what i'm doing wrong.
Title: Re: Google Calendar Switch
Post by: Stuart on August 22, 2014, 12:36:44 pm
Hi! I just install the plugin but missing some doc. I put me private xml link to my calendar. In the keyword i put test and in my google calendar i put a meeting a t 10am for test. In the plugin i see the even in the calendar tab but it didn't light up at 10am. If i click check it's stuck a checking....not sure what i'm doing wrong.

If it's stuck at 'Checking' it usually means that the calendar cannot be accessed properly.  Can you change gc_debug to 3 and get the output from the log file ?

If you are not familiar with getting to the log file - the easiest way (and the way I usually use) is the info viewer plugin.  It also allows remote log viewing and log filtering (among other things).  You can get it here:
http://forum.micasaverde.com/index.php/topic,13477.0.html

Either filter on 'GCal3' for the debug messages or 'gc_' to get both the debug messages and detail of each change in variable values.

See the documentation here http://forum.micasaverde.com/index.php/topic,7558.msg175074.html#msg175074 for an explanation of how to set up (it's on release behind but will not matter)

Also - GCal_II is being deprecated (as of today) because of changes on the Google end.  You may want to go straight to GCal3
here    http://forum.micasaverde.com/index.php/topic,26692.0.html
Title: Google Calendar II Deprecated
Post by: Stuart on August 22, 2014, 12:41:25 pm
As of today - Google Calendar II is deprecated

That means I will no longer be adding functionality to GCal_II or fixing bugs.
The reason is that the Google API's that are used by GCal_II go out of service in a couple of months (Nov 2014).
Instead - I would encourage you to switch over to GCal3 which is posted here

http://forum.micasaverde.com/index.php/topic,26692.0.html

GCal3 uses the new Google V3 API's and the new authentication scheme required by Google.

The first release of GCal3 has the same functionality as the last release of GCal_II.
Title: Re: Google Calendar Switch
Post by: destinet on August 22, 2014, 02:47:20 pm
Hi! I just install the plugin but missing some doc. I put me private xml link to my calendar. In the keyword i put test and in my google calendar i put a meeting a t 10am for test. In the plugin i see the even in the calendar tab but it didn't light up at 10am. If i click check it's stuck a checking....not sure what i'm doing wrong.

If it's stuck at 'Checking' it usually means that the calendar cannot be accessed properly.  Can you change gc_debug to 3 and get the output from the log file ?

If you are not familiar with getting to the log file - the easiest way (and the way I usually use) is the info viewer plugin.  It also allows remote log viewing and log filtering (among other things).  You can get it here:
http://forum.micasaverde.com/index.php/topic,13477.0.html

Either filter on 'GCal3' for the debug messages or 'gc_' to get both the debug messages and detail of each change in variable values.

See the documentation here http://forum.micasaverde.com/index.php/topic,7558.msg175074.html#msg175074 for an explanation of how to set up (it's on release behind but will not matter)

Also - GCal_II is being deprecated (as of today) because of changes on the Google end.  You may want to go straight to GCal3
here    http://forum.micasaverde.com/index.php/topic,26692.0.html

thanks, i will wait for the 26 when it reach the market.

Regards