Last active
March 26, 2022 12:45
-
-
Save np/76b50f958c7e33f999cd278060f6912a to your computer and use it in GitHub Desktop.
entity-light-switch-off-group-after-n-minutes-after-last-motion-detected
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: Entity (light/switch) OFF group after n minutes after last motion detected | |
domain: automation | |
input: | |
motion_entity_group: | |
name: Motion Sensor | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: motion | |
light_target: | |
name: Entity to be switched | |
description: The light, switch, scene to turn on (or script to run) when the | |
automation is triggered. | |
selector: | |
entity: | |
domain: group | |
no_motion_wait: | |
name: Wait time | |
description: Time to leave the light on after last motion is detected. | |
default: 3 | |
selector: | |
number: | |
min: 0.0 | |
max: 60.0 | |
step: 1.0 | |
unit_of_measurement: minutes | |
mode: slider | |
no_motion_wait_at_night: | |
name: Wait time at night | |
description: Time to leave the light on after last motion is detected at night. | |
default: 1 | |
selector: | |
number: | |
min: 0.0 | |
max: 20.0 | |
step: 1.0 | |
unit_of_measurement: minutes | |
mode: slider | |
source_url: https://community.home-assistant.io/t/entity-light-switch-off-after-n-minutes-after-last-motion-detected/360129 | |
mode: restart | |
max_exceeded: silent | |
trigger: | |
- platform: state | |
entity_id: !input 'light_target' | |
to: 'on' | |
from: 'off' | |
condition: [] | |
action: | |
- choose: | |
- conditions: | |
- condition: state | |
entity_id: !input 'motion_entity_group' | |
state: 'on' | |
sequence: | |
- choose: | |
- conditions: | |
- condition: time | |
after: 00:00 | |
before: 06:00 | |
sequence: | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input 'motion_entity_group' | |
from: 'on' | |
to: 'off' | |
for: | |
minutes: !input 'no_motion_wait_at_night' | |
default: | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input 'motion_entity_group' | |
from: 'on' | |
to: 'off' | |
for: | |
minutes: !input 'no_motion_wait' | |
default: | |
- choose: | |
- conditions: | |
- condition: time | |
after: 00:00 | |
before: 06:00 | |
sequence: | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input 'motion_entity_group' | |
from: 'off' | |
to: 'on' | |
timeout: | |
minutes: !input 'no_motion_wait_at_night' | |
default: | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input 'motion_entity_group' | |
from: 'off' | |
to: 'on' | |
timeout: | |
minutes: !input 'no_motion_wait' | |
- choose: | |
- conditions: | |
- condition: state | |
entity_id: !input 'motion_entity_group' | |
state: 'on' | |
sequence: | |
- choose: | |
- conditions: | |
- condition: time | |
after: 00:00 | |
before: 06:00 | |
sequence: | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input 'motion_entity_group' | |
from: 'on' | |
to: 'off' | |
for: | |
minutes: !input 'no_motion_wait_at_night' | |
default: | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input 'motion_entity_group' | |
from: 'on' | |
to: 'off' | |
for: | |
minutes: !input 'no_motion_wait' | |
default: [] | |
- delay: 00:00:01 | |
- service: homeassistant.turn_off | |
data: {} | |
entity_id: !input 'light_target' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment