Direct Answer Snippet:
Home Assistant YAML automations can fail when using OR conditions with
Zigbee sensors due to state evaluation timing issues and asynchronous
event reporting. Zigbee devices may report changes with slight delays,
causing the OR logic to evaluate before all conditions are current, which
prevents the automation from triggering as expected.
Preliminary Diagnostic Steps
1. Verify Device States
- Check the Developer
Tools → States in Home Assistant.
- Observe the
real-time states of all Zigbee sensors used in the OR condition.
2. Review Automation Trace
- Use the Automation
→ Trace feature to see how Home Assistant evaluates OR conditions.
- Identify which
sensor states are causing the automation to skip execution.
3. Check Event Reporting Frequency
- Zigbee sensors may
report events at different intervals or with slight delays.
- Identify sensors
with slow updates that may affect OR evaluation.
4. Test Each Condition Individually
- Temporarily split
OR conditions into separate automations.
- Verify that each
sensor triggers independently.
Step-by-Step Technical Fix
1. Use “For” or Delay Attributes
- Add a for:
attribute to each condition to ensure the state persists for a short
duration:
condition:
- condition: state
entity_id: binary_sensor.motion_sensor_1
state: "on"
for: "00:00:02"
- This reduces false
negatives due to transient state changes.
2. Implement Template Conditions
- Use template
conditions to combine multiple sensor states reliably:
condition:
condition: template
value_template: >
{{ is_state('binary_sensor.sensor1','on')
or is_state('binary_sensor.sensor2','on') }}
- Templates evaluate
all states at the moment of execution, reducing race conditions.
3. Optimize Zigbee Network Health
- Ensure strong mesh
connectivity: repeaters in strategic locations.
- Weak signal can
delay state updates, breaking OR logic.
4. Add Short Delay Before Action
- Use a delay:
of 1–2 seconds before executing automation actions.
- Ensures all Zigbee
sensor states have been received.
5. Update Home Assistant and Zigbee Integration
- Keep Home
Assistant, ZHA, or Zigbee2MQTT updated.
- New releases often
improve asynchronous state handling.
Preventing Future Failures
1. Use Templates for Complex Conditions
- Template
conditions are more reliable for multi-sensor OR logic.
2. Monitor Sensor Reporting Times
- Regularly check
logs for sensors with delayed or missed reports.
3. Avoid High-Frequency OR Automations
- Triggering very
frequently increases risk of missing updates.
4. Ensure Strong Zigbee Mesh
- Maintain stable
network with sufficient repeaters for consistent state updates.
5. Test Automations After Firmware Updates
- Zigbee firmware
updates can change reporting behavior; retest OR-based automations.
