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.

Script Guidance - Auto / On / Off, Lux Condition
#2
Hello

Here will be two event scripts
first - mode script

Code:
local mode = event.getvalue()

local output_addr = '0/0/4'

if mode == 0 then
  grp.write(output_addr, false)
elseif mode == 255 then
  grp.write(output_addr, true)
end

second - lux script

Code:
local lux = event.getvalue()

local delay = 3 -- seconds

local mode_addr = '0/0/1'
local lux_addr = '0/0/2'
local setpoint_addr = '0/0/3'
local output_addr = '0/0/4'

local mode = grp.getvalue(mode_addr)
local setpoint_lux = grp.getvalue(setpoint_addr)

if mode == 127 then
  if lux < setpoint_lux then
    grp.write(output_addr, true)
  elseif lux > setpoint_lux then
    os.sleep(delay)
   
    lux = grp.getvalue(lux_addr)
    setpoint_lux = grp.getvalue(setpoint_addr)
    if lux > setpoint_lux then
      grp.checkwrite(output_addr, false)
    end
  end
end
Reply


Messages In This Thread
RE: Script Guidance - Auto / On / Off, Lux Condition - by RomansP - 12.11.2024, 10:19

Forum Jump: