Hi,
I have a problem with a scene where I wan’t a light to turn on if it’s day and movement is detected of my SP103. Added a luup script for it to turn of after 45 seconds but if anyone remain in the room after 45 seconds it doesn’t seem to react again until I leave the room and come back again. I want it to trip again directly after the 45 seconds have gone if there is still movement in the room
Any ideas?
Luup script below
Regards,
Mikael
[code]local sensorDeviceNo = 29 – Motion Sensor device number
local lightDeviceNo = 5 – Light device number
local period = 45 – Seconds
local SS_SID = “urn:micasaverde-com:serviceId:SecuritySensor1” – Security Sensor Service ID
local SP_SID = “urn:upnp-org:serviceId:SwitchPower1” – Switch Power Service ID
function checkLastTrip()
local lastTrip = luup.variable_get (SS_SID, “LastTrip”, sensorDeviceNo) or os.time()
if (os.difftime (os.time(), tonumber (lastTrip)) >= period) then
luup.call_action (SP_SID, “SetTarget”, {[“newTargetValue”] = 0}, lightDeviceNo) – Turn off the light.
else
luup.call_delay (“checkLastTrip”, period) – Check when the sensor was last tripped every seconds.
end
end
luup.call_delay (“checkLastTrip”, period)
return true[/code]