Expression Tags
Expression tags compute their value from a formula evaluated by the Expression Evaluator service. Expressions can reference tags, devices, AI models, and model bindings, use arithmetic and logical operators, and call built-in math and statistical functions.
Expressions are evaluated in one of two ways:
- Reactive — when any referenced tag's value changes, the expression re-evaluates immediately (within milliseconds). This is the default when the expression references at least one tag value.
- Timer-based — if the expression has no reactive tag dependencies (e.g. it only references device or model status), it evaluates on a configurable interval set by the Evaluation Rate field.
Common use cases include:
- Unit conversions (e.g. Celsius to Fahrenheit)
- Scaling raw signals (e.g. 4–20 mA to 0–100%)
- Averaging multiple sensors
- Smoothing noisy readings with time-aware filters
- Computing rate of change for trend detection
- Status-based fallback logic (switch to backup sensor if primary fails)
- Alarm thresholds with deadband filtering
- Health monitoring (react to device or model failures)
References
Type @ in the expression editor to search and insert a reference. The autocomplete menu shows tags, devices, AI models, and model bindings — each with the fields you can reference.
Tag References
Reference a tag's live value, status, or error code:
Tag value references are reactive — the expression re-evaluates immediately when the referenced tag's value changes.
Device References
Reference a device's connection status or error code:
Device references are useful for building failover logic — for example, switching to a backup device's tags when the primary device goes down.
Model References
Reference an AI model's status or error code:
Binding References
Reference the raw prediction value from a model output binding:
Binding value references give you access to a model's prediction output without needing an in-memory tag to historize it first.
Arithmetic Operations
Standard math operators are supported:
Comparison Operations
Comparisons return True or False and are commonly used inside conditional expressions:
Logical Operations
Combine conditions with and, or, and not:
Math Functions
Built-in math functions for common calculations:
Statistical Functions
Functions that operate on lists of values:
Filter Functions
Filter functions smooth, transform, or gate input signals. They maintain internal state across evaluations, so each call remembers its previous output.
filter — Exponential Moving Average
filter(value, tau) applies an exponential moving average. The tau parameter is the time constant in seconds — it controls how quickly the output tracks the input, regardless of how often the expression evaluates.
At each evaluation the filter computes: alpha = 1 - e^(-dt / tau), then output = alpha x input + (1 - alpha) x previous. On the first evaluation the output equals the input.
moving_avg — Moving Average
moving_avg(value, window) computes the average of all samples received within the last window seconds.
rate — Rate of Change
rate(value) returns the rate of change of the input in units per second. It only updates when the input actually changes, so repeated evaluations with a stale value don't distort the result.
deadband — Deadband Filter
deadband(value, threshold) only passes through changes larger than threshold. The output holds its last accepted value until the input moves far enough away.
Conditional Expressions
Use Python's ternary syntax for if-else logic:
Practical Examples
Temperature Conversion
Celsius to Fahrenheit:
Scaling and Offset
Convert a 4–20 mA signal to 0–100%:
Average of Multiple Sensors
Status-Based Fallback
Use a backup sensor if the primary tag fails:
Device Failover
Switch to a backup device's sensor when the primary device connection goes down:
Model Health Check
Output 1 when the AI model is running, 0 when it's stopped or failed:
Alarm with Deadband
High alarm with a 5-unit deadband — turns on above 95, off below 90, holds previous state in between:
Smoothed Differential
Smoothed pressure differential with a 30-second time constant:
Rate of Temperature Change
Degrees per minute:
Smoothed Deadband
Reduce noise first, then gate small changes:
