We have moved at community.getvera.com

Author Topic: GCAL3 - General Discussion  (Read 192694 times)

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCAL3 - Google Calendar 3
« Reply #105 on: September 26, 2014, 05:27:08 pm »

More generically speaking I see a need to be able to determine if there are matching events found today or not regardless if they occured yet. (E.g. In my case, Is this calendar day a school day?)  Also it's useful to being able to tell if there are More events today" (E.g. In my case, are there any more lessons coming up today?) I'm not so good in explaining things Stuart, I apologize :D

EDIT: Item 1 corrected.
So currently the plugin provides variables that
1.  a list of events from the start of the local day until 'now' plus 24(ish) hours as a json encoded string.  This is to catch all day events etc
2.  a list of currently active events as a json encoded string
3.  a list of currently active events as a comma delimited string

The intent of (3) was that it could be used in PLEG using a partial string match (upcoming capability in PLEG)

It would be fairly straightforward to  add a parameter that provided a comma delimited list of all events in the calendar for the current 'today' i.e. the local day  00:00 to 23:00.  I'd have to force an update of the calendar at 00:00 but that's doable

The normal update frequency is based on the start and end of each event in the calendar or every 3 hrs whichever is sooner.

The number of events remaining could be a number that gets updated with the normal updates and would be a count of events in the calendar  from 'now' until the end of the day.

The slightly trickier question would be any events seen in the calendar i.e. the equivalent of gc_Keyword being blank or events that take into account the settings for gc_keyword , gc_ignoreAllDayEvent and etc. 

What's your thoughts ?
« Last Edit: September 26, 2014, 06:36:25 pm by Stuart »

guest141575

  • Guest
Re: GCAL3 - Google Calendar 3
« Reply #106 on: September 27, 2014, 05:46:23 am »
It would be fairly straightforward to  add a parameter that provided a comma delimited list of all events in the calendar for the current 'today' i.e. the local day  00:00 to 23:00.  I'd have to force an update of the calendar at 00:00 but that's doable

If there was a GCAL option (gc_LimitToday) it would be more versatile... (About the update at midnight it can be done from PLEG calling GCalCheck, so it's not really neccesary)

I've managed to implement a solution that I believe works for my needs.

Two schedules, s0005AM and s0010AM
A device property pJsonEvents

3 PLEG conditions that I put first in my PLEG

Lessons$None      s0005AM
Lessons$Exists   s0010AM and pJsonEvents ne "[]"
cSchoolDay      Lessons eq "Exists"

(Lessons becomes a PLEG State variable)
I put an action on Lessons$None that forces a GCalCheck.

One question though.... if I set gc_Interval to 0, would that disable automatic GCalChecks?

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCAL3 - Google Calendar 3
« Reply #107 on: September 27, 2014, 11:25:46 am »
If there was a GCAL option (gc_LimitToday) it would be more versatile...

Not sure what you would want gc_LimitToday to represent - can you further explain?

(About the update at midnight it can be done from PLEG calling GCalCheck, so it's not really neccesary)

I was looking at the code last night and put it in anyway :-)

I've managed to implement a solution that I believe works for my needs.
I think it probably works because there are no early morning events.   The way the code currently works is that it has a rolling window fixed at 00:00 of the current local day so while gc_jsonEvents might = "[]" - if it were to check at (say) 22:00 the window would be 'all of today and all of tomorrow".   I think it would be worthwhile to add another 'local day' variable so as to avoid ambiguity (and strange 'data sensitive' behavior)

One question though.... if I set gc_Interval to 0, would that disable automatic GCalChecks?

gc_Interval cannot be 'turned off' in the current code - there is a default minimum (cannot remember off the top of my head what it is).  In any case - it would have no effect on GCalCheck - so you are safe there.  If anything you would set gc_Interval to a very large number (of minutes) to 'turn it off' - it would still check but not very often - but there may be unintended side effects if you are running your own 'refresh' scheme through triggering GCalChecks.

Let me take a look at some option ......  I think a proper 'eventstoday' indicator be it boolean, a count, a list makes sense as it removes ambiguity - and while I have no conceptual issue with using GCalChecks to force updates - it just seems that it's possibly offloading to something else, what ought to be self contained in the plugin - but maybe I'm chasing shadows .......

BRAVO - on getting it to work though !

guest141575

  • Guest
Re: GCAL3 - Google Calendar 3
« Reply #108 on: September 27, 2014, 11:50:17 am »
Not sure what you would want gc_LimitToday to represent - can you further explain?
Just a flag to prevent fetching calendar events not belonging to the present calendar day. :D

I was looking at the code last night and put it in anyway :-)
Great :D

I think it probably works because there are no early morning events.   The way the code currently works is that it has a rolling window fixed at 00:00 of the current local day so while gc_jsonEvents might = "[]" - if it were to check at (say) 22:00 the window would be 'all of today and all of tomorrow".   I think it would be worthwhile to add another 'local day' variable so as to avoid ambiguity (and strange 'data sensitive' behavior)

Yes it's true.

