understand luup logic

Hi all.

i’m new to lua and i wonder if this logic would work on vera, eventhough it might keep scene active for hours

basically, i have a scene that is triggered by a sensor

and the luup i have in luup box is ( this is pseudo code)

sensor = – sensor’s trip variable —

while (sensor is tripped) do

     do something.. 
     if ( comparison) then
          do something..
     is sensor stil Tripped?


end scene’s luup

You do no want to run anything long in a scene. Lua is not multi threaded. You might want to look into pleg.

  • Garrett

A possible alternative is to schedule the scene to run every minute and do what you need in short bursts…

so to schedule the scene run every period of time. i found the luup.call_timer.

function: call_timer
parameters: function_name (string), type (number), time (string), days (string), data (string)

what is data(string) in this case?

is it still safe to do this in scene. create scene that will be triggered by sensor

luup.call_timer(“function”, 1, 6m, ? ,?) – this would keep calling the function every 6mins rite?

do something


If you tell us what you want to do, we may be able to offer you a solution. Have you looked at pleg plug in? Vera will kill anything that takes longer than 60 to complete. Scenes are meant to run their tasks and complete in a short time.

  • Garrett


i looked at PLEG and yes, it is an every good plug in for vera. however, i try to do with lua code.

what i try to do is writing a closing scene for garage door. the scene would be triggered when garage door is open (door sensor is tripped). it would check for sensors in garage door and if no motion is detected for period of time and garage door has been opened for period of time then vera would issue close to garage door. during closing, if motion is detected by sensors. then action would be canceled and start all over again until garage door closed

This can be done with pleg and there is already a thread / posts about doing this.

Have a look at this for some direction:




There are a few other posts that can be found if you search for “pleg garage”. RichardTSchaefer the creator of the pleg plugin can also provide you some help and incite.

  • Garrett

yes. i read those before. and now i try to do using luup code.

You can not do what you want via luup in a scene. Long running tasks will be killed if they run longer than 60 seconds. If you are set on running it via a scene, you can create a scene to run at an interval and have it check the status of the sensor and perform your action.

  • Garrett