Hello. I’m not at all smart in luup codes. The thing is I need two switches to turn off after a while when motion sensor is tripped. I made the scene, everything works fine just that only one off the switches turns off. The code I am using is:
local device = 13 – Switch on device 13:
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },device)
luup.call_delay( ‘switch_off’, 10) – Call the switch off function after a delay of 10 seconds
function switch_off()
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },device)
end
local device = 20 – Switch on device 20:
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },device)
luup.call_delay( ‘switch_off’, 10) – Call the switch off function after a delay of 10 seconds
function switch_off()
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },device)
end
return true
and I am sure it is far from correct. I tried to play with it, changed it million times but without results, only one switch (#13) is turning off after those 10 seconds.
EDIT:
The right code was this:
[11:01:22 PM] u------u: local device = 13and in interface I made for this sceene to turn on the two lights + trigger for sensor tripping.luup.call_delay( ‘switch_off1’, 10) – Call the switch off function after a delay of 10 seconds
function switch_off1()
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },device)end
local device = 25
luup.call_delay( ‘switch_off2’, 15) – Call the switch off function after a delay of 15 seconds
function switch_off2()
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },device)end
return true