Rules
A rule watches tags on the Site Runtime and acts when a condition is met. It can report the match (it shows under recent matches) or write a value to a device. Rules run on the Site Runtime, next to the devices.

The page is Monitoring → Rules. Its lead reads "Watch tags on the site runtime and act when a condition is met."
How it works
- Every poll of a device group becomes one row of the table
mii_raw. The columns arenode_name(the device),group_name(the group) and the values. A tag value is read asvalues->TagName. - A rule is a SQL query over that table. Each row the query returns is one match.
- The Guided editor writes the SQL for you. The SQL editor lets you write it.
- A rule needs a name (letters, digits and
_, not starting with a digit, unique), the condition and an action. - Rules are for conditions on the live values. They do not create new tags, send to uplinks or raise alarms. For limits with acknowledgement use Alarms. Uplinks are fed by group subscriptions, not by rules.
"Recent matches" are kept by the Site Runtime in memory only. They reset when the runtime restarts.
Step by step: a guided rule
- Open Monitoring → Rules and click Add rule. The editor opens in Guided mode.
- Enter the rule name, for example
filler_too_warm. - Under When pick the Tag
line1-modbus › fast › Temperature. - Pick the operator and a value (table below). The buttons Upper normal limit and Lower normal limit take the value from the equipment's normal range.
- Optional: add up to four conditions and combine them with and or or (Combine conditions). Extra conditions must be tags of the same device group.
- Under Then pick the action (see Actions).
- Click Check. The engine says "Accepted by the engine". If the Site Runtime cannot be reached it says "Only the text was checked; the site runtime is not reachable".
- Test the rule (see Try before you start).
- Save, then use Start in the list.

