Logic Machine Forum
Send a Email when a New alert occurs - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Send a Email when a New alert occurs (/showthread.php?tid=3778)



Send a Email when a New alert occurs - Jonas S - 28.12.2021

Hello.

I'm sure this i already posted but I just couldn't find it. 

Is it possible to send an Email when a new alerts occurs. I could imprent it in every script but it just seams alot of extra work if there is a solution. 

If I was to include it in a every script, how do I get the value included in the email also. 



This ofcourse dosen't work but what will? 
temperature = event.getvalue()
subject = 'Vestis Gerby Alarm'
message = 'Vestis Gerby Alarm ', temperature
mail('table', subject, message)


RE: Send a Email when a New alert occurs - admin - 28.12.2021

You can create a custom function and place it into Common functions. Then this function can be used in all script.
Code:
function mailalert(subject, message)
  mail({ ... }, subject, message)
  alert(message)
end

Event script:
Code:
temperature = event.getvalue()
subject = 'Vestis Gerby Alarm'
message = 'Vestis Gerby Alarm ' .. temperature
mailalert(subject, message)



RE: Send a Email when a New alert occurs - Jonas S - 29.12.2021

(28.12.2021, 08:33)admin Wrote: You can create a custom function and place it into Common functions. Then this function can be used in all script.
Code:
function mailalert(subject, message)
  mail({ ... }, subject, message)
  alert(message)
end



Thanks, now I get emails Smile
It's just the alerted function stoped working, what am I missing? 

temperature = event.getvalue()
setpoint = 68
alerted = storage.get('alerted')
if temperature >= setpoint then
  if not alerted then
      mailalert('Vestis Gerby', 'Kayttovesi Lahto Lampotila Korkea Ouman ' .. temperature)
    storage.set('alerted', true)
  end
else
  storage.set('alerted', false)
end