GCAL3 - General Discussion

[quote=“lwinter, post:59, topic:182612”]

An event has specified name - this does not technically trigger the plugin - but the event is “active”
This differentiates between ‘triggering’ and being able to react to a keyword with “A Calendar Event is Active” but not triggering (from Vera’s perspective). Without this vera would trigger on every event (with no gc_Keyword)

So you can leave gc_Keyword blank and use “A Calendar Event is Active” to “Activate” based on event names you set in your scenes.

How are you setting your scenes ? Are the conditions set to be upper case ? All the keywords are changed to upper case within the plugin and the matching conditions therefore need to be in upper case as well.


I leave gc_Keyword, gc_ignoreKeyword = false then true and nothing happen : the scene doesn’t start.
The next Event is TEST. My device is active but the scene will not be triggered.
Trigger of the scene :
A calendar event is active
Status ? Module is active
script of the scene :

local valeur = luup.variable_get("urn:srs-com:serviceId:GCalIII","gc_TrippedEvent",191) my_prowl("Value ?", valeur, "", 0) end
but when I execute the scene manually, it returns on Prowl Value ? TEST[/quote]

Keywords are all forced to UPPER CASE in the plugin - so any comparison must be in UPPER CASE as well. Not shouting :slight_smile: just emphasizing …

Your example test value is in lower case :cry:

[quote=“Borat, post:60, topic:182612”]Hi Stuart

In your PLEG tests, are you using the device property (as per Tyfoons example) or the “Event has specified name” input method? I have been able to get it to work using the device property mechanism, but not using Event has specified name. Could be I am using that wrong, or expecting it to work in a way that it is not designed? Would be good if you could explain how that should behave in PLEG?

ps - @Tyfoon, I noticed you are using == in your conditions, which is a numerical comparison operator. I think you have to use eq - the string operator. Something to try if it still doesnt work for you.

Cheers[/quote]

Close but no cigar ;D – but a great catch (I had not looked at PLEG for a while)

use the eq operator in PLEG

This screen shot shows both approaches working TEST2 is “active” but the plugin is not “triggered”. So if you wanted to do something based on TEST2, you could use a condition requiring T2 to be true or alternatively c2 (as defined)

This was mentioned before but when you have more than 1 GCal3 Device it will reload LUUP many many times. I know it was stated that only one Device should be needed since you can specify many keywords. However i need 2 separate devices, one for my work schedule and one for my wifes. I set certain things when we are both away and certain things when both or one are home. I have everything working as i want just if i change a setting in the device it will reload luup for each GCal3 device it seems, sometimes more.

Please see the earlier posts. This has been solved - you need the version posted here. It will be a few days before I get it to the marketplace.
http://forum.micasaverde.com/index.php/topic,26692.msg190735.html#msg190735

Keywords are all forced to UPPER CASE in the plugin - so any comparison must be in UPPER CASE as well. Not shouting :) just emphasizing ....

Your example test value is in lower case :cry:

I do not have to be gifted ???
You mean “Nom de ce d?clencheur:” must be in upper case ? Others keywords are in upper case in my example.

[quote=“lwinter, post:65, topic:182612”]

Keywords are all forced to UPPER CASE in the plugin - so any comparison must be in UPPER CASE as well. Not shouting :slight_smile: just emphasizing …

Your example test value is in lower case :cry:

I do not have to be gifted ???
You mean “Nom de ce d?clencheur:” must be in upper case ? Others keywords are in upper case in my example.[/quote]

Pardon – Je lis pas francais

In your code the value of ‘valeur’ would be TEST
but I do not see you making the comparison for the string literal TEST
what is the function my_prowl doing ? Also “Value ?” looks a little strange

local valeur = luup.variable_get(“urn:srs-com:serviceId:GCalIII”,“gc_TrippedEvent”,191)
my_prowl(“Value ?”, valeur, “”, 0)
end

Wait - I see the problem … you are initiating your scene with “A Calendar event is active” - in which case you have to specify the keyword in the advanced tab in gc_Keyword.
That wording ought to be changed to something like “A Calendar event has satisfied a Keyword” …
The option to set gc_Keyword blank and the calendar being thought of as “Active” but not “Triggered” relates to the initiation possibility of “An event has a specified name”

I’ll make an appropriate change to try an avoid confusion in the future.

