Skip to content

Custom Alarms

A custom alarm defines its condition as a JavaScript expression. The alarm is ON while the expression returns a truthy value and OFF when it returns a falsy one.

Analog and digital alarms watch a single variable. A custom alarm is for when the condition depends on several variables, or on a calculation.

The fields every alarm carries (name, groupId, delay, part, isActive, …) are listed on Alarm Management.

The custom alarm form — the condition field

// Alarm when power and temperature are high together
var power = ins.getVariableValue("ActivePower_kW").value;
var temp = ins.getVariableValue("Temperature_C").value;
return power > 500 && temp > 70;

The expression runs on the group’s scanTimeInMillis period, so it should not do heavy work — it is re-evaluated on every scan.

SituationWhy
The condition depends on more than two variablesA digital alarm combines at most two
The comparison is between two variablestank1 > tank2 rather than a fixed limit
A derived quantity is being watchedEfficiency, differential pressure, a ratio
The condition mixes a threshold with logic“Temperature high and pump running”

If the condition is just one variable against a fixed threshold, prefer an analog alarm: the thresholds are visible as fields, deadband and deviation come ready-made, and the condition is evaluated without running a script every scan.

Likewise, combining two boolean signals with AND/OR, or inverting one, needs no custom alarm — a digital alarm offers both as fields.

For writing expressions and the methods available: Expressions · Alarm API