Helping to create scenes.

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

local lightLevel = luup.variable_get(“urn:micasaverde-com:serviceId:LightSensor1”,“CurrentLevel”, 24)
local result = false
if (lightLevel and (tonumber(lightLevel) < 100)) then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “10”}, 20)
else if (lightLevel and (tonumber(lightLevel) < 200)) then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “20”}, 20)
end
return result

Hello! Prompt please, the script gives an error that is not correct?

Unless you put this in a file with a .lua extenstion and require it into your code you can’t use the <
character without escaping it!

Flip the args so you use the > argument in your tests!