Skip to content
Stand with Ukraine flag

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.

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 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)

This example creates a Critical alarm when temperature > 35 and clears it when the reading drops to or below 35.

  1. On the Edge instance, go to Rule chains and open the Edge Root Rule Chain.
  2. Click Edit.
  1. In the node panel, search for Script (under Filter) and drag it onto the canvas.
  2. Set the node name to High Temp?.
  3. Enter the condition:
    return msg.temperature !== undefined && msg.temperature > 35;
  4. Click Add.
  1. Search for create alarm (under Action) and drag it onto the canvas.
  2. Configure:
    • Alarm type: High Temperature
    • Severity: Critical
    • Alarm details script (optional — records the triggering value):
      return { temperature: msg.temperature };
  3. Click Add.
  4. Connect the True output of High Temp? to this node.
  1. Search for clear alarm (under Action) and drag it onto the canvas.
  2. Set Alarm type to High Temperature (must match exactly).
  3. Click Add.
  4. 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”
  1. Find the existing Message type switch node in the root rule chain.
  2. Connect its Post telemetry output to the High Temp? Script filter node.
  3. Click Apply changes.
ConnectionWhenMessage after
CreatedA new alarm was createdMessage replaced with alarm object; metadata: isNewAlarm: true
UpdatedAlarm of the same type already existedMessage replaced with alarm object; metadata: isExistingAlarm: true
FailureScript error or invalid severityOriginal message unchanged
ConnectionWhenMessage after
ClearedActive alarm was found and clearedMessage replaced with alarm object; metadata: isClearedAlarm: true
FalseNo active alarm existedOriginal message unchanged

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 cloud
  • False → 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.