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