gc_Interval cannot be 'turned off' in the current code - there is a default minimum (cannot remember off the top of my head what it is).  In any case - it would have no effect on GCalCheck - so you are safe there.  If anything you would set gc_Interval to a very large number (of minutes) to 'turn it off' - it would still check but not very often - but there may be unintended side effects if you are running your own 'refresh' scheme through triggering GCalChecks.
Since I only need a single GCalCheck per day I tried to set it up to check every 24 hours but then gc_jsonEvents were pupulated with events scheduled 48 hours from now. :D I didn't want that so I set it back to check every 3 hours as being the default value. Being able to disable automatic GCalChecks would be a nice feature though, I think.

Let me take a look at some option ......  I think a proper 'eventstoday' indicator be it boolean, a count, a list makes sense as it removes ambiguity - and while I have no conceptual issue with using GCalChecks to force updates - it just seems that it's possibly offloading to something else, what ought to be self contained in the plugin - but maybe I'm chasing shadows .......

Thank You for all the work You put into this essential plugin Stuart! I wish I could do something for You in return.  ;D

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCAL3 - Google Calendar 3
« Reply #109 on: September 28, 2014, 10:04:34 am »

Thank You for all the work You put into this essential plugin Stuart! I wish I could do something for You in return.  ;D

Thanks for the complement.  You can help !   What does your Luup code look like for invoking GCalCheck ?    I'll put it in the documentation as a note for others.

guest141575

  • Guest
Re: GCAL3 - Google Calendar 3
« Reply #110 on: September 28, 2014, 10:46:39 am »
Thanks for the complement.  You can help !   What does your Luup code look like for invoking GCalCheck ?    I'll put it in the documentation as a note for others.

This will probably work:

Code: [Select]
local GCAL_SID = "urn:srs-com:serviceId:GCalIII"
local GCAL_DEV = 141    -- The GCAL device number
luup.call_action(GCAL_SID, "GCalCheck", "", GCAL_DEV)

It works on my system when testing.

