12.11.2024, 10:19
Hello
Here will be two event scripts
first - mode script
second - lux script
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