Trying to get reactor to work, but always I get an “undeclared/uninitialized global” error.
Below is the code…don’t know what is wrong with it.
Anyone an idea what’s wrong ?
local TvOnOff = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”, “Tripped”, 54)
if (TVOnOff == “1”) then
luup.call_action(‘urn:micasaverde-com:serviceId:HomeAutomationGateway1’, ‘SetHouseMode’, { Mode=4 }, 0)
else
luup.call_action(‘urn:micasaverde-com:serviceId:HomeAutomationGateway1’, ‘SetHouseMode’, { Mode=1 }, 0)
end
Hard to see anything wrong with that, except perhaps a matter of style
local TvOnOff = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 54)
local mode = (TVOnOff == "1") and 4 or 0
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "SetHouseMode", {Mode=mode}, 0)
plus, of course, the quotes which seem to have been substituted by inverted commas, thanks perhaps to poor formatting or an over-keen editor.
If that’s actually your code, there’s a capitalization difference in “TV” between initializing the variable and then using it in the if. What you use in the if is the undeclared variable.
The full error message also includes the name of the variable in both the LuaUPnP log message and the message put in the event log (visible in the Events section of the Logic Summary, Tools tab). I try not to let these things be too much of a fishing expedition and post as much information as is available.
Kudos to you. Always hard to spot these things, which is why I’d recommend using a proper IDE to develop any code. My favourite for Lua is undoubtedly ZeroBrane Studio.