Hi All,
I'm running a Vera3, UI5 (1.5.622 .)
I've been delving into the wonderful world of lua scripting for exactly 2 weeks and have made some great scenes. Everything was working great until this morning when I made a small lua code change on one scene. Suddenly, after saving the scene, the dashboard status showed ERROR : Error in lua for scenes and events. I thought "No biggie, I obviously screwed up something, I'll just delete what I added. Well, I deleted exactly the line I added, then saved again and got the same error. Then I tried running the scene anyway and got the following error in the log.
Scene::RunScene running 60 test logging <0x2d73f680>
01 05/19/14 11:41:24.469 [31;1mLuaInterface::CallFunction_Scene Scene 60 failed attempt to call a nil value[0m <0x2d73f680>
I went back into the log and found a log entry that references a possible issue with one of my scenes, the log entry is:
01 05/19/14 11:51:22.569 [31;1mLuaInterface::LoadCode: [string "function scene_52()..."]:157: ')' expected near 'opensensors'[0m <0x2b8cb000>
01 05/19/14 11:51:22.585 [31;1mJobHandler_LuaUPnP::Run cannot start lua with code:
Here is the scene lua code:
local vol = 65
local son = 27 --mast bdr =33, kitch=27
local devcnt = 0
local devno = 0
local numopen = 0
local isare = "is"
local opensensors = " "
luup.log('Commencing sensor device search loop')
for deviceNo,d in pairs(luup.devices) do
if d.category_num == 4 then
local tripped = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", deviceNo) or "Nil"
if (tripped == "1") then
opensensors = opensensors .. ". " .. d.description
numopen = numopen + 1
end
luup.log(d.description .. ' status:' .. tripped .. ' Dev #' .. deviceNo .. ' id:' .. d.id .. ' cat #:' .. d.category_num .. ' type:' .. d.device_type)
devcnt = devcnt + 1
end
end
if numopen == 0 then --If there are no sensors tripped, log and announce!
luup.log('There were ' .. devcnt .. ' door and window sensors found and all are closed')
luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say", {Text="There were " .. devcnt .. " door and window sensors found, and all are closed", Language="en", Volume=vol}, son)
else --If there are any sensors tripped, log and announce!
if numopen > 1 then
isare = "are"
end
luup.log('There were ' .. devcnt .. ' door and window sensors found and ' .. numopen .. " " .. isare .. ' open' .. opensensors)
luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say", {Text="There were " .. devcnt .. " sensors found and " .. numopen .. " " .. isare .. " open." .. opensensors, Language="en", Volume=vol}, son)
end
Can anyone see where the expected ')' is supposed to go? Would this one issue stop all lua code from running?
Thanks
Pasqual