Notification API
Notification API sends web notifications, email and SMS to platform users from scripts. All three are addressed by platform usernames (username[]) — the actual email address / phone number comes from the user’s profile.
Web Notifications
Section titled “Web Notifications”ins.notify(type, title, message)
Section titled “ins.notify(type, title, message)”Pushes a web notification to every connected UI client (webix clients); it appears as a popup in the interface.
ins.notify("info", "Shift", "Shift change complete");type | Appearance |
|---|---|
"info" | Info (blue) |
"success" | Success (green) |
"warning" | Warning (yellow) |
"error" | Error (red) |
var temp = ins.getVariableValue("Temperature_C").value;if (temp > 60) { ins.notify("warning", "Temperature warning", "Panel temperature " + temp + "°C — limit 60°C");}ins.sendMail(usernames[], subject, content)
Section titled “ins.sendMail(usernames[], subject, content)”Sends a plain text email to the given platform users.
ins.sendMail( ["operator1", "supervisor"], "Daily report", "Today's total production: 1250 kWh");ins.sendMail(usernames[], subject, content, htmlContent)
Section titled “ins.sendMail(usernames[], subject, content, htmlContent)”Sends a multipart/alternative email — both the plain text body (content) and the HTML body (htmlContent) travel in the same message; the email client shows whichever it supports.
var power = ins.getVariableValue("ActivePower_kW").value;var voltage = ins.getVariableValue("Voltage_V").value;
var textBody = "Energy Report\n" + "Active Power: " + power + " kW\n" + "Voltage: " + voltage + " V\n";
var htmlBody = "<h2>Energy Report</h2>" + "<table border='1' cellpadding='6'>" + "<tr><td>Active Power</td><td>" + power + " kW</td></tr>" + "<tr><td>Voltage</td><td>" + voltage + " V</td></tr>" + "</table>";
ins.sendMail(["manager"], "Energy Report", textBody, htmlBody);ins.sendSMS(usernames[], message)
Section titled “ins.sendSMS(usernames[], message)”Sends an SMS through the platform’s default SMS provider.
ins.sendSMS(["oncall_engineer"], "ALARM: Transformer temperature critical!");ins.sendSMS(usernames[], message, provider)
Section titled “ins.sendSMS(usernames[], message, provider)”Sends via a specific SMS provider (if multiple are configured).
ins.sendSMS(["operator"], "Maintenance reminder", "NetGSM");Example: Multi-Channel Critical Alarm
Section titled “Example: Multi-Channel Critical Alarm”function main() { var temp = ins.getVariableValue("TransformerTemp_C").value; if (temp < 85) return;
var msg = "Transformer temperature: " + temp + "°C — limit 85°C";
// 1) Instant UI notification for everyone ins.notify("error", "Critical temperature", msg);
// 2) SMS to on-call staff ins.sendSMS(["oncall_engineer", "shift_supervisor"], msg);
// 3) Rich email to management var html = "<h3 style='color:#c0392b'>Critical Temperature</h3>" + "<p>" + msg + "</p>" + "<p>Time: " + ins.now() + "</p>"; ins.sendMail(["plant_manager"], "[CRITICAL] Transformer Temperature", msg, html);
ins.writeLog("ERROR", "TempWatch", msg);}main();