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 that you accept these cookies being set.

time/trigger script with diming over time
#1
Hi,

I want to realize based on the timer script example following function:

-the offstate is an minimum brightness level of e.g. 25% (should be adjustable with an external object)
-maximum (on state) brightness level of e.g. 90% (should be adjustable with an external object)
-time should be adjustable with an external object
-during the time counts down, each X seconds the light dims down -10% until it's on the minimum level 
-the whole function can be switch off (0% brightness)

My customer would like to illuminate an show room. The base illumination should be a brightness level of 50%. If somebody walks through the presentation the light triggers up to 95% until X seconds the motion sensors don't triggers motion again and dims the brightness level down to the default brightness of 50%.

At end of working day he completly switchs off the whole light.

Has somebody already realized such a function?
How it's the best way to handle such scripts. resident script or event based? I want to use it for up to 16 Light Circles...

Thank you forwards for any help :-)

Code:
-- maximum time that object can be on, in seconds
ontime = 4 * 60 * 60

-- current timestamp, in seconds
now = os.time()

-- get all objects with AutoOff tag
objects = grp.tag('AutoOff')

-- check all objects
for _, object in ipairs(objects) do
  -- object is on
  if toboolean(object.data) then
    delta = now - object.updatetime

    -- timer expired, turn off 
    if delta >= ontime then
      object:write(0)
    end
  end
end
Reply


Messages In This Thread
time/trigger script with diming over time - by Habib - 07.03.2017, 16:35

Forum Jump: