Variable from Google Calendar to Sonos Say feature

I have Google Calendar plugin and Sonos plugin. I can have the calendar trigger a scene where is says “Event is on your Calendar” when ever an event active. What I would like to do, is pass the Event name to the Sonos plugin so it can announce the event over my Sonos speakers? Is this possible, can I pass variable from Google Calendar to Sonos via the Scene is Active? Works for hard code text to say, but not via “Event Title”. Is there such a variable I can pass?

Kyle – the variable you want is gc_TrippedEvent. if you need other variables - they are explained in the documentation on the first post of the main thread. enjoy

Thanks, I missed that doc. I see all the variables, but not sure how to use in Advanced tab. I tried just the name gc_TrippedEvent but it just read it as that, not the value of it. Is there special notation I need?

$gc_TrippedEvent
%gc_TrippedEvent
$gc_TrippedEvent$

Just want the title of the even to be announced over my speakers, dynamically per event.

[quote=“kyle.dawson, post:3, topic:184177”]Thanks, I missed that doc. I see all the variables, but not sure how to use in Advanced tab. I tried just the name gc_TrippedEvent but it just read it as that, not the value of it. Is there special notation I need?

$gc_TrippedEvent
%gc_TrippedEvent
$gc_TrippedEvent$

Just want the title of the even to be announced over my speakers, dynamically per event.[/quote]

You will need to get the variable using some code like this: gc_Value and gc_Trippedevent shown …

local gCalDeviceNo = ?? -- YOUR GCal Sensor device number
local GS_SID = "urn:srs-com:serviceId:GCalIII" -- GCal Sensor Service ID
local eventVar = luup.variable_get (GS_SID, "gc_Value", gCalDeviceNo )
local eventTitle = luup.variable_get (GS_SID, "gc_TrippedEvent", gCalDeviceNo )

I’m not familiar with Sonos but I’m guessing you will then need to follow with some code to update the Sonos device’s Text parameter using something like this

local SONOSDeviceNo = ?? -- The Sonos device number
local SONOS_SID = "urn:????????????" -- The Sonos Service ID
local updateText = luup.variable_set (SONOS_SID, "Sonos Text Variable Name", eventTitle, SONOSDeviceNo)

I’m sure details for updating Sonos can be found in the applicable forum. Hope this helps.

I really wanted to just use the advanced tab ui to do this, like the screen shot above. So what your saying is i have to write code? I have never done this with verde. Will take me time to read up on this. Thanks for all the info.

I’m guessing that - yes - you will need to write code but take a look at the sonos discussion and also discuss with the sonos author - there may be some facilities already there.

I’ll also thing about the possibility of a ‘push’ from GCal. It looks like it would be pretty simple to incorporate - of course the details can be a bit ‘interesting’ :o

I got further today. I can have it trigger my Sonos when I have calender event, but not able to get the event title:

local gCalDeviceNo = 75
local GS_SID = “urn:srs-com:serviceId:GCalIII”
local eventVar = luup.variable_get (GS_SID, “gc_Value”, gCalDeviceNo )
local eventTitle = luup.variable_get (GS_SID, “gc_TrippedEvent”, gCalDeviceNo )

local SONOSDeviceNo = 26
local SONOS_SID = “urn:micasaverde-com:serviceId:Sonos1”
luup.call_action(SONOS_SID , “Say”, {Text = string.format(“You have new event”, eventTitle )}, SONOSDeviceNo )

Over my sonos is just says “You have new event” and does not say anything else. I am getting the event Title correctly? It seems blank.

[quote=“kyle.dawson, post:7, topic:184177”]I got further today. I can have it trigger my Sonos when I have calender event, but not able to get the event title:

local gCalDeviceNo = 75
local GS_SID = “urn:srs-com:serviceId:GCalIII”
local eventVar = luup.variable_get (GS_SID, “gc_Value”, gCalDeviceNo )
local eventTitle = luup.variable_get (GS_SID, “gc_TrippedEvent”, gCalDeviceNo )

