I’ve written a new script for my sonos which will tell me the time, my morning motivation (TBD), and read me the last 24 hours of work emails (subject, time, sender). However I can run this script once (it does take like 9 seconds to run), then after that all of my os.date() functions stop working. If I restart Vera, everything comes back, until I run it again.
Is it a performance thing? Resources? Code?
[code]function sonosemails()
local emails = getemails()
local saypastemails = "I will now brief you on your unread emails from the last 24 hours. "
for k, v in pairs(emails) do
for k, v in pairs(emails[k]) do
–print(k, “:”, v)
if(k == 1) then
saypastemails = saypastemails … " Received " … v
elseif(k == 2) then
saypastemails = saypastemails … " From " … v
else
saypastemails = saypastemails … " with the subject " … v … "… "
end
end
end
return saypastemails
end
local AV_DEV = 53
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local time = os.date(‘%I:%M’)
local TEMP_SID = “urn:upnp-org:serviceId:TemperatureSensor1”
local currenttemp = luup.variable_get(TEMP_SID, “CurrentTemperature”, 41)
local hightemp = luup.variable_get(TEMP_SID, “CurrentTemperature”, 43)
local weatherc = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”,“Condition”, 40)
local morningmot = “Do better.”
local ems = sonosemails()
luup.call_action(LS_SID, “Say”,
{Text = string.format(“Good Morning! The current time is %s. The weather today is %s with the current temp at %s, and a high of %s. Today your morning motivation is %s. %s”, time, weatherc, currenttemp, hightemp, morningmot, ems)}
, AV_DEV)[/code]