[quote=“rigpapa, post:7, topic:199946”][quote=“sebby, post:6, topic:199946”]Thanks AK, that example had a typo. the issue still persists even if I don’t fat-finger things… Also of note, all of this was working a few weeks ago, the code running on Vera, scenes, and the test luup code all worked just fine. i added a plugin and some child devices and now the code runs fine in the Vera environment, but not in the scenes or test luup code. very strange…
08 10/28/18 13:36:03.060 JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x6fb50520>
08 10/28/18 13:36:03.060 JobHandler_LuaUPnP::HandleActionRequest argument id=lu_action <0x6fb50520>
08 10/28/18 13:36:03.060 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x6fb50520>
08 10/28/18 13:36:03.061 JobHandler_LuaUPnP::HandleActionRequest argument action=RunLua <0x6fb50520>
08 10/28/18 13:36:03.061 JobHandler_LuaUPnP::HandleActionRequest argument Code=sebbyCode.setLocation()
<0x6fb50520>
01 10/28/18 13:36:03.061 LuaInterface::StartEngine failed run: 0 [string "sebbyCode.setLocation()..."]:1: attempt to call field 'setLocation' (a nil value) <0x6fb50520>
01 10/28/18 13:36:03.061 JobHandler_LuaUPnP::RunLua failed: sebbyCode.setLocation()
<0x6fb50520>
02 10/28/18 13:36:03.062 JobHandler_LuaUPnP::RunAction device -1 action urn:micasaverde-com:serviceId:HomeAutomationGateway1/RunLua failed with 401/Code failed <0x6fb50520>
[/quote]
sebby, double-check the name of the function definition in your module/startup code. The error message specifically suggests that (1) [tt]sebbyCode[/tt] is being found (because it not issuing an error related to a reference through nil, which you would get if [tt]sebbyCode[/tt] was nil/undefined), and (2) [tt]setLocation[/tt] is not defined within what is being found as [tt]sebbyCode[/tt] (or it is defined, but declared [tt]local[/tt]).[/quote]
thanks for the help rigpappa, setLocation is actually defined as a global [_G.setLocation()]. i would think that if it was not defined correctly, it would not run at all. what i am experiencing is that the code runs just fine when triggered from one of my luup.variable_watch functions (also defined in sebbyCode), but it only fails in scenes or the test luup code.
You might also run this in the Lua test tool, and see if outputs expected results (to the Vera log--run it several times to make sure the log's buffering flushes more quickly):
luup.log("sebbyCode is a " .. type(sebbyCode),2)
for k,v in pairs(sebbyCode) do -- this will give an error if sebbyCode is undefined or not table, which is fine--that's good info
luup.log(k .. " is a " .. type(v) .. " with value " .. tostring(v),2)
end
This should dump the contents of [tt]sebbyCode[/tt] if it’s a table (or module), and you should see the function listed there as it is defined, e.g. [tt]setLocation is a function with value function: 0xabcdef[/tt]
i ran the code, and it errors from the test luup screen. It shows the code looking like a string, not sure what i would have expected there. this is what it shows in the log:
08 10/28/18 14:09:13.530 JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x70a0e520>
08 10/28/18 14:09:13.530 JobHandler_LuaUPnP::HandleActionRequest argument id=lu_action <0x70a0e520>
08 10/28/18 14:09:13.531 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x70a0e520>
08 10/28/18 14:09:13.531 JobHandler_LuaUPnP::HandleActionRequest argument action=RunLua <0x70a0e520>
08 10/28/18 14:09:13.531 JobHandler_LuaUPnP::HandleActionRequest argument Code=luup.log("sebbyCode is a " .. type(sebbyCode),2)
for k,v in pairs(sebbyCode) do -- this will give an error if sebbyCode is undefined or not table, which is fine--that's good info
luup.log(k .. " is a " .. type(v) .. " with value " .. tostring(v),2)
end <0x70a0e520>
02 10/28/18 14:09:13.532 luup_log:0: sebbyCode is a string <0x70a0e520>
01 10/28/18 14:09:13.532 LuaInterface::StartEngine failed run: 0 [string "luup.log("sebbyCode is a " .. type(sebbyCod..."]:2: bad argument #1 to 'pairs' (table expected, got string) <0x70a0e520>
01 10/28/18 14:09:13.532 JobHandler_LuaUPnP::RunLua failed: luup.log("sebbyCode is a " .. type(sebbyCode),2)
for k,v in pairs(sebbyCode) do -- this will give an error if sebbyCode is undefined or not table, which is fine--that's good info
luup.log(k .. " is a " .. type(v) .. " with value " .. tostring(v),2)
end <0x70a0e520>
02 10/28/18 14:09:13.532 JobHandler_LuaUPnP::RunAction device -1 action urn:micasaverde-com:serviceId:HomeAutomationGateway1/RunLua failed with 401/Code failed <0x70a0e520>