Last active
May 5, 2021 17:21
-
-
Save accessone67/b736277dd834630743751c846c297262 to your computer and use it in GitHub Desktop.
This file contains hidden or 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: Turn off unoccupied lightes | |
source_url: https://gist.github.com/accessone67/b736277dd834630743751c846c297262 | |
description: Turn off a light that has been left on with no motion | |
domain: automation | |
input: | |
motion_entity: | |
name: Motion Sensor | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: motion | |
light_entity: | |
name: light | |
selector: | |
entity: | |
domain: light | |
wait_time_selector: | |
name: Stay On Time | |
description: Time to keep light on with no motion | |
default: 30 | |
selector: | |
number: | |
min: 1 | |
max: 1440 | |
unit_of_measurement: minutes | |
grace_period_selector: | |
name: Grace Period | |
description: After turning off the light, turn it back on if motion is detected within grace period | |
default: 30 | |
selector: | |
number: | |
min: 0 | |
max: 1440 | |
unit_of_measurement: minutes | |
grace_arm_delay_selector: | |
name: Grace Arm Delay Period | |
description: Delay before starting grace period (to prevent the act of turning off the light from triggering the sensor) | |
default: 2 | |
selector: | |
number: | |
min: 0 | |
max: 60 | |
unit_of_measurement: seconds | |
mode: single | |
trigger: | |
- platform: state | |
entity_id: !input light_entity | |
to: 'on' | |
for: | |
minutes: !input wait_time_selector | |
- platform: state | |
entity_id: !input motion_entity | |
to: 'off' | |
for: | |
minutes: !input wait_time_selector | |
condition: | |
- condition: state | |
entity_id: !input light_entity | |
state: 'on' | |
for: | |
minutes: !input wait_time_selector | |
- condition: state | |
entity_id: !input motion_entity | |
state: 'off' | |
for: | |
minutes: !input wait_time_selector | |
action: | |
- service: light.turn_off | |
entity_id: !input light_entity | |
- delay: | |
seconds: !input grace_arm_delay_selector | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input motion_entity | |
to: 'on' | |
- platform: state | |
entity_id: !input light_entity | |
to: 'on' | |
timeout: | |
minutes: !input grace_period_selector | |
continue_on_timeout: false | |
- service: light.turn_on | |
entity_id: !input light_entity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment