Thanks Stuart. I will try this version tonight
this is my script, which was “borrowed” from some other forum post, which appears to largely be borrowed from your testing code. I just added the tomdate variable and added an extra if statement in the for loop that iterates through the events found. that is simply so the speech output can gracefully say “Tomorrow’s events are…” and list them out
[code]url = require(“socket.url”)
local AV_DEV = 123
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local time = os.date(‘%I:%M’)
local todaydate = os.date(‘%Y-%m-%d’)
local tomdate = (os.date(“%Y-%m-%d”,os.time()+246060))
local SONOSZONES=“Kitchen”
local SameVolume=“true”
local TEMP_SID =“urn:upnp-org:serviceId:TemperatureSensor1”
local WUGTempHigh = luup.variable_get(TEMP_SID, “CurrentTemperature”, 6)
local currentCondition = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “Forecast.1.Condition”, 3)
local GS_SID = “urn:srs-com:serviceId:GCalIII”
local jsonEvents = luup.variable_get(GS_SID, “gc_jsonEvents”,236)
–checking to see if there are any events for the day. if not, tell us that there are no events for today.
if ((jsonEvents == “[]”) or (jsonEvents == nil)) then
TodaysEvents=“There are no events for today.”
else
TodaysEvents="Todays events are "
end
–checking to see if there are any events for tomorrow
if ((jsonEvents == “[]”) or (jsonEvents == nil)) then
TomorrowsEvents=“There are no events for tomorrow.”
else
TomorrowsEvents="Tomorrows events are "
end
–unwrapping all the different variables in the device variable.
package.loaded.json = nil
local json = require(“json”)
local eventList =json.decode(jsonEvents)
local numberEvents = table.getn(eventList)
local startevent, startDate, startTime, endevent, endTime, eventname, event
–looping around the dumping the variables into an array
for i = 1,numberEvents do
startevent = eventList[ i ].eventStart
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
–if the event happens today, add it to the TodaysEvents variable. if not, don’t add it.
if (startDate == todaydate) then
TodaysEvents = TodaysEvents … eventname … " . "
luup.log(event)
end
–if the event happens tomorrow at it to the TomorrowsEvents variable
if (startDate == tomdate) then
TomorrowsEvents = TomorrowsEvents … eventname … " . "
luup.log(event)
else
TomorrowsEvents=“There are no events for tomorrow.”
end
end
package.loaded.json = nil
–and then of course sending it all to the sonos device.
luup.call_action(LS_SID, “Say”, {Text = string.format(“Good morning, Guess Family! It is now %s. Here is your daily morning report. Today will be %s with a high of %s degrees. %s. %s. Have a great day.”, time, currentCondition, WUGTempHigh, TodaysEvents, TomorrowsEvents), GroupZones=SONOSZONES, SameVolumeForAll=SameVolume, Volume=50}, AV_DEV)[/code]
when I added the extra hours to endtime in the GCAL3.lua file to basically try and do what you’re doing with ExtraDays, it was somehow entering the logic for saying "todays events are " even though there were no events, so the speech output was just a bit weird. I probably somehow messed something somewhere else up when i was hacking around. I will give your updated version a try and report back.
Thanks for all the support!