(I'm not using LUUP toinvoke a GCalCheck. I simply defined an advanced PLEG action on my GCalIII device.)

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCAL3 - Google Calendar 3
« Reply #111 on: September 28, 2014, 06:52:43 pm »
Let me take a look at some option ......  I think a proper 'eventstoday' indicator be it boolean, a count, a list makes sense as it removes ambiguity - and while I have no conceptual issue with using GCalChecks to force updates - it just seems that it's possibly offloading to something else, what ought to be self contained in the plugin - but maybe I'm chasing shadows .......

@ Farang

I made some changes - please try them out and let me know.  They should make your PLEG logic a bit simpler .....

(1) The calendar now checks at midnight (actually a second past) for events, independently of the normal checks
(2) A new variable gc_EventsToday - that gives a count of the number of events that match your selection criteria for the current day.  This gets checked at each event during the day but unless you add / delete events during the day - it will remain constant.
(3) A new variable gc_EventsLeftToday - that gives a count of the remaining number of events for the current day that match your selection criteria.  This gets updated at each event during the day.  It will start out (at midnight) being the same as gc_EventsToday and count down to zero (i.e. after the last event that day).  I suspect this might be useful but have not thought through how ......  I'm sure someone will find a use :-)

EDIT: Attachment removed
« Last Edit: September 29, 2014, 10:54:48 am by Stuart »

guest141575

  • Guest
Re: GCAL3 - Google Calendar 3
« Reply #112 on: September 29, 2014, 03:49:31 am »
Thank You Stuart. I'm exited to use these newly implemented variables and they sure makes Your plugin even more easy to use.  :) :) :)

(1) The calendar now checks at midnight (actually a second past) for events, independently of the normal checks

That is great. I wonder though if it still will check at midnight if I've set the gc_StartDelta variable ...
(I'm currently set both gc_StartDelta and gc_Enddelta to -60 so I can use the calendar for reminders 1 hour in advance.)

(2) A new variable gc_EventsToday - that gives a count of the number of events that match your selection criteria for the current day.  This gets checked at each event during the day but unless you add / delete events during the day - it will remain constant.

Seems to work perfectly. Very nice :D

(3) A new variable gc_EventsLeftToday - that gives a count of the remaining number of events for the current day that match your selection criteria.  This gets updated at each event during the day.  It will start out (at midnight) being the same as gc_EventsToday and count down to zero (i.e. after the last event that day).  I suspect this might be useful but have not thought through how ......  I'm sure someone will find a use :-)

I'm sure I will use it in the future :D It would be interesting though to know how setting gc_Enddelta will affect the value of gc_EventsLeftToday

I noticed something today that I haven't noticed before. As I mentioned earlier, I've currently set both gc_StartDelta and gc_Enddelta to -60 in the GCal 3 plugin for my sons school schedule. First lesson is at 9:00 AM to 9:20 AM. In the UI of the plugin it says that the lesson is between 8:00 AM to 9:21 AM. The plugin doesn't seem to adjust for my negative gc_EndDelta value. I had a quick look in the jsonEvents and they were also faulty in the same manner. I'm also confused by the extra minute added to the end time.

I'm not sure how to express my gratitude enough for Your efforts and great work. I hope a "Thank You" will do until I get the chance to buy You a beer or something :D

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCAL3 - Google Calendar 3
« Reply #113 on: September 29, 2014, 10:57:18 am »

I noticed something today that I haven't noticed before. As I mentioned earlier, I've currently set both gc_StartDelta and gc_Enddelta to -60 in the GCal 3 plugin for my sons school schedule. First lesson is at 9:00 AM to 9:20 AM. In the UI of the plugin it says that the lesson is between 8:00 AM to 9:21 AM. The plugin doesn't seem to adjust for my negative gc_EndDelta value. I had a quick look in the jsonEvents and they were also faulty in the same manner. I'm also confused by the extra minute added to the end time.


A copy / paste error on my part when adding in the new variables - was over writing gc_EndDelta.

EDIT: Removed Attachment

Try this.

I'll explain the other questions / aspects later today ....  gtg

« Last Edit: September 29, 2014, 11:25:51 pm by Stuart »

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCAL3 - Google Calendar 3
« Reply #114 on: September 29, 2014, 02:05:08 pm »
That is great. I wonder though if it still will check at midnight if I've set the gc_StartDelta variable ...
(I'm currently set both gc_StartDelta and gc_Enddelta to -60 so I can use the calendar for reminders 1 hour in advance.)

gc_StartDelta and gc_Enddelta operate the same 'logical' way.   Negative values are back in time Positive are forward in time.  So setting both to -60 means that the start and end times are both 1 hr before the times for that event.  So a calendar event that you have set for 9:00 to 9:20 will actually be interpreted as 8:00 to 8:20.

In terms of the midnight check - there is no effect since the start delta and end delta are applied after the calendar retrieves the events to create an 'effective' start and end date.

Note that you can over-ride gc_StartDelta and gc_Enddelta but putting event specific start, end deltas into the event name in [] e.g. event [-60,60]  would create en effective start 1hr before and an effective end 1hr after the event times in the calendar.

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCAL3 - Google Calendar 3
« Reply #115 on: September 29, 2014, 11:36:30 pm »
I'm sure I will use it in the future :D It would be interesting though to know how setting gc_Enddelta will affect the value of gc_EventsLeftToday

Here's an updated file.  I tidied up a couple of comparisons  .....

Basically  the number of events today and the number remaining are based on the effective dates, i.e. taking into account any start end deltas.  If part of the event is in 'today' then it is counted.  Today meaning 00:00:00 to 23:59:59

EDIT: Removed attachment
« Last Edit: October 01, 2014, 12:01:28 am by Stuart »

guest141575

  • Guest
Re: GCAL3 - Google Calendar 3
« Reply #116 on: September 30, 2014, 12:07:37 am »
I'm sure I will use it in the future :D It would be interesting though to know how setting gc_Enddelta will affect the value of gc_EventsLeftToday

Here's an updated file.  I tidied up a couple of comparisons  .....

Basically  the number of events today and the number remaining are based on the effective dates, i.e. taking into account any start end deltas.  If part of the event is in 'today' then it is counted.  Today meaning 00:00:00 to 23:59:59

Thanks!

Installed it and trying it out. Seems to work very well. I'm already using the new variable gc_EventsToday  ;D

Code: [Select]
cSchoolDay No pEventsToday > 0
cSchoolDayEnded No cSchoolDay and pEventsLeftToday == 0

guest141575

  • Guest
Re: GCAL3 - Google Calendar 3
« Reply #117 on: September 30, 2014, 08:54:39 am »
Code: [Select]
cSchoolDay No pEventsToday > 0
cSchoolDayEnded No cSchoolDay and pEventsLeftToday == 0

It seems like gc_EventsLeftToday doesn't update when an event finishes. Even though all events had passed today, it was still on 1. After doing a GCalCheck gc_EventsLeftToday changed to 0.

Offline Stuart

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: GCAL3 - Google Calendar 3
« Reply #118 on: September 30, 2014, 11:26:07 am »
It seems like gc_EventsLeftToday doesn't update when an event finishes. Even though all events had passed today, it was still on 1. After doing a GCalCheck gc_EventsLeftToday changed to 0.

Were you looking at the advanced tab ?  If so it may not have refreshed (always use an F5 before looking).  Here's my output from a PLEG test.
I had an event that went from 9:05 to 9:10  For 'Left0' the event finished at 09:10 and the variable reflects that change (the previous change value was when I refreshed)

If you think it's still an issue (i.e. not the advanced tab)  - do you have a specific example I can try ?
« Last Edit: September 30, 2014, 01:00:41 pm by Stuart »

guest141575

  • Guest
Re: GCAL3 - Google Calendar 3
« Reply #119 on: September 30, 2014, 01:28:02 pm »
Were you looking at the advanced tab ?  If so it may not have refreshed (always use an F5 before looking).  Here's my output from a PLEG test.
I had an event that went from 9:05 to 9:10  For 'Left0' the event finished at 09:10 and the variable reflects that change (the previous change value was when I refreshed)

If you think it's still an issue (i.e. not the advanced tab)  - do you have a specific example I can try ?

Things didn't happen when I expected them to, so I made a status report in my PLEG. I'm currently running a test and I'll get back to you. Thanks.