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.

Help with timer/time in LUA script
#3
Create a scheduled scripts that runs every minute.
Change group addresses as needed:
1/1/1 - mode (2 = auto)
1/1/2 - forecast (true/false)
1/1/3 - temperature value
1/1/4 - output control

To simplify things the output will turn on at 0 minutes of every hour if needed and will turn off after X minutes depending on the current temperature.
Code:
mode = grp.getvalue('1/1/1')
if mode ~= 2 then
  return
end

forecast = grp.getvalue('1/1/2')
temperature = grp.getvalue('1/1/3')
if not forecast or temperature > 4 then
  offtime = 0
-- 0..4
elseif temperature >= 0 then
  offtime = 25
-- -4..0
elseif temperature >= -4 then
  offtime = 35
-- -8..-4
elseif temperature >= -8 then
  offtime = 50
-- lower than -8
else
  offtime = 60
end

min = os.date('*t').min
value = min < offtime
grp.checkwrite('1/1/4', value)
Reply


Messages In This Thread
RE: Help with timer/time in LUA script - by admin - 26.10.2020, 11:43

Forum Jump: