local house_occupied=luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",45) if (house_occupied == "0") or not ( luup.is_night() ) then return false end local Device3 = 18 local RandOnTime3 = 3600 local On3 = 1000 local RandOffTime3 = 600 local RanNumbOn3 = (math.random() * RandOnTime3 ) local RanNumbOff3 = (math.random() * RandOffTime3 ) function DelayOn3() luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1"},Device3) luup.call_timer("StayOn3", 1, On3 , "", "") end function StayOn3() luup.call_timer("DelayOff3", 1, RanNumbOff3, "", "") end function DelayOff3() luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0"},Device3) end luup.call_timer("DelayOn3", 1 , RanNumbOn3,"","")