local sensorDeviceNo = 11
local lightDeviceNo = 18
local period = 10
local NoMoveDelay = 30
local SS_SID = "urn:schemas-micasaverde-com:device:MotionSensor:1" -- Security Sensor Service ID
local SP_SID = "urn:schemas-upnp-org:device:DimmableLight:1" -- 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)) >= NoMoveDelay) then
luup.call_action (SP_SID, "SetTarget", {["newTargetValue"] = 0}, lightDeviceNo)
else
luup.call_delay ("checkLastTrip", period)
end
end
luup.call_delay ("checkLastTrip", 0)
За основу взят вот этот код:
local sensorDeviceNo = 10
local lightDeviceNo = 9
local period = 12
local LOW_LEVEL = 60
local DEVICE_NO = 12
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", {["newTargetValue"] = 0}, lightDeviceNo)
else
luup.call_delay ("checkLastTrip", period)
end
end
luup.call_delay ("checkLastTrip", period)
return true
else
return false
end
задан
18 Июн '15, 16:48
Golden
1●1
процент согласия:
0%
Добрый день! Вы сами писали данный сценарий или взяли готовый откуда-то?
За основу взят готовый код с форума и исправлен под свои нужды.