Restricting a scene to run once in a time period

??? Brain game of the day:

I have a scene for my garage door that runs a dry contact relay connected to the garage door switch. It does the following:

on
wait 1 second
off

This emulates a push of the garage door button. It works great every time when run from the web interface.

I also have a Aeon Zwave key-FOB. when i press the button on the key-FOB sometimes I get the equivalent of 2 presses which runs 2 scenes one after another. Maybe I am at the edge of the range of operation, or the button gets actually pressed twice (they are tiny). anyway, the effect is that the garage door stops half way up or down. very dangerous when my wife is backing out of the garage!!

What I want to do is write some Luup that restricts the scene to run only once say in a 5 second period. I think that would solve the problem. can I do something like that?

Any other ideas?

Place the following code into the scene Luup. It notes the last time it was run in the global variable tLastOnD99 and only runs the scene if at least 5 seconds has elapsed.

local tNow = os.time() local tLastOn = tLastOnD99 or 0 tLastOnD99 = tNow return ((tNow - tLastOn) > 5)

Change the 99 in tLastOnD99 to be the device ID of your relay in case you use this code for another device.

Thanks,

Works perfectly now!

I made one little tweak to the code. as written above, if someone continuously presses the button every 3 seconds it will only work once since tLastOnD99 is updated regardless of whether the 5 seconds requirement was meet or not. I moved the update of tLastOnD99 into the conditional so that it only updates when the the elapsed time is greater than 5 seconds.

Thanks again for the help!!

You also might want to look into a fibaro relais. Since the vera is not reliable to send the second command.

The fibaro relais you can programm that it stays on (after pressing it) , but switches itself off after the programmed time. Which is offcourse the most reliable you can get. I have this setup for my garage door and gate.

There are several topics about this , how to programm the relais.

Cor

Thanks for the info, I will look into them.