Hello! Please tell me, how do I make the scene:
When motion is detected, the lighting is switched on for 60% and burned for 1 minute. If the movement continues the lights turned on at 100%. If dvidenie stopped the lights off.
local sensorDeviceNo = 22
local lightDeviceNo = 20
local period = 60
local LOW_LEVEL = 100
local DEVICE_NO = 24
local LS_SID = “urn:micasaverde-com:serviceId:LightSensor1” – the LightSensor service ID
local SS_SID = “urn:micasaverde-com:serviceId:SecuritySensor1” – Security Sensor Service ID
local SP_SID = “urn:upnp-org:serviceId:SwitchPower1” – Switch Power Service ID
local currentLevel = luup.variable_get (LS_SID, “CurrentLevel”, DEVICE_NO) or 0
currentLevel = tonumber(currentLevel)
if currentLevel <= LOW_LEVEL then
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”, {[“newLoadlevelTarget”] = 60}, lightDeviceNo)
else
if (os.difftime (os.time(), tonumber (lastTrip)) >= period) then
luup.call_action (SP_SID, “SetTarget”, {[“newLoadlevelTarget”] = 40}, lightDeviceNo)
else
luup.call_delay (“checkLastTrip”, period) – Check when the sensor was last tripped every seconds.
end
end
end
luup.call_delay (“checkLastTrip”, period)
return true
else
return false
end
What is the LS_SID, SS_SID, SP_SID?
Why use DEVICE_NO? the level of lit. nothing has changed