It's been working good for me with a camera detection and Blue Iris API....
-- DETECTiION MOVEMENT OUTSIDE FROM MY CAMERA
local device1 = 319 -- Light
local device2 = 330 -- Detect.
local dayNo = 9
local delay = 120
local delay1 = 5
function checkmotion()
local itsday = luup.variable_get("urn:rts-services-com:serviceId:DayTime","Status", dayNo) -- Night Time
if(itsday == "0")then
luup.call_action("urn:micasaverde-com:serviceId:SecuritySensor1", "SetArmed", {newArmedValue = "0"},device2)
luup.call_delay( 'switch_on', delay1) -- Call the switch on function after a delay of x seconds
function switch_on()
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" },device1)
luup.call_action("urn:dcineco-com:serviceId:MiLightRGBW1","SetWhiteMode",1,device1)
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{newLoadlevelTarget = 100},device1)
luup.call_delay( 'switch_off', delay) -- Call the switch off function after a delay of x seconds
function switch_off()
luup.call_action("urn:dcineco-com:serviceId:MiLightRGBW1","SetHue",{newHue = 40},device1)
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" },device1)
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{newLoadlevelTarget = 100},device1)
luup.call_delay( 'switch_arm', delay1) -- Call the switch off function after a delay of x seconds
function switch_arm()
luup.call_action("urn:micasaverde-com:serviceId:SecuritySensor1", "SetArmed", {newArmedValue = "1"},device2)
end
end
end
end
end
checkmotion()