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.

Controlling Temp with timer
#1
Hi all,

I am monitoring water temperature with LM and KNX, but I need send email when current temperature is higher than "max limit" during one period of time (e.g. 60 min).

Anyone could help me? Thanks
Reply
#2
Create an event script mapped to temperature object:
Code:
temp = event.getvalue()

curr = temp > 22
prev = storage.get('temp_over')

if curr ~= prev then
  if curr then
    storage.set('temp_time', os.time())
    storage.set('temp_notified', false)
  end

  storage.set('temp_over', curr)
end

Then create a scheduled script that runs every minute to check whether e-mail needs to be sent. Change delta time if needed (60 * 60 = 1 hour in seconds).
Code:
curr = storage.get('temp_over')
notified = storage.get('temp_notified')
if curr and not notified then
  now = os.time()
  time = storage.get('temp_time', now)

  delta = now - time
  if delta > 60 * 60 then
    -- send email
    storage.set('temp_notified', true)
  end
end
Reply
#3
(15.03.2019, 08:05)admin Wrote: Create an event script mapped to temperature object:
Code:
temp = event.getvalue()

curr = temp > 22
prev = storage.get('temp_over')

if curr ~= prev then
 if curr then
   storage.set('temp_time', os.time())
   storage.set('temp_notified', false)
 end

 storage.set('temp_over', curr)
end

Then create a scheduled script that runs every minute to check whether e-mail needs to be sent. Change delta time if needed (60 * 60 = 1 hour in seconds).
Code:
curr = storage.get('temp_over')
notified = storage.get('temp_notified')
if curr and not notified then
 now = os.time()
 time = storage.get('temp_time', now)

 delta = now - time
 if delta > 60 * 60 then
   -- send email
   storage.set('temp_notified', true)
 end
end

Thank you very much!! Script works perfectly on my LM. Is there any handbook or manual to learn advanced scripts in LUA???
Reply
#4
Common LM/Lua functions are documented: http://openrb.com/docs/lua.htm

As for more advanced things, have a look at example in forums and on our website. There are some many possible solutions and approaches that it's just not possible to document them.
Reply
#5
Hello,
This function is very useful.
I use it to check a temperature for 5 minutes if it goes above 23 ° C so I send an email.
If possible, I would like to send an email when the temperature drops below 23 ° C.
This email must be sent only after a temperature fault and not every time the temperature is below 23 ° C.
thank you. B. R.
Reply
#6
Event script:
Code:
temp = event.getvalue()

curr = temp > 23
prev = storage.get('temp_over')

if curr ~= prev then
  storage.set('temp_time', os.time())
  storage.set('temp_notified', false)
  storage.set('temp_over', curr)
end

Scheduled script:
Code:
notified = storage.get('temp_notified')
if not notified then
  curr = storage.get('temp_over')
  
  now = os.time()
  time = storage.get('temp_time', now)
  delta = now - time
  
  if delta > 5 * 60 then
    if curr then
      text = 'temp over limit'
    else
      text = 'temp under limit'
    end

    -- send email
    storage.set('temp_notified', true)
  end
end
Reply


Forum Jump: