Last active
February 1, 2021 03:51
-
-
Save carsonb/2ed87b78f133976af26dbd585de62036 to your computer and use it in GitHub Desktop.
Home Assistant Motion Aware Lights with Dimming Blueprint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Motion Aware Lights with Dimming | |
description: > | |
Turn a light on and off based on detected motion but only if certain criteria a matched provided by a Illuminance-Sensor or a Binary-Sensor. | |
Also allows to disable motion aware lights. This might be useful for example if a person is in the bed or a movie is playing. | |
Adapted from https://gist.github.com/pavax/ce9559c428b9a3c369ce79ef215ef1e2 | |
domain: automation | |
source_url: https://gist.github.com/carsonb/2ed87b78f133976af26dbd585de62036 | |
input: | |
motion_sensor: | |
name: Motion Sensor | |
description: This sensor will be synchronized with the light. | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: motion | |
no_motion_wait: | |
name: Wait time | |
description: Time to wait until the light should be turned off. | |
default: 120 | |
selector: | |
number: | |
min: 0 | |
max: 3600 | |
unit_of_measurement: seconds | |
illuminance_sensor: | |
name: Illuminance Sensor (Optional) | |
description: "Sensor that decides if lights should be turned on based on the illuminance." | |
default: | |
selector: | |
entity: | |
domain: sensor | |
illuminance_threshold: | |
name: Illumincance Threshold (Optional) | |
description: "Defines the illumincance threshold below which the lights should turn on." | |
default: 50.0 | |
selector: | |
number: | |
min: 0.0 | |
max: 100.0 | |
unit_of_measurement: '%' | |
binary_sensor_entity: | |
name: Binary Sensor (Optional) | |
description: "Binary Sensor that decides if lights should be turned on - state on is turn on lights." | |
default: | |
selector: | |
entity: | |
domain: binary_sensor | |
disabled_entity_id: | |
name: Disabled Mode (Optional) | |
description: "Binary Sensor that decides if lights shall not be interacted with - state on is do not turn on lights." | |
default: | |
selector: | |
entity: | |
domain: binary_sensor | |
target_light: | |
name: Light | |
description: "The lights to keep in sync." | |
selector: | |
entity: | |
domain: light | |
target_brightness: | |
name: Brightness | |
description: "How bright the light will be set to in percentage." | |
default: 100.0 | |
selector: | |
number: | |
min: 0.0 | |
max: 100.0 | |
unit_of_measurement: '%' | |
mode: restart | |
max_exceeded: silent | |
trigger: | |
- platform: state | |
entity_id: !input motion_sensor | |
to: 'on' | |
variables: | |
illuminance_sensor: !input illuminance_sensor | |
illuminance_threshold: !input illuminance_threshold | |
binary_sensor_entity: !input binary_sensor_entity | |
disabled_entity_id: !input disabled_entity_id | |
condition: | |
- "{{ disabled_entity_id == None or is_state(disabled_entity_id, 'off') }}" | |
- "{{ trigger.to_state.state == 'on' }}" | |
- condition: or | |
conditions: | |
- "{{ binary_sensor_entity != None and is_state(binary_sensor_entity, 'on' ) }}" | |
- "{{ illuminance_sensor != None and states(illuminance_sensor)|float < illuminance_threshold|float }}" | |
action: | |
- service: light.turn_on | |
data: | |
entity_id: !input target_light | |
brightness_pct: !input target_brightness | |
- wait_for_trigger: | |
platform: state | |
entity_id: !input motion_sensor | |
from: 'on' | |
to: 'off' | |
- delay: !input no_motion_wait | |
- service: light.turn_off | |
data: | |
entity_id: !input target_light |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment