Skip to content

Instantly share code, notes, and snippets.

@chatainsim
Last active September 28, 2021 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chatainsim/d1ce470401d3d5ce81b285ba88e55ba5 to your computer and use it in GitHub Desktop.
Save chatainsim/d1ce470401d3d5ce81b285ba88e55ba5 to your computer and use it in GitHub Desktop.
Portail turn light On/Off
blueprint:
name: Door Sensor-activated Light
description: Turn on a light when door is opened.
domain: automation
input:
switch_target:
name: Monitored Switch
description: Switch to be monitored
selector:
entity:
domain: switch
# My sensors has device_class opening but it's commented
# for now since not every sensor uses 'opening' as default
# device_class: opening
light_target:
name: Light
selector:
target:
entity:
domain: light
door_closed_wait:
name: Wait time
description: Time to leave the light on after door is closed
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
mode: single
max_exceeded: silent
trigger:
platform: state
entity_id: !input switch_target
from: "off"
to: "on"
condition:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
action:
- service: light.turn_on
target: !input light_target
- wait_for_trigger:
platform: state
entity_id: !input switch_target
from: "on"
to: "off"
- delay: !input door_closed_wait
- service: light.turn_off
target: !input light_target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment