I have written some Lua to give me some TTS as to where my wife is and how long she’s going to be (not as creepy as it sounds I promise)
The Lua works perfectly when I run it from the Test Lua windows, but when I execute it in a scene:
|08|02/07/20 19:19:05.382|JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunScene <0x723bc520>|
|---|---|---|
|08|02/07/20 19:19:05.382|JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x723bc520>|
|08|02/07/20 19:19:05.383|JobHandler_LuaUPnP::HandleActionRequest argument action=RunScene <0x723bc520>|
|08|02/07/20 19:19:05.383|JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=84 <0x723bc520>|
|08|02/07/20 19:19:05.383|JobHandler_LuaUPnP::HandleActionRequest argument rand=0.012212348495252767 <0x723bc520>|
|08|02/07/20 19:19:05.383|Scene::RunScene running 84 Where Rachel <0x723bc520>|
|01|02/07/20 19:19:05.383|LuaInterface::CallFunction_Scene Scene 84 failed attempt to call a nil value <0x723bc520>|
Here’s the Lua
local RachelDistance = math.floor(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "Distance", 250))
local RachelSpeed = math.floor(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "RTSpeed", 250))
local RachelETA = math.floor((luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "ETA", 250))/60)
luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="Rachel is currently"..RachelDistance.."kilometers away. Her Speed is " ..RachelSpeed.. " kilmoters per hour and her ETA is" ..RachelETA.. " minutes",Volume=40,GroupZones="Living_Room_dot"}, 167)
So hitting run reports success from inside the scene editor but launching the scene from outside the editor fails? I think there could be an error in how the scene is being saved. It may not have the right identifier…
yeah create another one with some action in the editor. first make sure that it is saved, test it and see that it works. Then go back into the editor and put your lua code.
When the log says it fails, did it actually execute?
Are you sure these work in a test lua screen when you execute?
I get the feeling that you are running mathfloor functions on strings, You may need to convert them with a tonumber function right after the variable get.
local RachelDistance = tonumber(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "Distance", 250))
RachelDistance = math.floor(RachelDistance)
local RachelSpeed = tonumber(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "RTSpeed", 250))
RachelSpeed = math.floor(RachelSpeed)
local RachelETA = tonumber(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "ETA", 250))
RachelETA = math.floor(RachelETA/60)
luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="Rachel is currently"..RachelDistance.."kilometers away. Her Speed is " ..RachelSpeed.. " kilmoters per hour and her ETA is" ..RachelETA.. " minutes",Volume=40,GroupZones="Living_Room_dot"}, 167)
luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="Rachel is currently"..RachelDistance.."kilometers away. Her Speed is " ..RachelSpeed.. " kilmoters per hour and her ETA is" ..RachelETA.. " minutes",Volume=40,GroupZones="Living_Room_dot"}, 167)
?
But having deleted that line from the scene Lua, still: