"And" function? Turn off light when 2 conditions are met

I am trying to make an automation to turn our garage light off when both the garage roller door & internal door to the house are closed.

The light needs to stay on when one of the doors is still open, but ONLY gets off when BOTH doors are closed.

It was not too difficult to set up to turn the light on when either one of the doors is open, but having difficulties finding a way to turn it off only when both doors are closed…

Anyone can help me with this?

Thanks!

Trigger : either door opening (two state triggers)

Condition: both doors closed (two state conditions, these are AND by default)

Action: turn off your light.

This is what I use:

- id: '6'
  alias: Garage Door Closed
  trigger:
  - platform: state
    entity_id: sensor.garagedoorstate
    to: closed
  - platform: state
    entity_id: sensor.frontdoorz
    to: Locked
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: sensor.garagedoorstate
      state: closed
    - condition: state
      entity_id: sensor.frontdoorz
      state: Locked
  action:
    service: switch.turn_off
    data:
      entity_id: switch.garage_door_light
  mode: restart

That should work. You don’t need these lines though:

    condition: and
    conditions:

Conditions are AND by default.

1 Like

Thank you both!
The setup @ceh works perfectly and I have removed the “and” condition as @tom_l mentioned.

Thank you very much for the quick help!