Smart blinking

Hello,

I have a Vera Plus controller with several devices Qubino ZMNHBD1 (Switch 2 relays).

I would like to create a scene for 4 lights :

Each light can have a different state at the begining. For example :
Light #1 is on
Light #3 is off
Light #4 is off
Light #5 is on

When I’ll launch the scene :
Switch off the lights #1 and #4
Switch on the lights #2 and #3

One second later :

Switch on the lights #1 and #4
Switch off the lights #2 and #3

And so on 4 times

At the end the lights must be in same state that at the begining.

How can make this scene ?

Thanks in advance.

Gvals

This is what I found on the forum… it’s working for me

–Blink lights

–Enter the device ID’s here in the array with your device id’s
local array_lights = {XX, XX, XX, XX }
local original_status={}
local counter = 4
– set the counter value higher since you’ll probably want the light to flash for a while if the alarm is triggered
local delay = 1

function set_switch(device,value,value1)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=value },device)
luup.call_action(“urn:dcineco-com:serviceId:MiLightRGBW1”,“SetWhiteMode”,value,device)

end

function light_on()
for i, device in ipairs(array_lights) do
set_switch(device,“1”)
end
luup.call_delay( ‘light_off’, delay )
end

function light_off()
counter = counter-1

if (luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2", "Alarm", deviceID) == "None") then

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

elseif counter > 0 then
	
	for i, device in ipairs(array_lights) do
			set_switch(device,"0")
	end
	luup.call_delay( 'light_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

light_off()

I’d try Reactor setting 4 variables to store the status at the start, then execute the actions, then execute a set to the variable settings

I think that’d work

C