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.

Send notification email after change value (delay)
#1
Hello,
I have simple Event-based script (in SL) who sends an email when the status changes in a particular group. This code works pretty well, however I have two questions:
1. Why script works even when the status has not changed. For example, the controller performs a daily scan - and at that time scripts work and send a notification. (status has not changed). How to fix it?
2. How can I put a delay on sending notifications? This means, if the particular group status has switched and is unchanged for 10 seconds, then only send a notification.


Code:
value = event.getvalue()
mydata = storage.get('myobjectdata', 2)
if value then
  if value ~= mydata then
    --email for ON (1)
    subject = 'Main switch = ON'
message = '\nState: Normal'
  mail('1234@yyyyyyy.ww', subject, message) 
  end
else
 
  if value ~= mydata then
   --email for OFF (0)
    subject = 'Main switch = OFF'
message = '\nState: ALARM!!'
    mail(' 1234@yyyyyyy.ww ', subject, message)
  end
end 
storage.set('myobjectdata', value)


Thank you.
Reply


Messages In This Thread
Send notification email after change value (delay) - by Krists - 15.10.2024, 13:36

Forum Jump: