AN-26091401 Email Alarm Notification
This application note configures ThinkLink to send an alarm email when temperature reaches 30°C and a recovery notification when it falls below 30°C.
1. Workflow and prerequisites
Device uplink → Thing model parser → Trigger model → ALARM RPC
├─ Raise or clear an alarm record
└─ Email group → SMTP → RecipientThe device must already report data, and its thing model must expose temperature as a number. This example uses temperature; replace it if your model uses another field such as TP. Prepare SMTP credentials, a test recipient, and permission to configure notification groups, devices, and models. A system administrator configures SMTP.
This example evaluates valid reported temperatures. It is not a device-offline rule.
2. Configure SMTP
Open System Platform → System Config → SMTP Configuration and enter the settings supplied by your email provider.
| Field | Value |
|---|---|
host | SMTP server address |
port | Port required by your provider |
secure | Match the port and provider settings; typically enabled for 465. Port 587 typically uses STARTTLS with secure disabled for the initial connection |
user | Sender account login |
pass | Password or SMTP app password, as required by the provider |
Click Submit. SMTP is shared across the deployment. If the platform already has a working email service, ask its administrator to confirm availability. Keep sender credentials out of trigger scripts.
See System Config.
3. Create an email notification group
Open Alarm Management → Notification Groups → Add.
| Field | Example or action |
|---|---|
| Id Name | ops-email |
| Name | ops-email |
| Enable | On |
| Notification method | email |
| Contacts | Actual recipient email addresses; multiple recipients are supported |
| Remark | Temperature alarm email notifications |
Use ops-email for both Id Name and Name, and use the same value in the script to avoid confusing the two fields.
New groups are disabled by default. Turn Enable on before saving. A successful save does not prove delivery; complete the alarm test below.

See Notification Groups.
4. Bind ALARM RPC to the device
Open Maintenance → Device Management → target device → Details → RPC → Add. Select the built-in ALARM RPC and save. Confirm its Method is lowercase alarm.
ALARM creates or clears an alarm and dispatches notifications to the selected groups. Its built-in script does not need editing.
5. Create and bind a trigger model
Under Model Management → Trigger Models, create a model named “Temperature alarm email notification”.
Paste the following code directly into the script editor. It is a complete function body; do not add a function trigger_script(...) wrapper.
const threshold = 30;
const notify = ["ops-email"];
const temperature = device?.telemetry_data?.[thingModelId]?.temperature;
// Missing, string, or non-finite values neither raise nor clear an alarm.
if (!Number.isFinite(temperature)) return null;
const isAlarm = temperature >= threshold;
return {
delayms: 0,
abort_previous_timer: true,
should_dispatch: true,
actions: [{
method: "alarm",
params: {
_eui: device.eui,
name: "high_temperature_email",
action: isAlarm ? "new" : "clear",
title: "[" + device.name + "] High temperature",
level: "high",
desc: isAlarm
? "Temperature is at or above " + threshold + " C. Check the device."
: "Temperature has recovered below " + threshold + " C.",
notify: notify
}
}]
};Adapt these values to your device:
| Setting | Change |
|---|---|
| Threshold | Replace threshold = 30 with the required temperature |
| Temperature field | Replace the final .temperature with the actual field, such as .TP |
| Notification groups | Replace ["ops-email"]; multiple groups can use ["ops-email", "duty-email"] |
| Alarm name | Keep high_temperature_email stable; raising and clearing must use the same name |
Save and bind the trigger model to the target device. Confirm the corresponding thing model exposes the required temperature. Creating a model or setting its thing-model constraints does not bind it to a device.
The current ALARM RPC accepts a string array in params.notify and converts it to the underlying notice_groups field. Do not use the legacy group parameter or a string containing JSON.
should_dispatch: true allows unchanged data to call the RPC; ALARM still suppresses duplicate alarms. This flow does not require additional MQTT forwarding or a wireless downlink.
For a shared script across devices, threshold and groups can instead be read from device.server_attrs.alarm_temp and device.server_attrs.notify. Confirm the threshold is a number and groups are an actual string array before enabling that version. The initial example configures both at the top of the script.
See Trigger Model and RPC Model.
6. Verify alarm and recovery delivery
Use a test device and test recipients. Report the following temperatures in sequence, checking Alarm Management → Latest Alarms, Alarm Logs, and the inbox.
| Step | Temperature | Expected result |
|---|---|---|
| 1 | 25°C | With no active alarm initially, no alarm or recovery notification |
| 2 | 31°C | Alarm created and alarm email received |
| 3 | 35°C | The same alarm remains active without another notification |
| 4 | 29°C | Alarm cleared and recovery notification received |
| 5 | 28°C | Remains normal without another recovery notification |
| 6 | 31°C | A new alarm and a new alarm email |
The example keeps the alarm name, title, level, and abnormal-state description stable so ALARM can recognize duplicates. Do not insert changing readings or timestamps into the title or description, as this can cause repeated notifications. Email appearance depends on the deployed version and recipient client.
Automatic recovery requires a later valid normal reading. Missing data, invalid numeric values, or a device that stops reporting do not clear the alarm. If readings repeatedly cross the threshold, design hysteresis or duration conditions for your application.
7. Troubleshooting
| Symptom | Checks |
|---|---|
| Temperature exceeds the threshold but no alarm appears | Telemetry field and number type, trigger binding, and ALARM RPC binding |
| Alarm exists but no email arrives | Enabled notification group, recipients, notify array, SMTP settings, and server connectivity |
| Email send error | Execution logs for authentication failure, timeout, or recipient error; provider sending limits |
| No reported error, but inbox is empty | Spam folder, corporate quarantine, and provider delivery records |
| Similar alarms keep arriving | Changing title, description, or level; readings repeatedly crossing the threshold |
| Temperature recovers but alarm remains active | A new valid normal reading, a returned clear action, and an unchanged alarm name |
Mark all as read changes only the log reading state. It does not prove device recovery, alarm clearance, or email delivery. See Alarm Management.