[quote=“Stuart, post:66, topic:182612”]Wait - I see the problem … you are initiating your scene with “A Calendar event is active” - in which case you have to specify the keyword in the advanced tab in gc_Keyword.
That wording ought to be changed to something like “A Calendar event has satisfied a Keyword” …
The option to set gc_Keyword blank and the calendar being thought of as “Active” but not “Triggered” relates to the initiation possibility of “An event has a specified name”

I’ll make an appropriate change to try an avoid confusion in the future.[/quote]

That’s right !! I specified a keyword (TEST in my example) in gc_Keyword and the scene will be triggered with “A Calendar event is active”.
Thanks for your help !!

Correct! I also noticed this after I posted. However this was not the solution. I now used Stuarts method and not the device properties anymore. Now it seems to be working!

Correct! I also noticed this after I posted. However this was not the solution. I now used Stuarts method and not the device properties anymore. Now it seems to be working![/quote]

Device Properties should work equally well - as I showed in the earlier post. At some point it’s a matter of preference … but … " if it isn’t broken" … :o

[quote=“duiffie, post:11, topic:182612”][quote=“Stuart, post:10, topic:182612”]@ Duiffie
Wow! I have a vera light and do not know if there is supposed to be a difference.

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

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

I did 2 things and then things started to work:

  • installed openssl: opkg install openssl-util
  • changed the first line of the googlejwt.sh script (#!/bin/bash to #!/bin/ash) because bash seems not present on vera 2 as well[/quote]

Hi Duiffie -

Could you do me a favor and tell me what version of openssl was installed ?

MCV have suggested a version to install (but not specifically identified for vera 2 - just ‘try it’) – and their suggestion is different (newer) than on my vera light. So I want to be a bit cautious here …

Hi Stuart

Is there some way to trigger overlapping events in PLEG? I have been able to get one to work using “Event with name” but it does not trigger on a second overlapping event. According to the manual
“1. If events overlap ? then the first event will complete before the second event starts i.e. the second event will have an effective start time at the end of the first event.”, which I take to mean no, but I wanted to check as they show up in json events with a time, so I was hoping this could be possible. I was hoping to use the plugin for heating and other things, but there will almost inevitably be overlapping events.

Thanks

[quote=“Borat, post:71, topic:182612”]Hi Stuart

Is there some way to trigger overlapping events in PLEG? I have been able to get one to work using “Event with name” but it does not trigger on a second overlapping event. According to the manual
“1. If events overlap ? then the first event will complete before the second event starts i.e. the second event will have an effective start time at the end of the first event.”, which I take to mean no, but I wanted to check as they show up in json events with a time, so I was hoping this could be possible. I was hoping to use the plugin for heating and other things, but there will almost inevitably be overlapping events.

Thanks[/quote]

There is some good documentation on PLEG in one of the PLEG forums.

Yes - the documentation (and your interpretation) is correct - the devise only contemplates one event at a time.

One thing to remember is that events have a start (which you can do something on … or not) and a finish (which you can do something on … or not). PLEG makes it easier to tease out the logic and get finer control than out-of-the-box vera

One way to approach what you want to do is leave gc_Keywords blank and use PLEG to react to the event names as they occur.

So you could (for example) have a short (say 5 min) event for “Heat On” and another separate event some time later for “Heat Off” – with other events in between … Or maybe short event for Heat {22} and another later on for Heat {15} to change the temp to specified levels . (Temp in Celsius).

You can also have multiple plugin instances looking at the same (or different calendars) and by using keywords - handle overlaps in this way too. Note that the vera has limited memory resources and you should be selective in the idea of multiple plugin instances.

And yes - you could read the event list and set up your own logic around that too – that’ what it’s there for :slight_smile:

Hope this gives you some ideas

Ok thanks I have been trying it with the keywords option so will have a play without it. Am wary of more instances as I have had some memory issues.

Cheers

Hi @Stuart,

Is there any way Gcal3 can detect and trip a different sensor (or triggers scenes) when overlapping events with different keywords each start and end?

My use case for this would be to have one google calendar which contains an event called Wake_Up repeating every day at 7am and other event called Vacation that would run for a week, overlapping a bunch of Wake_Up events. My logic would be not to trigger the Wake_Up event if the Vacation event is in progress.

(apologies if this has been asked and answered already… i searched for “overlap” in this thread and came up empty)

Thanks !

[quote=“mda, post:74, topic:182612”]Hi @Stuart,

Is there any way Gcal3 can detect and trip a different sensor (or triggers scenes) when overlapping events with different keywords each start and end?

My use case for this would be to have one google calendar which contains an event called Wake_Up repeating every day at 7am and other event called Vacation that would run for a week, overlapping a bunch of Wake_Up events. My logic would be not to trigger the Wake_Up event if the Vacation event is in progress.

(apologies if this has been asked and answered already… i searched for “overlap” in this thread and came up empty)

Thanks ![/quote]

I have a ‘one word’ answer … PLEG. It’s the ‘swiss army knife’ of the vera world and means that plugins like GCal don’t need to be nearly as complicated as they might otherwise be. It can easily do the sort of thing you describe – from a GCal3 perspective, you will probably leave gc_keyword blank and use PLEG to respond to gc_TrippedEvent values.

I have similar requirements and find PLEG to be invaluable. It takes a bit of effort to understand some of the ‘tricky’ stuff (e.g. state sequences) but well worth it …

My calendar shows up in the calendar tab, but calendar events don’t show up on the device to be used as triggers. Pressing ‘check’ on the control tab just leads to ‘checking…’ forever.
Any idea how I can fix this, please?

[quote=“conchordian, post:76, topic:182612”]My calendar shows up in the calendar tab, but calendar events don’t show up on the device to be used as triggers. Pressing ‘check’ on the control tab just leads to ‘checking…’ forever.
Any idea how I can fix this, please?[/quote]

It’s probably a credentials issue. Please set gc_debug to 3 and get a log

Also - make sure you have applied the patch here as it has a little more debugging

http://forum.micasaverde.com/index.php/topic,26692.msg190735.html#msg190735

50 09/08/14 13:38:00.102 luup_log:303: GCal3 gc_V 0.6.2:Checking semaphore <0x31862680>
50 09/08/14 13:38:00.103 luup_log:303: GCal3 gc_V 0.6.2:Semaphore file returned 0 <0x31862680>
50 09/08/14 13:38:00.123 luup_log:303: GCal3 gc_V 0.6.2:Device 303 requested semaphore <0x31862680>
50 09/08/14 13:38:00.124 luup_log:303: GCal3 gc_V 0.6.2:Device 303 claimed semaphore <0x31862680>
50 09/08/14 13:38:00.126 luup_log:303: GCal3 gc_V 0.6.2:StartMin is 2014-09-08T00:00:00.000Z StartMax is 2014-09-09T06:38:00.000Z <0x31862680>
50 09/08/14 13:38:00.140 luup_log:303: GCal3 gc_V 0.6.2:Function: requestCalendar <0x31862680>
50 09/08/14 13:38:00.144 luup_log:303: GCal3 gc_V 0.6.2:Getting new token <0x31862680>
50 09/08/14 13:38:00.145 luup_log:303: GCal3 gc_V 0.6.2:Client email is: 634xxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com <0x31862680>
50 09/08/14 13:38:00.186 luup_log:303: GCal3 gc_V 0.6.2:Command rm /etc/cmh-ludl/GCal3/GCal3303.token returned 256 <0x31862680>
50 09/08/14 13:38:00.205 luup_log:303: GCal3 gc_V 0.6.2:Command /usr/lib/lua/googlejwt.sh 634xxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com https://www.googleapis.com/auth/calendar /etc/cmh-ludl/GCal3/GCal3.pem /etc/cmh-ludl/GCal3/GCal3303.token returned 32512 <0x31862680>
50 09/08/14 13:38:00.205 luup_log:303: GCal3 gc_V 0.6.2:Could not execute the googlejwt.sh script <0x31862680>
50 09/08/14 13:38:00.206 luup_log:303: GCal3 gc_V 0.6.2:Fatal error trying to get access token <0x31862680>
50 09/08/14 13:38:00.206 luup_log:303: GCal3 gc_V 0.6.2:Device 303 released the semaphore <0x31862680>
50 09/08/14 13:38:00.208 luup_log:303: GCal3 gc_V 0.6.2:Next check will be in 10800 sec at 2014-09-08T16:38:00 <0x31862680>

I replaced my gmail email addy with a few xxxx’s, but otherwise I hope that’s what you need. I used the updated file too.
Thanks.

[quote=“Stuart, post:72, topic:182612”][quote=“Borat, post:71, topic:182612”]Hi Stuart

Is there some way to trigger overlapping events in PLEG? I have been able to get one to work using “Event with name” but it does not trigger on a second overlapping event. According to the manual
“1. If events overlap ? then the first event will complete before the second event starts i.e. the second event will have an effective start time at the end of the first event.”, which I take to mean no, but I wanted to check as they show up in json events with a time, so I was hoping this could be possible. I was hoping to use the plugin for heating and other things, but there will almost inevitably be overlapping events.

Thanks[/quote]

There is some good documentation on PLEG in one of the PLEG forums.

Yes - the documentation (and your interpretation) is correct - the devise only contemplates one event at a time.

One thing to remember is that events have a start (which you can do something on … or not) and a finish (which you can do something on … or not). PLEG makes it easier to tease out the logic and get finer control than out-of-the-box vera

One way to approach what you want to do is leave gc_Keywords blank and use PLEG to react to the event names as they occur.

So you could (for example) have a short (say 5 min) event for “Heat On” and another separate event some time later for “Heat Off” – with other events in between … Or maybe short event for Heat {22} and another later on for Heat {15} to change the temp to specified levels . (Temp in Celsius).

You can also have multiple plugin instances looking at the same (or different calendars) and by using keywords - handle overlaps in this way too. Note that the vera has limited memory resources and you should be selective in the idea of multiple plugin instances.

And yes - you could read the event list and set up your own logic around that too – that’ what it’s there for :slight_smile:

Hope this gives you some ideas[/quote]

Hi Stuart

The problem is, I can not see the overlapping event even in the advanced variables of the GCAL device, except in gc_jsonevents. For example, I set up 2 overlapping events and this is what I see (at a time when both are active). As PLEG can not extract the info on the second, I can not do anything with it in PLEG either. What am I missing here? gc_keyword is blank. All other config settings are set to false at the moment.

gc_jsonEvents: [{‘eventEnd’:1410166080,‘eventStart’:1410162480,‘eventName’:‘TEST1’},{‘eventEnd’:1410166200,‘eventStart’:1410162600,‘eventName’:‘VACATION’}]

gc_TrippedEvent: TEST1

Thanks

[quote=“Borat, post:79, topic:182612”]The problem is, I can not see the overlapping event even in the advanced variables of the GCAL device, except in gc_jsonevents. For example, I set up 2 overlapping events and this is what I see (at a time when both are active). As PLEG can not extract the info on the second, I can not do anything with it in PLEG either. What am I missing here? gc_keyword is blank. All other config settings are set to false at the moment.

gc_jsonEvents: [{‘eventEnd’:1410166080,‘eventStart’:1410162480,‘eventName’:‘TEST1’},{‘eventEnd’:1410166200,‘eventStart’:1410162600,‘eventName’:‘VACATION’}]

gc_TrippedEvent: TEST1

Thanks[/quote]

I had considered providing separate variables for overlapping events – but ‘how many’? Inevitably ‘someone’ will want ‘more’ … ;D Also there is a problem as events unfold - what variable relates to what event …

Instead I created a single variable gc_jsonEvents so that others could manipulate to their heart’s content. Not ideal but …
Here’s some sample code to decode the gc_jsonEvents variable. The idea would be to write a custom Luup script to do what you want or use it to set variables in one of the ‘container’ plugins which could then be used by PLEG. A bit ‘round about’ but …

The other approach, as stated earlier, is to use separate non overlapping events with parameters and PLEG to manage the respective conditions e.g. c1 => TEST and gc_value eq “On”, c2 => TEST gc_value eq “Off”, c3 => VACATION and gc_value eq “Start”, c4 =VACATION and gc_value eq “End”

function getjsonEvents() -- this is really some sample code and useful for debugging
local json = require"json")
  local jsonEvents = luup.variable_get(GCAL_SID, "gc_jsonEvents",lul_device)

  if (jsonEvents == "[]") then -- equivalent of a nul so don't try
    package.loaded.json = nil
    return
  end

  local eventList =json.decode(jsonEvents)
  local numberEvents = table.getn(eventList)
  local startevent, startDate, startTime, endevent, endTime, 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
    print("Event " .. i .. ": " .. event)
  end
  package.loaded.json = nil
  return
end

Hope this gives you a better set of options. For now - there are is no overlapping event handling. I may add some in the future but it still needs a good design that is not convoluted and for now - I do not have time; especially since my Vera os ‘bricked’ :-\ .