Skip to content

Instantly share code, notes, and snippets.

@adamjez
Last active December 15, 2024 21:19
Show Gist options
  • Select an option

  • Save adamjez/75510934ed686bbdc7f711a897f5a9f3 to your computer and use it in GitHub Desktop.

Select an option

Save adamjez/75510934ed686bbdc7f711a897f5a9f3 to your computer and use it in GitHub Desktop.
Improved presence light blueprint
blueprint:
name: Presence Light
description: Turn on a light when presence is detected.
domain: automation
input:
presence_entity:
name: Presence Sensor
description: Presence sensor device
selector:
entity:
filter:
- domain: binary_sensor
- device_class: occupancy
light_target:
name: Light
description: The light to turn on
selector:
target:
entity:
- domain: light
bright_percentage:
name: Bright Percentage
description: Brightness level that the light will turn into once is turned on
default: 100
selector:
number:
min: 0
max: 100
unit_of_measurement: percentage
on_transition:
name: Turning on transition
description: Time in seconds of transition turning on
default: 0
selector:
number:
min: 0
max: 10
unit_of_measurement: seconds
no_motion_wait:
name: Wait time
description: Time to wait after motion stops before turning off the light
default: 0
selector:
duration:
off_transition:
name: Turning off transition
description: Time in seconds of transition turning off
default: 0
selector:
number:
min: 0
max: 10
unit_of_measurement: seconds
light_sensor:
name: Light sensor
description: Light sensor to read from
default: []
selector:
entity:
filter:
- domain: sensor
- device_class: illuminance
light_threshold:
name: Light threshold
description: Light sensor‘s lower threshold
default: 10
selector:
number:
min: 0
max: 255
mode: box
turn_on_additional_conditions:
name: Conditions to turn on the light
description: Additional custom conditions to turn on the light
selector:
condition:
mode: single
trigger:
- trigger: state
entity_id: !input presence_entity
from: "off"
to: "on"
id: "occupied"
- trigger: state
entity_id: !input presence_entity
from: "on"
to: "off"
id: "not_occupied"
for: !input no_motion_wait
conditions:
- condition: or
conditions:
- condition: and
conditions:
- condition: trigger
id:
- "occupied"
- condition: numeric_state
entity_id: !input light_sensor
below: !input light_threshold
- condition: and
conditions: !input turn_on_additional_conditions
- condition: trigger
id:
- "not_occupied"
actions:
- if:
- condition: trigger
id:
- "occupied"
then:
- alias: "Turn on the light"
action: light.turn_on
target: !input light_target
data:
brightness_pct: !input bright_percentage
transition: !input on_transition
- if:
- condition: trigger
id:
- "not_occupied"
then:
- alias: "Turn off the light"
action: light.turn_off
target: !input light_target
data:
transition: !input off_transition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment