We have moved at community.getvera.com

Author Topic: Emergency Light  (Read 15237 times)

Offline aa6vh

  • Hero Member
  • *****
  • Posts: 642
  • Karma: +15/-0
Emergency Light
« on: January 17, 2010, 05:24:58 pm »
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

Offline lyonne

  • Sr. Newbie
  • *
  • Posts: 29
  • Karma: +0/-0
Re: Emergency Light
« Reply #1 on: January 18, 2010, 03:16:24 pm »
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... ;)
Version 1.0.996 -- Schlage Lock, WD-20 Thermostat, HSM100 and a boatload of switches and outlets.

Offline aa6vh

  • Hero Member
  • *****
  • Posts: 642
  • Karma: +15/-0
Re: Emergency Light
« Reply #2 on: January 19, 2010, 10:26:44 am »
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.

Offline myhomeserver

  • Hero Member
  • *****
  • Posts: 874
  • Karma: +3/-5
  • http://www.MyZwave.net
Re: Emergency Light
« Reply #3 on: March 22, 2011, 08:23:47 am »
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?
MyZWave.net - See Our Z-Wave product Reviews
(formerly MyHomeServer)

Offline aa6vh

  • Hero Member
  • *****
  • Posts: 642
  • Karma: +15/-0
Re: Emergency Light
« Reply #4 on: March 22, 2011, 10:13:46 am »
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.

Offline myhomeserver

  • Hero Member
  • *****
  • Posts: 874
  • Karma: +3/-5
  • http://www.MyZwave.net
Re: Emergency Light
« Reply #5 on: March 22, 2011, 02:18:01 pm »
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!
MyZWave.net - See Our Z-Wave product Reviews
(formerly MyHomeServer)

Offline aa6vh

  • Hero Member
  • *****
  • Posts: 642
  • Karma: +15/-0
Re: Emergency Light
« Reply #6 on: March 22, 2011, 05:39:03 pm »
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.

Offline myhomeserver

  • Hero Member
  • *****
  • Posts: 874
  • Karma: +3/-5
  • http://www.MyZwave.net
Re: Emergency Light
« Reply #7 on: March 22, 2011, 09:38:09 pm »
Got it working, thank you for the help!
MyZWave.net - See Our Z-Wave product Reviews
(formerly MyHomeServer)

Offline silvereagle2208

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0
Activating the Emergency Light module from a Vera scene
« Reply #8 on: April 06, 2011, 08:55:40 pm »
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?

Offline m0jon

  • Full Member
  • ***
  • Posts: 113
  • Karma: +0/-0
  • @m0jon
Re: Emergency Light
« Reply #9 on: April 07, 2011, 04:02:11 am »
Thanks for the code which works great for me. Just one question, how do you get it to stop?

Cheers

m0jon
« Last Edit: April 07, 2011, 04:04:44 am by m0jon »

Offline aa6vh

  • Hero Member
  • *****
  • Posts: 642
  • Karma: +15/-0
Re: Emergency Light
« Reply #10 on: April 07, 2011, 11:00:37 am »
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
...

Offline javene

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Emergency Light
« Reply #11 on: July 01, 2011, 04:26:50 am »
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

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: Emergency Light
« Reply #12 on: July 01, 2011, 05:00:34 am »
If I want more lights to blink, is it as simple as adding more devices comma separated?

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.

Offline Henk

  • Hero Member
  • *****
  • Posts: 820
  • Karma: +3/-0
Re: Emergency Light
« Reply #13 on: July 01, 2011, 05:33:42 am »
@futzle

*chuckle* a technical lie huh.... wonder if i dare ask ;-)

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

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.
| Vera2 @ UI4 1.1.1350 / 3.20 | Vera Lite @ UI5 | Vera 3 @ UI5 | 2x Merten  504519 | 1x Duewi  064374 | 1x Everspring SM103 doorbell mod |1 Y-cam IP cam | various LUUP plugins |

Offline ghurty

  • Sr. Newbie
  • *
  • Posts: 35
  • Karma: +0/-0
Re: Emergency Light
« Reply #14 on: August 21, 2011, 12:54:15 am »
How would I get it that it stays on when triggered again. Now it stays off.

Thanks
« Last Edit: August 21, 2011, 01:55:40 am by ghurty »