@keithr, after taking your updated of @becky’s code, I did a few modifications to finally getting the LUA snippit to work on my VERA - Edge. I’m hoping that @becky was able to get the Weather Alarm(s) to also work. Does anyone know of a way to get the calendar event to also have the start times announced?
[code]
– Morning Announcement (Becky) modified by Michael Blackwell. To let the family know what’s going on for the day before we get out of bed. It includes, current time, current weather condition, current temperature and any calendar events for the day from google calendar via GCal3 plugin plugin
local AV_DEV = 15 – Sonos Device ID within Vera
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local LS_ZONES = “Kitchen,Living Room,Patio Room” – Valid GroupZones = “All”, “Kitchen”, “Patio Room”, “Living Room”, “Master Bedroom”, “Lily’s Cabin” Note: if you are grouping more than one zone, ensure that there are no spaces between the deliminating comma.
local LS_VOLUME = 70
local time = os.date(‘%I:%M’)
local todaydate = os.date(‘%Y-%m-%d’)
local WEATHER_ID = 5 – World Weather Device ID
local WEATHER_ID2 = 6 – World Weather Child Device ID
local WEATHER_SID = “urn:upnp-micasaverde-com:serviceId:Weather1”
local TEMP_SID = “urn:upnp-org:serviceId:TemperatureSensor1”
local WeatherCurrCondition = luup.variable_get(WEATHER_SID, “Condition”, WEATHER_ID)
local WeatherCurrTemp = luup.variable_get(TEMP_SID, “CurrentTemperature”, WEATHER_ID2)
local GS_SID = “urn:srs-com:serviceId:GCalIII”
local jsonEvents = luup.variable_get(GS_SID, “gc_jsonEvents”, 243) --GCal3 Sensor Device ID
– 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 Calendar events scheduled for today. "
else
TodaysEvents=” The Calendar Events for Today are as follows; "
end
– unwrapping all the different variables in the device variable.
local json = require(“dkjson”) – depending on your vera version like Edge or Plus, you may need to use require(“json”)
local eventList =json.decode(jsonEvents)
package.loaded.json = nil
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 (i == 1) then
TodaysEvents = TodaysEvents … eventname … " . "
else
TodaysEvents = TodaysEvents … " then " … eventname … " . "
end
luup.log(event)
end
package.loaded.json = nil
– Establishing proper greeting depending on the time of day
local time2 = os.date(‘It is %H:%M.’)
local hour=tonumber(os.date(‘%H’))
local greeting=“”
if hour < 12 then
greeting = “Good morning”
elseif hour < 17 then
greeting = “Good afternoon”
elseif hour < 21 then
greeting = “Good evening”
else
greeting = “Good evening”
end
– and then of course sending it all to the sonos device to make the announcement.
luup.call_action(LS_SID, “Say”, {Text = string.format(“%s Blackwell family! The time is. %s Here is your daily report. Today’s weather will be %s with a high of %s degrees %s Have a great day.”, greeting, time, WeatherCurrCondition, WeatherCurrTemp, TodaysEvents), GroupZones=LS_ZONES, SameVolumeForAll=“true”, Volume=LS_VOLUME}, AV_DEV)[/code]
Made correction in the Say statement had some flaws…