This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

“staircase function”
#1
Hello,

As a "newcomer" to LM5 as well as Lua scripting, I am struggling with a script, that features kind of a staircase function and that could be parametrised separately to implement a time-controlled lighting of a staircase or similar applications.

- The script would be triggered by a “1 bit object” originating from a motion-sensor
- The script would then dim-on the corresponding lights by sending a “1 byte object” to the dimmer
- Then the script would wait a delay time, after that it would dim down the lights by sending several decreasing values, also with some short delay in between

Well, so far, this was straight forward to implement.

Code:
value = event.getvalue()

if value==true then

  grp.write('9/1/3',100)
 
  sleep(90)

  grp.write('9/1/3',50)
 
  sleep(15)

  grp.write('9/1/3',30)
 
  sleep(3)
 
  grp.write('9/1/3',15)
 
  sleep(3)
 
  grp.write('9/1/1',false)
 
  end


Only, there would be some “extra features” needed:

a) When an another 1 bit object = 1, originating from a motion-sensor would be received during the script-execution, it should reset the initial delay time —> “staircase function” (means, restarting the script immediately)

b) When an object = 1 originating from a wall-switch would be received during the script-execution, it should stop the script, dim up the lights and disable the motion-sensor

c) When an object = 0 originating from a wall-switch would be received during the script-execution, it should stop the script, dim down the lights and disable the motion-sensor


Thank you very much.
Reply
#2
Hi,

Well there are quite some improvements to make as you can’t use event based scripts like this as they will run in parallel if you don’t take care of it.

Here is a sample to start with that already does a lot you need only needs to be modified for your dimming steps, restart and blocking is already implemented.

See: https://forum.logicmachine.net/showthrea...2#pid15442

BR,

Erwin
Reply
#3
(11.02.2020, 20:23)Erwin van der Zwart Wrote: Hi,

Well there are quite some improvements to make as you can’t use event based scripts like this as they will run in parallel if you don’t take care of it.

Here is a sample to start with that already does a lot you need only needs to be modified for your dimming steps, restart and blocking is already implemented.

See: https://forum.logicmachine.net/showthrea...2#pid15442

BR,

Erwin
Hello Erwin

Thank you very much for your quick and helpful reply, critic and valuable suggestion, which I will be happy to try out this Friday. Am I right, by assuming, that your suggested script shall run as a "Resident Script"?

KR, Boris
Reply
#4
Hi,

No you need to run it as event based attached to the input object.

BR,

Erwin
Reply


Forum Jump: