Alarms via Rule Chain
Manage alarms directly in the Edge rule chain using three dedicated rule nodes: create alarm, clear alarm, and alarm status filter. This approach gives you full programmatic control over alarm creation and clearing — based on any telemetry condition, attribute value, or custom script logic — entirely on the Edge node without a cloud connection.
When to use rule chain alarm nodes
Section titled “When to use rule chain alarm nodes”Use rule chain alarm nodes when you need logic that device profile alarm rules cannot express: conditions that span multiple telemetry keys, dynamic thresholds from attributes, or post-alarm actions (such as sending an RPC to another device). For single-key threshold alarms, device profile alarm rules require less configuration.
The pattern
Section titled “The pattern”The standard pattern for a threshold alarm in the rule chain:
Post telemetry → [Script filter: condition?] ├─ True → create alarm → Created → (act on new alarm) │ → Updated → (alarm already exists, skip) └─ False → clear alarm → Cleared → (act on cleared alarm) → False → (no alarm was active, skip)Example — temperature threshold alarm
Section titled “Example — temperature threshold alarm”This example creates a Critical alarm when temperature > 35 and clears it when the reading drops to or below 35.
Step 1 — Open the rule chain
Section titled “Step 1 — Open the rule chain”- On the Edge instance, go to Rule chains and open the Edge Root Rule Chain.
- Click Edit.
Step 2 — Add a Script filter node
Section titled “Step 2 — Add a Script filter node”- In the node panel, search for Script (under Filter) and drag it onto the canvas.
- Set the node name to
High Temp?. - Enter the condition:
return msg.temperature !== undefined && msg.temperature > 35;
- Click Add.
Step 3 — Add a create alarm node
Section titled “Step 3 — Add a create alarm node”- Search for create alarm (under Action) and drag it onto the canvas.
- Configure:
- Alarm type:
High Temperature - Severity: Critical
- Alarm details script (optional — records the triggering value):
return { temperature: msg.temperature };
- Alarm type:
- Click Add.
- Connect the True output of
High Temp?to this node.
Step 4 — Add a clear alarm node
Section titled “Step 4 — Add a clear alarm node”- Search for clear alarm (under Action) and drag it onto the canvas.
- Set Alarm type to
High Temperature(must match exactly). - Click Add.
- Connect the False output of
High Temp?to this node.
Step 5 — Wire the Script filter to the incoming message
Section titled “Step 5 — Wire the Script filter to the incoming message”- Find the existing Message type switch node in the root rule chain.
- Connect its Post telemetry output to the
High Temp?Script filter node. - Click Apply changes.
Output connections
Section titled “Output connections”create alarm
Section titled “create alarm”| Connection | When | Message after |
|---|---|---|
Created | A new alarm was created | Message replaced with alarm object; metadata: isNewAlarm: true |
Updated | Alarm of the same type already existed | Message replaced with alarm object; metadata: isExistingAlarm: true |
Failure | Script error or invalid severity | Original message unchanged |
clear alarm
Section titled “clear alarm”| Connection | When | Message after |
|---|---|---|
Cleared | Active alarm was found and cleared | Message replaced with alarm object; metadata: isClearedAlarm: true |
False | No active alarm existed | Original message unchanged |
Using the alarm status filter
Section titled “Using the alarm status filter”After a create alarm or clear alarm node, the message type changes to ALARM and the payload contains the full alarm object. Use the alarm status filter node to branch on the current alarm status before taking further action (for example, only send a notification on a genuinely new unacknowledged alarm).
Add an alarm status filter node after create alarm, configure the status set (e.g., Active Unacknowledged), and connect:
True→ send notification / RPC / push to cloudFalse→ skip
For step-by-step examples using the standalone alarm rules editor in ThingsBoard 4.3 and later, see Alarm rule tutorials.
For the full alarm management reference, see Manage alarms on Edge.