local SONOSDeviceNo = 26
local SONOS_SID = “urn:micasaverde-com:serviceId:Sonos1”
luup.call_action(SONOS_SID , “Say”, {Text = string.format(“You have new event”, eventTitle )}, SONOSDeviceNo )

Over my sonos is just says “You have new event” and does not say anything else. I am getting the event Title correctly? It seems blank.[/quote]

it looks like your code is doing what you have told it to do. Specifically the command
{Text = string.format(“You have new event”, eventTitle )} is forcing Text to = “You have new event”

Since eventTitle is already a string - perhaps just
{Text = eventTitle )}

I have found this to be a helpful reference
http://www.lua.org/pil/20.html

That did it. Thanks so much for the help. This was my first code for verde. So far, I just used the GUI for what I wanted, now I have the power of code. Thanks for helping.

Also, to have this trigger for all events, I had to change these on the device Advanced tab:

gc_triggerNoKeyword to true

gc_exactKeyword tp false

[quote=“kyle.dawson, post:10, topic:184177”]Also, to have this trigger for all events, I had to change these on the device Advanced tab:

gc_triggerNoKeyword to true

gc_exactKeyword tp false[/quote]

Congratulations on getting the code to work !!

With gc_triggerNoKeyword set to true, it should not matter what gc_exactKeyword is set to. gc_exactKeyword is only used when you set a keyword (e.g. TEST) and this would allow the plugin to trigger on events named TEST1, Test Something etc i.e. a partial match.

using gc_triggerNoKeyword set to true is fine if you want to parse all events to see if it’s one you want to react (or not). Another way - assuming you are on UI5 - (there are some bugs in UI7 that prevent this from working until vera fixes them) is to use “Event has a specified name” - that way you can set up triggers to react to specific event names.

The choice is yours - not that either is better, just that one may be better in a given situation.

Enjoy.

Does this

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

look interesting / usable for you guys ?

Thank you for all information, I’m now also able to Say with Sonos some of my Calendar Event.

But if in the event name I have that:
April 26, at 04:16PM “Weight: 221.78 lb (100.6 kg) / Lean mass: – lb (-- kg) / Fat mass: – lb (-- kg) / Body fat: – %”

How can I extrapolate in a Variable only “100.6”? Are there some function to filter it?

Thank you
Matteo

[quote=“kyle.dawson, post:7, topic:184177”]I got further today. I can have it trigger my Sonos when I have calender event, but not able to get the event title:

local gCalDeviceNo = 75
local GS_SID = “urn:srs-com:serviceId:GCalIII”
local eventVar = luup.variable_get (GS_SID, “gc_Value”, gCalDeviceNo )
local eventTitle = luup.variable_get (GS_SID, “gc_TrippedEvent”, gCalDeviceNo )

local SONOSDeviceNo = 26
local SONOS_SID = “urn:micasaverde-com:serviceId:Sonos1”
luup.call_action(SONOS_SID , “Say”, {Text = string.format(“You have new event”, eventTitle )}, SONOSDeviceNo )

Over my sonos is just says “You have new event” and does not say anything else. I am getting the event Title correctly? It seems blank.[/quote]

Try this :

[code]
local gCalDeviceNo = 75
local GS_SID = “urn:srs-com:serviceId:GCalIII”
local eventVar = luup.variable_get (GS_SID, “gc_Value”, gCalDeviceNo )
local eventTitle = luup.variable_get (GS_SID, “gc_TrippedEvent”, gCalDeviceNo )

local SONOSDeviceNo = 26
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local playbackVol = 80
luup.call_action(LS_SID, “Say”, {Text = string.format(“You have new event %s”, eventTitle), Volume=playbackVol}, SONOSDeviceNo)[/code]

Added event start and end triggers including overlapping events in R1.3. May be useful with Sonos.