Door sensor + Light or Switch + delay off

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

GitHub Link Click Here

Version: 1.1

A very basic automation for a door sensor (or any binary sensor really) to active a light or a switch which will turn off after a certain delay if the door is left open.

blueprint:
  name: Door Sensor-activated Light/Switch With Delay
  description: >
    Version: 1.1

    Turn on/off a light or a switch when door is opened/closed and off after the door has been opened for a while.

    For community support see this forum post: [Click here](https://community.home-assistant.io/t/door-sensor-light-or-switch-delay-off/483329).

    GitHub: [Click here](https://github.com/maur8ino/home-assistant-blueprints/blob/99e75b7981dedb7d10bbcddbd641ea7298d924c3/automations/door-sensor-turn-on-off-light-or-switch-with-delay.yaml)
  domain: automation
  input:
    door_sensor_entity:
      name: Door Sensor
      selector:
        entity:
          domain: binary_sensor
          multiple: false
    light_or_switch_target:
      name: Light/Switch
      selector:
        target:
          entity:
            domain:
              - light
              - switch
    door_opened_wait:
      name: Wait time
      description: Time to leave the light/switch on after door is opened
      default: 120
      selector:
        number:
          min: 0.0
          max: 3600.0
          unit_of_measurement: seconds
          mode: slider
          step: 1.0
mode: restart
max_exceeded: silent
trigger:
  platform: state
  entity_id: !input door_sensor_entity
  from: "off"
  to: "on"
action:
  - service: homeassistant.turn_on
    target: !input light_or_switch_target
  - wait_for_trigger:
      - platform: state
        entity_id: !input door_sensor_entity
        from: "on"
        to: "off"
    timeout: !input door_opened_wait
  - service: homeassistant.turn_off
    target: !input light_or_switch_target
1 Like

Thanks for geat blueprint.
Is it possible to add run only if statment.
Example:
Run only if dayligt sensor is off or sun below horizon?

/Claes

Hi Claes,

there could be surely done: I designed this blueprint for my specific use case which is a closet that sometimes is left open, but the door closet is the only source of light, so it didn’t make much sense to add a condition there.

Let me think about it!

I’m not sure if this would drop straight into the blueprint between trigger and action (you may want to adjust offsets), but it works for me in my regular automations…

condition:
  - condition: sun
    before: sunrise
    before_offset: "+01:00:00"
    after: sunset
    after_offset: "-02:00:00"