7. Send Alarm Email Notifications in atvise SCADA

Created by Ybone Hernandez, Modified on Tue, 28 Oct at 5:19 PM by Agent Aaron Camacho

In many SCADA applications, it's essential to alert operators immediately when an alarm is triggered.

atvise SCADA allows you to send automatic email notifications whenever a specific alarm condition occurs.


This example shows how to configure an SMTP server, attach a script to an alarm, and automatically send an email notification when the alarm is activated.


✅Steps


  1. Add SMTP Server
  2. Create a Modification Script:
    • Create a script that handles the email notification.
    • Copy and paste the example code (adjust recipients, subject, and message content as needed).
    • This script will be triggered whenever the alarm condition changes to active.
  3. // Alarm Object (alarm)
    var text = "Alarm Subject";
    var node  = alarm.InputNode;
    var status  = alarm.ActiveState.en;
    var value  = alarm.value;
    var desc  = alarm.eventtext.en;
    //var time  = new Date(alarm.activetime).toISOString().slice(0,19).replace('T', ' ');
    
    var timestamp = new Date(alarm.activetime);
    
    const options = {
      timeZone: 'America',
      hour12: false,
      hour: 'numeric',
      minute: 'numeric',
      second: 'numeric'
    };
    
    const time = timestamp.toLocaleString('en-US', options)
    
    
    
    if (alarm.ActiveStateId == true) { 
       var alarmtext = desc + " of "+nodeF[0]+" with status "+status+ " and activation value of  " +value+ " at " +time;
      
      call("SYSTEM.LIBRARY.ATVISE.SERVERSCRIPTS.Mail.SendMail", {
        smtpserver: "test", // SMTP server configured previously
        from: "example@gmail.com",
        to:"example@gmail.com",
        subject: text,
        body: alarmtext
    })


  4. Attach the Script to the Alarm Condition:

    • Go to your alarm configuration in atvise.
    • Set the modification script to the specific alarm.
    • When the alarm is triggered, the system will automatically execute the script and send the email.
       
  5. Test the Configuration:

    • Trigger the alarm condition manually or simulate it.
    • Check the email inbox of the recipient.
    • You should receive an alarm notification almost instantly.


Example Reference


You can also test this feature using the atvise Live Example available in atvise live under Scripting section.




Tip


For production environments, use a dedicated SMTP account and make sure your firewall allows outbound traffic on the required port (e.g., 465 or 587 for Gmail).




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article