A condition block tests something and sends the message, unchanged, on its yes or no output. Use them to filter and branch. All condition blocks also have an error output for a test that could not be made. This page lists them as the blocks define them, then explains the values, paths and expressions they use.
Compare
Compares one property with a value.
| Setting | Meaning | Default | Values |
|---|---|---|---|
| property | What is tested | msg.payload | a msg., flow., global. or sys. path |
| op | The comparison | eq | see the operators below |
| value | What it is compared with | empty | any value kind; not shown for true, false, null, empty, nempty |
A missing property counts as null: gt 30 is then false. Errors: invalid_value (a bad pattern or operator), or the code of a value that could not be worked out.
Operators
Shared by Compare, Any / all of, Device state and Switch:
| Operator | True when |
|---|---|
eq, ne | Equal, not equal. A number and a number or numeric text compare as numbers ("5" equals 5, true counts as 1); anything else compares by content as JSON. |
lt, le, gt, ge | Less, less or equal, greater, greater or equal. Numbers and numeric text as numbers; two texts alphabetically; any other mix is false. |
contains | Text contains the value; an array has an equal element; an object has a key of that name |
regex | Text (or a number as text) matches the pattern: case-sensitive, at most 64 characters |
true, false | Exactly the boolean true / false (not 1, not "true") |
null | Missing or null |
empty, nempty | null, "", [] or {} / anything else |
type | The type is number, string, boolean, array, object or null |
Patterns cannot use lookahead, lookbehind or back-references; such a pattern is refused at deploy (regex_unsupported).
Any / all of
Up to 8 comparisons joined by “or” or “and”.
| Setting | Meaning | Default | Values |
|---|---|---|---|
| mode | How the rows are joined | any | any (or), all (and) |
| items | One comparison per row: property, op, value | none | up to 8 rows |
Rows are checked in order and checking stops once the answer is known. With no rows, any is false and all is true.
If / else
True when an expression is true.
| Setting | Meaning | Values |
|---|---|---|
| expr | The expression | required, up to 512 characters |
no when the result is false, null, 0, "" or not a number; an empty array or object counts as true. Errors: invalid_value (does not compile), type, div_zero, steps, regex, limit.
Example: msg.payload.temperature > 30 && flow.mode == "auto".
In range
Is a number between a minimum and a maximum, with optional hysteresis.
| Setting | Meaning | Default | Values |
|---|---|---|---|
| property | The number | msg.payload | a path |
| min | Lower limit, inclusive; empty = none | empty | a number |
| max | Upper limit, inclusive; empty = none | empty | a number |
| hyst | How far past a limit the value must go before the answer changes | 0 | 0 or more |
| key | A separate memory per value of this path | msg.originator (one per device) | a path |
Once inside, the answer stays yes until the value drops below min − hyst or rises above max + hyst; once outside, it turns yes again only within min + hyst … max − hyst. Not a number: no, memory unchanged.
Device state
Tests a stored variable (flow., global.) or a platform value (sys.) instead of the message. The message only decides when the test is made.
| Setting | Meaning | Default | Values |
|---|---|---|---|
| path | What is tested, e.g. flow.mode, global.persist:count | required | a sys., flow. or global. path |
| op | The comparison | eq | as above |
| value | What it is compared with | empty | any value kind |
Changed
yes when a property differs from its value in the previous message of the same key; the first message of a key is yes.
| Setting | Meaning | Default | Values |
|---|---|---|---|
| property | The value watched | msg.payload | a path |
| key | A separate last value per value of this path | msg.originator (one per device) | a path |
Values compare as JSON text: 5 and "5" differ.
Not repeated
yes only if nothing with the same key went through yes within the period.
| Setting | Meaning | Default | Values |
|---|---|---|---|
Period (window_ms) | How long after a yes the key is held back | 1 h | 0 to 7 days; 0 lets everything through |
| key | Keys counted apart | msg.originator (one per device) | a path |
Only a yes starts the period; with a 1-hour period a steady stream gives one yes an hour. Use it to stop repeating notifications.
Happened n times
yes when this message makes at least n messages of the same key within the period.
| Setting | Meaning | Default | Values |
|---|---|---|---|
| n | How many times | 3 | 1 to 1,000 |
Period (window_ms) | Sliding window | 10 min | 1 ms to 7 days |
| key | Keys counted apart | msg.originator (one per device) | a path |
| reset_on_yes | Start counting from zero after a yes | off | on, off |
Memory of condition blocks
In range, Changed, Not repeated and Happened n times remember values per key. On Hermetry the key defaults to the message’s originator, so each device has its own memory; set key to msg.topic (or another path) to share or split it differently. Each block keeps at most 10,000 keys; beyond that the oldest is forgotten. The memory survives restarts. Deploying a change to the block’s settings starts its memory empty. See Counters, statistics and watchdogs.
Values, paths and expressions
Many settings take a value of one of these kinds:
| Kind | Example | Meaning |
|---|---|---|
| Number, Text, Yes / no, JSON | 30, "alarm", true, {"on": true} | A fixed value |
| Variable (path) | msg.payload.level, flow.limit, global.persist:site.max | Read when the block runs |
| Expression | msg.payload.a + msg.payload.b | Worked out for every message |
| Environment variable | A value of the environment | |
| Current time | The time the message arrives |
Paths
msg.…: the message. Fields starting with_belong to the engine and cannot be written;msg.msgTypeandmsg.originatorare read-only.flow.…: variables of this flow.global.…: variables shared by all flows of the organisation. Addpersist:to use the persistent store (flow.persist:total). The first key starts with a letter or_and has at most 32 letters, digits or_.sys.…: read-only platform values.- Missing paths give
null.
Expressions
Up to 512 characters, at most 10,000 evaluation steps.
| Part | Available |
|---|---|
| Values | numbers, "text", true, false, null, [arrays], {objects}, paths |
| Operators | ?: || && == != < <= > >= in + - * / % ! |
| Number functions | abs, round(x, decimals), floor, ceil, min, max, clamp(x, lo, hi), sqrt, pow, number, int, fixed, sum, avg, and trigonometric and logarithmic functions (sin, cos, asin, rad, log10 …) |
| Text functions | string, len, lower, upper, trim, substr, replace, split, join, contains, starts, ends, matches |
| Other | keys, has, now, fmt_time, typeof, exists, default(x, fallback), empty |
==compares numbers numerically and everything else by type and value;<and>withnullare false.- Arithmetic on text fails with
type, even on numeric text: writenumber(msg.payload). {{ expression }}in text settings (templates) inserts a value:Level {{ msg.payload.level }} %.

