I stumbled across this from another thread, should do what I am looking for.
Will test out this evening:
[quote=“biggsworld, post:26, topic:167189”]I wanted to update this thread since there didn’t seem to be any others that met my specific criteria - you can certainly use this for alarms or any purpose you need.
In my case I installed a door sensor in my mailbox so it would tell me when the mail had arrived. (I know - but it’s fun to tinker with!) My specific needs were to blink a light and then return that light to it’s original setting - this is for notification only.
I cleaned up the code a little from the early posts and made it a little easier to follow. I re-edited since I found a minor bug - If you have too many lights to blink, it fails because the previous z-wave command hasn’t completed before the next gets sent. I added a delay (adjustable - set to 1 second now) to wait between sending zwave commands. That seems to work much better in a busy zwave network.
Here’s my updated code for your use.
[CODE]
–Enter the device ID’s here in the array with your device id’s
– 4 - Stair lights
– 19 - kitchen pendant
– 60 - bedroom lamp
– 69 - LR lamp 3
local array_lights = {4,19,60,60}
local original_status={}
– loopspeed is the timeout between sending commands
local loopspeedms = 1000
– counter is the number of times to blink
local counter = 5
– delay is the number of seconds to wait between switching off-> on, and on->off
local delay = 1
– sleep() takes milliseconds not seconds - so we do the math here
local delayms = delay * 1000
function set_switch(device,value)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=value },device)
end
– Turn all the switches in the array ON
function switch_on()
for i, device in ipairs(array_lights) do
set_switch(device,“1”)
luup.sleep(loopspeedms)
end
– Run a delay and then call switch_Off which turns them all back off.
– luup.call_delay( ‘switch_off’, delay )
end
– Turn off all the switches in the array
– This is only a stub - does not call switch_on
function switch_off()
for i, device in ipairs(array_lights) do
set_switch(device,“0”)
luup.sleep(loopspeedms)
end
end
– Main program
– Loop over the array “counter” times, with “delay” between loops.
function switch_run()
while counter > 0 do
counter = counter-1
switch_on()
luup.sleep(delayms)
switch_off()
luup.sleep(delayms)
end
--Set to original status
for i, device in ipairs(array_lights) do
set_switch(device,original_status[i])
end
end
– Program run starts here
–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
switch_run()
[/CODE][/quote]