Author Topic: Make lights blink(multiple) when motion detector is tripped  (Read 2082 times)

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Make lights blink(multiple) when motion detector is tripped
« on: October 24, 2011, 08:28:26 pm »
1. Create an Event for Motion detector.

2. Courtesy of Ap15e – Use the following code :)

http://forum.micasaverde.com/index.php/topic,5127.0.html

So here's the modified version that lets you put in # of lights that you want to blink - And the lights go back to their original status after the blinking counter reaches its max...(I'll update this under AP15e's sample as well)

Code: [Select]

--Enter the device ID's here in the array with your device id's
local array_lights = {1,2,3}
local original_status={}
local counter = 10
local delay   = 3


function set_switch(device,value)
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue=value },device)
end


function tree_on()
for i, device in ipairs(array_lights) do
set_switch(device,"1")
end
luup.call_delay( 'tree_off', delay )
end

function tree_off()
counter = counter-1

if counter > 0 then
for i, device in ipairs(array_lights) do
set_switch(device,"0")
end
luup.call_delay( 'tree_on', delay )

   else

   --Set to original status
for i, device in ipairs(array_lights) do
set_switch(device,original_status[i])
end

  end

end



--Save Original status
for i, device in ipairs(array_lights) do
original_status[i] = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status", device)
end

tree_off()

« Last Edit: October 25, 2011, 07:23:47 pm by mysticjay »
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline pgrover516

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1013
  • Karma: +0/-0
Re: Make lights blink(multiple) when motion detector is tripped
« Reply #1 on: October 26, 2011, 01:03:44 am »
Nice thanks!
V1,V2,V3,VLite,Express Controls HSM-100,Intermatic HA20C, HA04C,HA02C,HA09, Leviton VRP15-1LW, VRS15-1LX,Home Manageables HM-TS001,Schlage FE599, Schlage BE369, Cooper RF9500, Aeon Labs Minimote, Schlage TZEMT400AB32MAA+more