Hi
I’m trying to see if I can create a separate file/module with all my watched variables and functions in ? But I’m not having much luck ? Is it even possible ?
I have a file called xxluupvariablewatch.lua uploaded and the following entry in the lua startup
require "xxluupvariablewatch"
And then with the module/Lua file itself I have the following.
module("xxluupvariablewatch", package.seeall)
function IP_power_state_change(dev_id,service, variable, old_val, new_val)
luup.log("A watched variable has changed - check and update status")
luup.log(dev_id,service, variable, old_val, new_val)
-- called when the Office Desk Socket is switched on or off - from a variable_watch
if new_val == "1" then
luup.log("IPPower has been turned ON check socket status")
-- code here to do stuff..
else
luup.log("IPPower has been turned OFF check socket status")
-- code here to do stuff
end
end
luup.variable_watch("IP_power_state_change", "urn:upnp-org:serviceId:SwitchPower1","Status", 375)
No matter what I do , while the log records the watched variable change, but the called function does not work, I continue to get the same error. (See below)
06 09/04/21 10:30:03.805 Device_Variable::m_szValue_set device: 375 service: urn:upnp-org:serviceId:SwitchPower1 variable: Status was: 0 now: 1 #hooks: 1 upnp: 0 skip: 0 v:0x10f6ae8/NONE duplicate:0 <0x76eda520>
01 09/04/21 10:30:03.805 LuaInterface::CallFunction_Variable func: IP_power_state_change Device_Variable 375 urn:upnp-org:serviceId:SwitchPower1:Status failed attempt to call a nil value <0x76eda520>
Any ideas ?