Operators
| Operator | SQL | Notes |
|---|---|---|
| is above | > | |
| is at least | >= | |
| is below | < | |
| is at most | <= | |
| equals | = | Integer tags reject fractions. |
| changes | value differs from the previous poll | Cannot be used with a time window. |
| rises above | the value crosses the limit from below | A single numeric condition only. No time window. |
Numbers accept 80,5 and 80.5.
Time windows
Next to a numeric tag the option Use picks what to compare: current value, 1 min average, 5 min average, 15 min average, lowest in 1 min, highest in 1 min. A window needs a numeric tag, and it cannot be combined with several conditions, changes or rises above.
SQL mode
Switch to SQL to write the query. The hint says "Read from mii_raw. node_name and group_name identify the device and group; values->tag is the tag." Click a tag to insert it. Switching from SQL back to Guided discards your SQL edits (you must confirm).
Syntax rules:
- Strings use single quotes:
node_name = 'line1-modbus'. - A tag name that is not a plain identifier is written in backticks:
values->`Motor Current`. - Always select
node_name,group_nameand the value asresult. - Supported words include
select,from,where,and,or,not,group by,having,as,case when then else end,over,between,in,like,is null,true,false, the functionslag,avg,min,max,sum,count,cast,latest,had_changed,changed_col, and the windowsTumblingWindow,SlidingWindow,HoppingWindow.
What the Guided editor generates:
-- Temperature is above 8, with a rising-edge flag
SELECT node_name, group_name, values->Temperature AS result,
CASE WHEN lag(values->Temperature) OVER (WHEN node_name = 'line1-modbus' AND group_name = 'fast') <= 8
THEN true ELSE false END AS edge
FROM mii_raw
WHERE node_name = 'line1-modbus' AND group_name = 'fast' AND values->Temperature > 8
-- State changes
SELECT node_name, group_name, values->State AS result, true AS edge FROM mii_raw
WHERE node_name = 'line1-modbus' AND group_name = 'fast'
AND values->State != lag(values->State) OVER (WHEN node_name = 'line1-modbus' AND group_name = 'fast')
-- 5 minute average of Pressure above 3.5
SELECT node_name, group_name, avg(cast(values->Pressure, "float")) AS result FROM mii_raw
WHERE node_name = 'line1-modbus' AND group_name = 'fast'
GROUP BY TumblingWindow(ss, 300)
HAVING avg(cast(values->Pressure, "float")) > 3.5
Actions
| Action | What it does |
|---|---|
| Report the match | "Shows up under recent matches." Nothing else happens. |
| Write to a device | "Sets a writable tag when the condition is met." Fields Target (a writable tag) and Value to write. |
If no tag is writable the editor says "There is no writable tag on this runtime. Set a tag's access to write under Devices first."
How often a write repeats:
| Mode | Behaviour |
|---|---|
| "Once, each time the condition becomes true" | A rising edge. If the condition is already true when the rule starts, it waits for the next occurrence. |
| "Repeatedly while the condition holds" | The same value, at most every 10 seconds. |
In SQL mode every row the query returns is a write, repeated at most every 10 seconds. For a single write use lag() as in the example above.
Saving a write rule shows the dialog "This rule writes to a device" with <device> › <group> will be set to <value> and the button I understand, save. Rule writes obey the safe write limits and holds of the target tag. See Writes.
Examples
Filter: report a warm Filler
Report every poll in which the Filler temperature is above 8 °C.
SELECT node_name, group_name, values->Temperature AS result
FROM mii_raw
WHERE node_name = 'line1-modbus' AND group_name = 'fast' AND values->Temperature > 8
Guided: Tag Temperature, is above 8, action Report the match.
Rising edge write: slow the Filler when it gets warm
When the temperature rises above 8 °C once, write 60 to the setpoint.
Guided: Tag Temperature, rises above 8. Action Write to a device, Target line1-modbus › control › SpeedSetpoint, Value to write 60, mode "Once, each time the condition becomes true".
SQL (one write per crossing):
SELECT node_name, group_name, values->Temperature AS result,
CASE WHEN lag(values->Temperature) OVER (WHEN node_name = 'line1-modbus' AND group_name = 'fast') <= 8
THEN true ELSE false END AS edge
FROM mii_raw
WHERE node_name = 'line1-modbus' AND group_name = 'fast' AND values->Temperature > 8
The target SpeedSetpoint needs the Write attribute, and should have safe-write limits, for example 0 to 150.
Derived value: temperature in Fahrenheit
Compute a value from a tag and report it:
SELECT node_name, group_name, cast(values->Temperature, "float") * 1.8 + 32 AS result
FROM mii_raw
WHERE node_name = 'line1-modbus' AND group_name = 'fast'
A rule does not store the result as a tag. It only shows under recent matches. To keep a derived value, compute it in the consumer, or scale the tag with Decimal and Bias.
Try before you start
| Button | What it does | Writes to devices? |
|---|---|---|
| Check | Validates the SQL with the engine. | No |
| Try live | Listens for N seconds on live data. "Listening for N s…", then "No match while listening." or "N matching rows". | No |
| Try on history | Replays a guided rule over stored values from the historian. The panel title is "Try on history". | No |
Try on history answers "would have fired N times", "would not have fired" or "condition already held, no new occurrence". It also shows "condition held for time (pct%)" and a chart of the episodes. The result is approximate: it compares buckets of 1 to 600 seconds and picks the aggregate that cannot hide a match (the maximum for above, the minimum for below), so it says "Compared in N s steps using the peak value…". It needs numeric tags and the historian ("The historian is not reachable.", "No history for this tag in this range."). If a rule would fire very often it warns "Consider a time window or another limit."
Rules list
Filters: All, Running, Needs attention, Stopped. States: Running, "Running · N errors", "Stopped by engine", "Not loaded", Unknown, Stopped, "Needs rewrite" (a rule in an old dialect), "Condition missing". A row shows "Reports matches" or "Writes value to device › group", the number of matches, "last" time or "no match yet".
Buttons: Add rule, Start and Stop, Edit, Copy, Delete. "Suggested from the normal ranges of your equipment" offers starter rules.
Limits and good practice
- A rule sees one group at a time. Put tags that must be compared in the same group.
- A group's poll interval is the rule's time resolution. A 1000 ms group cannot catch a 200 ms pulse.
- Prefer rises above to is above for writes, so the rule acts once per event.
- Test with Try on history and Try live first. A write rule on a wrong threshold acts every 10 seconds.
- Put limits on every rule target (safe write).
- Rules are not an alarm system. Use Alarms for acknowledged limits.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| "Invalid SQL" | Syntax error or unknown tag. | Insert tags by clicking them. Use backticks for odd names. |
| State "Not loaded" | The Site Runtime has not loaded the rule. | Check the runtime is online, then start the rule. |
| State "Needs rewrite" | Old dialect. | Open the rule and rewrite it. |
| "Condition missing" | No condition in Guided mode. | Add one. |
| No match yet | The condition never held, or wrong group name. | Use Try live. |
| The rule writes but the value does not change | Safe-write hold, limits, or a protocol that refuses writes. | See Writes. |
| "Try on history" says no history | The tag is not numeric or not bound. | Bind the tag to equipment. |