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 help
#1
Hello,

Could you please help me with one resident script?

If the temperature is below "A" for more then "B" seconds/ minutes turn on 1/1/2. If the temperature is above C for more then "D" seconds/minutes turn off 1/1/2

We have temperature with address 1/1/1.
Reply
#2
Modify as needed, make sure that step value is the same as script sleep time (at least 5 seconds, can be more if the wait time is larger).
Code:
temp = grp.getvalue('1/1/1')

-- temp limits
temp_low = 20
temp_high = 30

-- time in seconds
time_low = 20
time_high = 40

step = 5 -- script sleep time in seconds

if temp < temp_low then
  timer_high = nil

  if timer_low then
    if timer_low < time_low then
      timer_low = timer_low + step

      if timer_low >= time_low then
        grp.write('1/1/2', true)
      end
    end
  else
    timer_low = 0
  end
elseif temp > temp_high then
  timer_low = nil

  if timer_high then
    if timer_high < time_high then
      timer_high = timer_high + step

      if timer_high >= time_high then
        grp.write('1/1/2', false)
      end
    end
  else
    timer_high = 0
  end
end
Reply
#3
(20.09.2021, 10:52)admin Wrote: Modify as needed, make sure that step value is the same as script sleep time (at least 5 seconds, can be more if the wait time is larger).
Code:
temp = grp.getvalue('1/1/1')

-- temp limits
temp_low = 20
temp_high = 30

-- time in seconds
time_low = 20
time_high = 40

step = 5 -- script sleep time in seconds

if temp < temp_low then
  timer_high = nil

  if timer_low then
    if timer_low < time_low then
      timer_low = timer_low + step

      if timer_low >= time_low then
        grp.write('1/1/2', true)
      end
    end
  else
    timer_low = 0
  end
elseif temp > temp_high then
  timer_low = nil

  if timer_high then
    if timer_high < time_high then
      timer_high = timer_high + step

      if timer_high >= time_high then
        grp.write('1/1/2', false)
      end
    end
  else
    timer_high = 0
  end
end

Thank you very much!
Reply


Forum Jump: