Hi All,
I’m a bit new to this so I’m probably missing something simple. I snagged mysticjay’s code from http://forum.micasaverde.com/index.php/topic,5127.0.html and used it as part of my scene. The scene works as follows:
Step #1) Device Trigger Alarm State: Alarm is active
Step #2) (Nothing)
Step #3) Run the following code:
[code]–Enter the device ID’s here in the array with your device id’s
local array_lights = {72,74}
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 (luup.variable_get("urn:schemas-micasaverde-com:device:AlarmPartition:2","Alarm", 42) == 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( '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()[/code]
I changed the code a bit so that when function tree_off is firing it is checking the alarm state first and if it sees that the alarm is turned off (“None” value?) then it changes the lights back to their original state and stops the flashing.
My goal is to flash the lights if the alarm sounds and return the lights to their previous state when the alarm stops. The code, I wrote, unfortunately doesn’t seem to be working and I could use some help debugging it. Am checking the wrong service?
Thanks in advance.