Skip to content

Instantly share code, notes, and snippets.

@hyperbolic2346
Last active December 11, 2021 17:30
Show Gist options
  • Save hyperbolic2346/95b1512192216a0136e9e278d62330d0 to your computer and use it in GitHub Desktop.
Save hyperbolic2346/95b1512192216a0136e9e278d62330d0 to your computer and use it in GitHub Desktop.
Door Sensor Light
blueprint:
name: Door Sensor Light
description: Turn a light when a door is opened
domain: automation
input:
doorsensor_entity:
name: Door Sensor
selector:
entity: {}
light_target:
name: Light
selector:
target:
entity:
domain: switch
door_closed_wait:
name: Wait time
description: Time to leave the light on after door is closed
default: 120
selector:
number:
min: 0.0
max: 3600.0
unit_of_measurement: seconds
step: 1.0
mode: slider
source_url: https://gist.github.com/hyperbolic2346/95b1512192216a0136e9e278d62330d0
mode: restart
trigger:
platform: state
entity_id: !input 'doorsensor_entity'
from: 'closed'
to: 'open'
condition:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
action:
- service: switch.turn_on
target: !input 'light_target'
- wait_for_trigger:
platform: state
entity_id: !input 'doorsensor_entity'
from: 'open'
to: 'closed'
for: !input 'door_closed_wait'
- service: switch.turn_off
target: !input 'light_target'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment