Emergency Light

When emergency services (fire/ambulance/police) are responding to a call in an urban setting, time can be wasted by the responders having to search for the correct address, especially at night. If you are the one having the emergency, you can direct them to your house by causing your porch light to blink. The blinking light draws them in, saving precious time, which in some types of emergencies, that time can be the difference between life and death.

You can get Vera to blink your porch light, using the LUA code. I created a Vera scene, which has the below LUA code associated with it. I then programmed some of my scene controllers to envoke my “emergency” Vera scene.

A couple of notes on the code. My porch light is device 19. The third parameter of call_timer is the time (in seconds), and I am specifying a 1 second interval (for further informaton on the call_timer function, refer to the Wiki). And most importantly, there must be a way to stop the blinking once started (besides power cycling Vera). The LUA code is written so that if the scene is envoked a second time, the “sBlink” global variable gets reset, indicating to stop the cycle. One other suggestion is to not use CFL (florescent) bulbs in your porch fixture that will be blinked, as CFLs do not like to be blinked.

The LUA code:

function DipOnPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },19)
if (sBlink == “1”) then
luup.call_timer(“DipOffPorchLight”, 1, “1”, “”, “”)
end
end
function DipOffPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },19)
if (sBlink == “1”) then
luup.call_timer(“DipOnPorchLight”, 1, “1”, “”, “”)
end
end
if (sBlink == “1”) then
sBlink = “0”
else
sBlink = “1”
luup.call_timer(“DipOffPorchLight”, 1, “1”, “”, “”)
end

I tried it and the code worked great. However, my intermatic switches have a long ramp up and ramp down, so the lights don’t really flash. They kind of have a dim throb. I’ll either see if I can change the ramp rate or rename my scene from “Emergency” to something else… :wink:

Try increasing the timer interval (its the third parameter in call_timer, and is the “1” in quotes). Even a slower blink should get attention.

Im trying to get this code to work on a GE Appliance switch, but no go. Any ideas? My device ID is #99 and I’ve tried everything but not sure why it’s not working

Any other ideas?

When you say it is not working, how is it not working. Does the light come on but not blink, or no light at all.

I would double check that you are using the correct Device ID for that module.

Also check your syntax. A misspelling can cause the LUA code to not run at all.

Thanks, I’ll triple check everything and make sure I cut, copied and pasted properly and changed the device ID properly. I get no light at all when I attempt to run in a scene with this code in the luup tab. I also tried putting this in the developer sandbox luup test code area and that said bad device. I’ll play with it more and post an update. thanks for the help and code!

Another thing to try is to increase the time interval. I would temporarily change the time interval to something like 60 seconds, just to see if it starts working. If it does start working, you can then reduce the time until you get the effect you want.

The timer interval in the code above is set for 1 second, and is the third parameter of the Call Timer (the “1” in quotes). Change the “1” to “60” to get 60 seconds.

I could invision that 1 second may not be enough time to allow the relay within to applicance module to flop over.

Got it working, thank you for the help!

At present it appears that the Emergncy Light module is activiated and terminated by means of buttons on a scene controller. Have you any ideas regarding how to activate and terminate the module from a Vera scene that is activated by means of triggering a motion sensor?

Thanks for the code which works great for me. Just one question, how do you get it to stop?

Cheers

m0jon

The scene is coded that if the scene is run a second time, the “sBlink” variable will get reset. The next iteration of the timed functions will detect that the variable is reset, and stop the sequence.

Thats why this code snippet exists in the main part of the lua code:

if (sBlink == “1”) then
sBlink = “0”
else

Hello!
Thank you for a great scene script!

If I want more lights to blink, is it as simple as adding more devices comma separated?

Like this:
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },19,25,43,44)

Regards

No, you have to repeat the entire line, changing the device number each time.* Put each on its own line, or put semicolons between each statement.

  • This is technically a lie. Ask me about writing loops in Lua when you’re ready.

@futzle

chuckle a technical lie huh… wonder if i dare ask :wink:

No, you have to repeat the entire line, changing the device number each time.* Put each on its own line, or put semicolons between each statement.

  • This is technically a lie. Ask me about writing loops in Lua when you’re ready.[/quote]

How would I get it that it stays on when triggered again. Now it stays off.

Thanks

[quote=“ghurty, post:15, topic:165392”]How would I get it that it stays on when triggered again. Now it stays off.

Thanks[/quote]

Try this:

function DipOnPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },19)
if (sBlink == “1”) then
luup.call_timer(“DipOffPorchLight”, 1, “1”, “”, “”)
end
end
function DipOffPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },19)
if (sBlink == “1”) then
luup.call_timer(“DipOnPorchLight”, 1, “1”, “”, “”)
end
end
if (sBlink == “1”) then
sBlink = “0”
luup.call_timer(“DipOnPorchLight”, 1, “2”, “”, “”)
else
sBlink = “1”
luup.call_timer(“DipOffPorchLight”, 1, “1”, “”, “”)
end

I have tried and this works perfectly and the modification to change the interval so that you could set how common they would blink would be great as well.

I think with the lua code, you can set it to blink like a porch light and through a created and establish vera scene, it would be able to associate with it so that it will function as described when chosen as an emergency scene.

[quote=“ghurty, post:15, topic:165392”]How would I get it that it stays on when triggered again. Now it stays off.

Thanks[/quote]

It seems to work the other way round for me. I just added this blink code to one of my burglar alarm scenes. Now when the burglar alarm is tripped by a door contact sensor the porch light start blinking as well, this works good! However when I run my Cancel burglar alarm scene that runs the Emergency porch light scene again i.e to cancel the blinking the porch light then remains on. I’d like it to remain off when I run the blink code again.

The code presented above was designed to leave the light on when the blinking is cancelled. You can instead change it to leave the light off by changing the fifith statement from the end from:

luup.call_timer(“DipOnPorchLight”, 1, “2”, “”, “”)

to:

luup.call_timer(“DipOffPorchLight”, 1, “2”, “”, “”)

When I set this up it worked perfectly… (I changed the fifth line from the bottom for the light to left turned off). However, now my actual light switch device will flash if I just turn it on by itself. The only way I can get it to turn off is to run the emergency scene (to make the timers know it is flashing) and then run it again (as if I’m turning off the emergency). In other words, I can’t make my light run on the regular timer schedule now at all.

Any suggestions?