Created
May 27, 2022 22:42
Star
You must be signed in to star a gist
HASS Blueprint | Motion - Turn Off Unoccupied Lights
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 - Turn Off Unoccupied Lights v1.0 | |
source_url: https://gist.github.com/blizzrdof77/b3244483825be220287fe98c3e12df2c | |
description: Turn off a switch that has been left on with no motion | |
domain: automation | |
input: | |
motion_entity: | |
name: Motion Sensor | |
description: The motion sensor to track. | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: motion | |
multiple: false | |
light_entity: | |
name: Light(s) | |
selector: | |
entity: | |
domain: light | |
# multiple: false | |
transition: | |
name: Transition | |
description: Transition time in seconds to fade light on/off. | |
default: 2.0 | |
selector: | |
number: | |
min: 0.0 | |
max: 15.0 | |
step: 0.1 | |
mode: slider | |
wait_time_selector: | |
name: Stay On Time | |
description: Time to keep lights on when no motion is detected. | |
default: 30 | |
selector: | |
number: | |
min: 1.0 | |
max: 1440.0 | |
unit_of_measurement: minutes | |
step: 1.0 | |
mode: slider | |
grace_period_selector: | |
name: Grace Period | |
description: After turning off the switch, turn it back on if motion is detected within grace period. | |
default: 15 | |
selector: | |
number: | |
min: 0.0 | |
max: 1440.0 | |
unit_of_measurement: minutes | |
step: 1.0 | |
mode: slider | |
grace_arm_delay_selector: | |
name: Grace Arm Delay Period | |
description: Delay before starting grace period (to prevent the act of turning off the switch from triggering the sensor). | |
default: 5 | |
selector: | |
number: | |
min: 0.0 | |
max: 60.0 | |
unit_of_measurement: seconds | |
step: 1.0 | |
mode: slider | |
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 | |
data: | |
entity_id: !input 'light_entity' | |
transition: !input 'transition' | |
- 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 | |
data: | |
entity_id: !input 'light_entity' | |
transition: !input 'transition' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment