Create advanced, state-aware logic units with multiple formulas and intelligent input handling.
⚠️ Important: This is a major upgrade with significant changes. While backwards compatibility is maintained, we strongly recommend creating new Logic Units and reconfiguring your flows for the best experience.
The biggest improvement! Each formula now has its own separate input state.
A
is completely independent from Formula 2’s input A
Before v1.1.0: All formulas on a device shared the same inputs (messy!)
After v1.1.0: Each formula tracks its own inputs (clean!)
Choose how your formulas handle incoming input values:
First Impression Mode (firstImpression: true
- default):
Reactive Mode (firstImpression: false
or 0
):
Set a timeout per formula to catch incomplete evaluations:
{
"id": "f1",
"name": "Security Check",
"expression": "A AND B AND C",
"timeout": 30,
"firstImpression": true
}
New flow actions to reset and re-evaluate:
true
/false
and 1
/0
for boolean valuesBoolean Toolbox lets you create Logic Units - virtual devices that evaluate boolean expressions using multiple inputs (A, B, C, etc.). Think of it as programmable logic gates for your smart home!
*
, &
), OR (+
, |
), XOR (^
, !=
), NOT (!
)Go to the device settings and add formulas in JSON format:
[
{
"id": "formula_1",
"name": "Motion & Dark",
"expression": "A AND B",
"enabled": true,
"timeout": 60,
"firstImpression": true
},
{
"id": "formula_2",
"name": "Any Window Open",
"expression": "A OR B OR C",
"enabled": true,
"timeout": 0,
"firstImpression": false
}
]
WHEN:
THEN:
AND:
Scenario: Turn on alarm only if all doors are closed within 30 seconds of arming.
{
"id": "security",
"name": "All Doors Closed",
"expression": "A AND B AND C",
"timeout": 30,
"firstImpression": true
}
Flow:
WHEN: User arms alarm
THEN: Set input A to [front door closed] for [security]
Set input B to [back door closed] for [security]
Set input C to [garage door closed] for [security]
IF: Formula [security] is TRUE
THEN: Activate alarm
ELSE: Send notification "Close all doors first!"
IF: Formula [security] timed out
THEN: Send notification "Security check failed - not all doors reported"
Why First Impression? Each door’s state is locked at the moment of arming. Even if someone opens a door later, the alarm activation decision is based on the initial state.
Scenario: Turn on lights if motion detected AND it’s dark, turn off when either condition changes.
{
"id": "auto_light",
"name": "Motion & Dark",
"expression": "A AND B",
"timeout": 0,
"firstImpression": false
}
Flow:
WHEN: Motion sensor changes
THEN: Set input A to [motion detected] for [auto_light]
WHEN: Lux sensor changes
THEN: Set input B to [is dark] for [auto_light]
WHEN: Formula [auto_light] changed to TRUE
THEN: Turn on living room lights
WHEN: Formula [auto_light] changed to FALSE
THEN: Turn off living room lights
Why Reactive? The lights should respond immediately to changes in both motion and light level.
Scenario: One device with different logic for day and night.
[
{
"id": "day_mode",
"name": "Daytime Motion",
"expression": "A AND B AND C",
"firstImpression": false
},
{
"id": "night_mode",
"name": "Nighttime Security",
"expression": "A OR B OR C",
"firstImpression": true,
"timeout": 300
}
]
Important: Input A
for day_mode
is completely separate from input A
for night_mode
!
Flows:
// Daytime: All sensors must be active (reactive)
WHEN: Sensor changes
THEN: Set input A to [sensor state] for [day_mode]
// Nighttime: Any sensor triggers (first impression, 5min timeout)
WHEN: Night mode activated
THEN: Set input A to [sensor state] for [night_mode]
Set input B to [sensor state] for [night_mode]
Set input C to [sensor state] for [night_mode]
Property | Type | Default | Description |
---|---|---|---|
id |
string | required | Unique identifier for the formula |
name |
string | required | Human-readable name (shown in flows) |
expression |
string | required | Boolean expression (e.g., “A AND B”) |
enabled |
boolean | true |
Enable/disable the formula |
timeout |
number | 0 |
Seconds before timeout (0 = infinite) |
firstImpression |
boolean/number | true |
Lock inputs at first value (true /1 ) or reactive mode (false /0 ) |
Operator | Symbols | Example | Description |
---|---|---|---|
AND | AND , & , * |
A AND B |
Both must be true |
OR | OR , + , \| |
A OR B |
At least one must be true |
XOR | XOR , ^ , != |
A XOR B |
Exactly one must be true |
NOT | NOT , ! |
NOT A |
Inverts the value |
// Simple AND
"A AND B"
// Complex grouping
"(A OR B) AND (C OR D)"
// With NOT
"A AND NOT B"
// Mixed operators
"(A AND B) OR (C AND D) OR E"
// XOR for exclusive conditions
"A XOR B" // True if only A or only B, not both
✅ Sequences - Actions that should complete in a specific order
✅ One-time triggers - Events that should only evaluate once
✅ Stable conditions - Check state at a specific moment
✅ Timeout detection - Verify all inputs arrive in time
Examples:
✅ Real-time monitoring - Continuous evaluation of changing conditions
✅ Dynamic responses - Immediate reaction to any input change
✅ Live states - Current status tracking
Examples:
Option 1: Fresh Start (Recommended)
Option 2: Upgrade Existing Devices
"firstImpression": false
to all formulas to maintain old behaviorMigration Example:
Old formula (v1.0.0):
{
"id": "f1",
"name": "My Formula",
"expression": "A AND B",
"enabled": true
}
New formula (v1.1.0 - maintaining old behavior):
{
"id": "f1",
"name": "My Formula",
"expression": "A AND B",
"enabled": true,
"timeout": 0,
"firstImpression": false
}
New formula (v1.1.0 - using new features):
{
"id": "f1",
"name": "My Formula",
"expression": "A AND B",
"enabled": true,
"timeout": 30,
"firstImpression": true
}
Check:
"enabled": true
First Impression Mode:
If formulas time out unexpectedly:
timeout
valuetimeout: 0
for infinite timeoutv1.1.0 migration:
Device | Inputs | Use Case |
---|---|---|
Logic Unit (2 inputs) | A, B | Simple AND/OR/XOR gates |
Logic Unit (3 inputs) | A, B, C | Small automation sequences |
Logic Unit (4 inputs) | A, B, C, D | Multi-sensor conditions |
Logic Unit (5 inputs) | A, B, C, D, E | Complex room automation |
Logic Unit (6-10 inputs) | A-J | Advanced multi-device logic |
Created by Lars Kvanum (@Tiwas)
If you find this app useful, consider supporting development:
This app is provided as-is. Use at your own risk.
Boolean Toolbox v1.1.0 - Create smarter automations with advanced boolean logic! 🚀