HI Bergman
I am not sure that it is exactly what you need, but have a try,
and please give me feedback.
This code is for humidity scale object (event script).
Regards,
Romans
Here is updated version of the script.
I am not sure that it is exactly what you need, but have a try,
and please give me feedback.
This code is for humidity scale object (event script).
Code:
local humidity = event.getvalue() -- scale object
local fan_addr = '38/1/26' -- scale object
local fan_val_level_1 = 30 -- values for scale object
local fan_val_level_2 = 60
local fan_val_level_3 = 100
if humidity < 33 then -- humidity less than 33%
grp.write(fan_addr, fan_val_level_1)
elseif humidity > 38 and humidity < 66 then -- 38% < humidity < 66%
grp.write(fan_addr, fan_val_level_2)
elseif humidity > 71 then -- humidity more than 71%
grp.write(fan_addr, fan_val_level_3)
end
Regards,
Romans
Here is updated version of the script.
Code:
local humidity = event.getvalue() -- scale object
local fan_addr = '38/1/26' -- scale object
local fan_val_level_1 = 30 -- values for scale object
local fan_val_level_2 = 60
local fan_val_level_3 = 100
local hyst = 5 -- 5% humidity hysteresis
local hum_level_1 = 33 -- 33% humity
local hum_level_2 = 66 -- 66% humidity
if humidity < hum_level_1 then -- humidity less than 33%
grp.write(fan_addr, fan_val_level_1)
elseif humidity > hum_level_1 + hyst and humidity < hum_level_2 then -- 38% < humidity < 66%
grp.write(fan_addr, fan_val_level_2)
elseif humidity > hum_level_2 + hyst then -- humidity more than 71%
grp.write(fan_addr, fan_val_level_3)
end