Automation not triggering because conditions not met

Hi and thank you for reading this,

I’ve migrated from another open source system, but am really new at the automations in HA. I have one that is giving me an issue and I can’t tell why.

I have two garage doors (lets call them LEFT and RIGHT, both with Z-Wave tilt sensors on them to tell when they are open and closed. I have a light inside my house in the hall that I want to have come on when a door is open, and off when a door is closed. The idea is to tell when someone has left the garage door open. We have some crime in the area…

WORKS: I have an automation that turns the light on when either door is up.
(Basically a trigger set for LEFT = OPENED and one set for RIGHT = OPENED, with no conditions set. The action turns on the light.)

WORKED: I had another automation that detected when the LEFT door was closed and turned off the light

THE PROBLEM: Instead of having two automations for closing, I tried to make one.
Triggers: LEFT = CLOSED, RIGHT = CLOSED
Conditions: LEFT=CLOSED & RIGHT = CLOSED
Action: Turn off the hall light.

This works if I open and close the LEFT, or I open and close the RIGHT.
If I open the Left and then open the right, then close the left, then close the right… it does not turn off the light.

The trace says “Stopped because a condition failed”. Now if I go back into the automation and run a test on the conditions, it says it passes. AND If I run the rule manually, it also turns off the light.

id: '1695599785236'
alias: Garage door close
description: ''
trigger:
  - type: not_opened
    platform: device
    device_id: 69babed1a0132896079e4e3fde906200
    entity_id: d8c9f60131058d981867d72e17486b97
    domain: binary_sensor
  - type: not_opened
    platform: device
    device_id: db26529ca5c83df27a5646e6ea1b8dcf
    entity_id: 3c66d9a76958cb69b41bd1eb75418ec0
    domain: binary_sensor
condition:
  - condition: and
    conditions:
      - type: is_not_open
        condition: device
        device_id: db26529ca5c83df27a5646e6ea1b8dcf
        entity_id: 3c66d9a76958cb69b41bd1eb75418ec0
        domain: binary_sensor
      - type: is_not_open
        condition: device
        device_id: 69babed1a0132896079e4e3fde906200
        entity_id: 47169e2f0148837704a8c94d5727a417
        domain: binary_sensor
action:
  - type: turn_off
    device_id: e299a6e7c7db6bc314e73dbecf8262ce
    entity_id: badde247dc4139a3a9a4c09bb2837482
    domain: light
mode: single

And when I look at the step details on the failure… its showing that the state has not changed yet on the garage door. But as I understand it, that state change is what triggered the rule to be evaluated.

## conditions/0/entity_id/0
result: true state: 'off' 
wanted_state: 'off'

## conditions/1/entity_id/0
result: false state: 'on' 
wanted_state: 'off'

If I go back to the editing of the automation rule, and test the conditions, it says it passed.

I am just confused…

Thanks for any advice

If you run the automation manually it skips the triggers and conditions and just performs the actions.

You can go to Developer Tools → Services and use the trigger automation service. There will be an option to not skip the conditions you should use.

Thanks, that is good to know.

I used this to run it after it failed, along with the skip conditions turned off… it works. So there is some delay in updating the state.

I set a duration on the triggers of 5 seconds and that seems to have made the whole thing work. Is that the right way of going about this?

Thanks!