IF
Category: Logic
Splits the automation flow into two branches based on a condition. The true branch executes when the condition passes, the false branch when it doesn't. Use this for conditional logic — "if the temperature is high, do X, otherwise do Y."
When to use
- Branch based on a device's current state
- Check values from upstream nodes (HTTP responses, code outputs)
- Compare trigger values against thresholds
- Create different paths for day vs night, home vs away, etc.
Configuration
- Expression — A condition written in the expression language. Returns true or false.
You can click the input data buttons below the expression field to insert references to upstream nodes and device state.
Expression syntax
states('acc-1', 'brightness') > 50 // Device state check
trigger.to_value == 1 // Trigger value
nodes['http1'].data.status == 200 // Upstream node output
now().hour >= 22 || now().hour < 6 // Time-based
nodes['code1'].data.average > 25 // Code node resultOperators: ==, !=, >, <, >=, <=, && (and), || (or), ! (not)
Functions: states(), is_state(), now(), min(), max(), iif()
Output data
{{ nodes['<id>'].data.branch }}—"then"or"else"{{ nodes['<id>'].data.result }}—trueorfalse
Handles
The IF node has two output handles:
- T (green, left) — connects to the "true" branch
- F (red, right) — connects to the "false" branch
Each branch can have its own chain of actions.
Examples
Daytime vs nighttime brightness:
- Schedule → sunset
- IF →
now().hour >= 18 - True → Set Device → bedroom light to 30%
- False → Set Device → bedroom light to 80%
Check HTTP response before acting:
- HTTP Request → GET API endpoint
- IF →
nodes['http1'].data.ok == true - True → Code → process response
- False → Notify → "API request failed"
Tips
- The expression is evaluated against current device state at execution time, not the state when the trigger fired
- Use
trigger.to_valueto check the value that triggered the automation - Use
nodes['<id>'].data.<field>to check output from upstream nodes - Complex conditions can use
&&and||to combine checks - Node IDs with hyphens need bracket notation:
nodes['my-node-id']