💡 Closet Light Control - Control one closet light with two door sensors and a timeout

Easily control the light in a double sliding door closet. Setup a door sensor on each door and use this blueprint to turn the lights on when either door opens. When all doors are shut, the light will turn off.

Optionally, you can include a light timeout to turn the lights off after a duration, if the doors are left open. Especially useful if you then open the other side, the light will come back on!

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Control Closet Light with Double Sliding Doors and a Timeout
  description: Control the light inside a closet with double doors and an optional timeout.
  domain: automation
  input:
    controlling_door_sensors:
      name: Doors
      description: Door sensors, when any opens the light will turn on, when all are closed, the light will turn off.
      selector:
        entity:
          domain:
          - binary_sensor
          multiple: true
    controlled_light:
      name: Light
      description: Light that is controlled by open/closed state of the Door
      selector:
        entity: {}
    enable_timeout:
      name: Enabled the timeout setting bellow
      description: Turn on to use the timeout duration below to turn off the lights after the time has elapsed
      default: false
      selector:
        boolean:
    light_timeout:
      name: Duration
      description: The duration to leave the light on for (optional)
      selector:
        duration:

mode: restart

variables:
  enable_timeout: !input enable_timeout

trigger:
  - platform: state
    entity_id: !input controlling_door_sensors
    id: Doors
  - platform: state
    entity_id: !input controlled_light
    to: "on"
    id: Light

action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Doors
        sequence:
          - choose:
              - conditions:
                  - condition: and
                    conditions:
                      - condition: not
                        conditions:
                          - condition: state
                            entity_id: !input controlling_door_sensors
                            state: "off"
                        alias: Check if any door is open
                      - condition: template
                        value_template: "{{ trigger.to_state.state == 'on' }}"
                        alias: Verify a door was opened
                      - condition: state
                        entity_id: !input controlled_light
                        state: "off"
                sequence:
                  - service: homeassistant.turn_on
                    target:
                      entity_id: !input controlled_light
                    data: {}
              - conditions:
                  - condition: and
                    conditions:
                      - condition: state
                        entity_id: !input controlling_door_sensors
                        state: "off"
                        alias: Check if both are closed
                      - condition: state
                        entity_id: !input controlled_light
                        state: "on"
                sequence:
                  - service: homeassistant.turn_off
                    target:
                      entity_id: !input controlled_light
                    data: {}
            default:
              - if:
                  - condition: and
                    conditions:
                      - condition: template
                        value_template: "{{ enable_timeout }}"
                        alias: Confirm if the timeout is enabled
                      - condition: state
                        entity_id: !input controlled_light
                        state: "on"
                then:
                  - delay: !input light_timeout
                  - service: homeassistant.turn_off
                    target:
                      entity_id: !input controlled_light
                    data: {}
                alias: Wait for timeout

      - conditions:
          - condition: trigger
            id:
              - Light
        sequence:
          - if:
              - condition: template
                value_template: "{{ enable_timeout }}"
                alias: Confirm if the timeout is enabled
            then:
              - delay: !input light_timeout
              - service: homeassistant.turn_off
                target:
                  entity_id: !input controlled_light
                data: {}
            alias: Wait for timeout

Thanks to @tombo12354 and @JonTheNiceGuy as this was based off combining one of each of their automations: