The Only if block says what must hold when a trigger fires: “All of these must hold.” It is optional. The same conditions are used by the actions Wait until something holds and Choose by a condition. Click Add a condition and choose the kind.
Conditions read the values stored now, at the moment they are checked. They do not wait for a new message.
| Kind | Holds when |
|---|---|
| A value | A device’s latest stored value compares as chosen. |
| A device is online or offline | The device is online / is offline. |
| An alarm is active | A device has an active alarm / has no active alarm, optionally of a minimum severity. |
| A time window | The time is After … and Before …, on chosen weekdays. |
| Day or night | It is day / It is night at the place. |
| Months or dates | Today is in chosen months, on chosen days of the month, or Between two dates. |
| A public holiday | Today is a public holiday / Today is a working day. |
| A formula | A formula over stored values is true. |
A value
Pick the Device, the Value (key), the operator and the value:
| Operator | Meaning |
|---|---|
| is above / is at least | > / >= |
| is below / is at most | < / <= |
| is / is not | == / != |
| is between x and y | x ≤ value ≤ y |
Numbers and number-like text compare as numbers; is / is not compare anything else as text. A device with no stored value for the key makes the condition false, and the run log says which: “Room 1 · humidity has no stored value”. Conditions read telemetry values; a value the device only sends as an attribute has no stored telemetry value.
Conditions compare with fixed values you type. To compare with another device’s value or with a computed limit, use A formula.
A device is online or offline
Reads the device’s current connection state under its profile’s online rule. A device on Last seen only is neither, so both choices are false.
An alarm is active
has an active alarm holds when the device has an open or acknowledged alarm, of at least the chosen severity if you set one. It does not tell acknowledged from open alarms, so “if still unacknowledged after 30 minutes” cannot be built this way; use the alarm rule’s reminders instead (see Alarm notifications in depth).
A time window
After and Before as HH:MM, and optionally weekdays. The window includes After and excludes Before. A window may cross midnight: after 22:00, before 06:00. Leave After empty for “from midnight”, Before empty for “until midnight”.
Day or night
Day is between today’s sunrise and sunset at the place’s location. A place without a location makes it false (“the place has no location, so day and night are unknown”). Near the poles, on days without a sunrise or sunset, it is false too.
Months or dates
Any combination of:
- months (January to December),
- days of the month (1 to 31),
- Between two dates: From and Until as month and day, both included. The window may cross the new year (1 Nov to 28 Feb).
Every part you set must hold. “Say which months, days of the month or dates this is about.” if none is set; “A date window needs both its first and its last date.” if only one end is set.
A public holiday
Today is a public holiday holds on the days of your organisation’s public-holiday calendar; Today is a working day holds on every other day. “Today” is the place’s own date. See Time, sunrise/sunset, dates and holidays for where the calendar comes from. Without a holiday calendar, no day is a holiday.
A formula
Write a device name and one of its values in brackets, and compare or calculate:
[Room 1].[temperature] > [Outdoor].[temperature] + 3
[Tank A].[level] + [Tank B].[level] < 120
[Pump 1].[running] == 1 && [Pump 2].[running] == 1
- Compare and calculate with
>,<,==,&&(and),||(or),+,-,*and/. The formula is checked when you save; text that cannot be read is refused with “The formula cannot be read: …”. - Add this value inserts a device and value from the place.
- Devices are named by name and must be in the rule’s home. Two devices with the same name are refused: “More than one device is called “…”; rename one of them.”
- Nothing but the bracketed values can be read: “A formula reads only the values you name in brackets, like [Room 1].[temperature].”
- At most 12 values and 500 characters.
- A value with nothing stored yet makes the formula false, with the device and value in the run log.
- A number result counts as true when it is not 0.
If you rename a device, the rule keeps working with the device it was saved with until the rule is saved again; then the formula must use the new name.
Groups
Click Add a group to combine conditions:
| Group | Holds when |
|---|---|
| All of these hold | every condition holds |
| Any of these holds | at least one holds |
| None of these holds | none holds |
Groups nest up to 4 levels, with at most 16 conditions in a group.
Every device or any device
A condition on Every profile means:
- in All of these hold (and in the top level of Only if): every device of that profile in the place must satisfy it;
- in Any of these holds: at least one device must;
- None of these holds negates the same reading (“not every device is above 25”).
A reference with no device at all is false.
The run log
When a condition stops a run, the rule’s History says why, in words: the first failing condition of an “all”, or every reason of a failing “any”. Use Test now in the editor to see the same text before saving.
In JSON
"onlyIf": { "all": [
{ "kind": "value", "target": { "device": "<id>" }, "key": "temperature", "op": "between", "value": 18, "value2": 24 },
{ "kind": "status", "target": { "device": "<id>" }, "is": "online" },
{ "kind": "alarm", "target": { "home": true }, "active": false, "minSeverity": "major" },
{ "kind": "time", "after": "08:00", "before": "18:00", "days": [1, 2, 3, 4, 5] },
{ "kind": "sun", "is": "night" },
{ "kind": "date", "from": "06-01", "to": "09-30" },
{ "kind": "holiday", "is": false },
{ "not": { "kind": "expr", "expr": "[Room 1].[co2] > 1200" } }
] }

