Make lights blink(multiple) when motion detector is tripped

  1. Create an Event for Motion detector.

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

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)


--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()

Nice thanks!