Scene should run only once

When I trigger a scene multiple times it runs multiple times. How can I avoid this and let it run only once at the same time? Maybe until return true / false happens.

Thanks for any input.

You could use a global variable as a lock-out flag. At the start of the scene Lua code, check the flag and, if it is on, return. If the flag is off, turn it on and proceed with the rest of the code. Turn the flag off when the code completes.

To avoid problems if a restart occurs while the scene is running, reset the flag to off in Startup Lua.

If you need to do this with a scene controller dedupe…I know you can detect multiple presses in Lua based on previus forum. I can’t find the exact one with my searching. This post shows you how to trap the second key press, and essentially you can have no function for that second key press.
http://forum.micasaverde.com/index.php?topic=10447.0

PLEG has more samples as it deals with sequences and time stamps easily.

If you trigger a scene directly (not from another trigger like a switch or scene controller), than you must use solution that Rex described (which is new to me)

Thanks, I use a virtual switch to avoid other scenes to run at the same time. Basically this should also avoid itself to run, but the scene goes crazy if I retrigger it.

I think I will try PLEG as a trigger filter.

If you use a VirtualSwitch as a lockout flag, there will be a delay while the action is queued and performed. If the trigger occurs during this period, the scene will be run again. I suggested using a global variable because it will be set (and can be read) instantly.

That could be the solution for my issues thanks.

So global variables are never reset? Why do people use the variable container plugin? Just for visualisation?

Thanks again I wasn’t aware of this delay.

The value of Global variables are lost when Vera Restarts.
That’s why you use Variable Container.

So global variables are never reset?

As RTS pointed out, they don’t exist after a restart until they are defined. If you test at the start of your scene for the lockout variable being true, you would not need to explicitly reset it at startup. A non-existent variable will have a value of nil which is not true. The first time you set it to true it will exist.