I’m trying to write a function that detects a devices status change then does something. Such as:
If light1 turns on
then do something
if light1 turns off
then do something
if light 2 turns on…
I see the function “variable_watch” with parameters “function_name (string), service (string), variable (string or nil), device (string or number)”. So for light1 on (call it device 1), would it be:
luup.variable_watch("checkLights1","urn:upnp-org:serviceId:SwitchPower1", "Status", 1)function checklights1 (lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
local new = lul_value_new
local old = lul_value_oldIf new > old then
do what you do when light turns on
else
do what you do when light turns off
end
I would then repeat the same for light2, light3, etc.