Forked from networkingcat/yet_another_motion_automation.yaml
Last active
December 21, 2020 20:17
-
-
Save yvolchkov/65c3d18e4871ba89fc79f7878cfd49b0 to your computer and use it in GitHub Desktop.
Homeassistant blueprint for motion-activated light scene with surrounding light level check
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: Yet Another Motion Automation | |
description: Turn on a light scene when motion is detected. Five different scenes can be defined depending on time of day. V03 | |
domain: automation | |
source_url: https://gist.github.com/networkingcat/a1876d7e706e07c8bdcf974113940fb8 | |
input: | |
motion_entity: | |
name: Motion Sensor | |
description: Motion Sensor or a group with Motion Sensors (But can be anything switching between "on" and "off") | |
selector: | |
entity: | |
light_target: | |
name: Light | |
selector: | |
target: | |
entity: | |
domain: light | |
automation_blocker: | |
name: Automation Blocker | |
description: Only run if this boolean is true (Optional) | |
default: input_boolean.none | |
selector: | |
entity: | |
domain: input_boolean | |
scene_ambient: | |
name: Ambient Scene (Optional) | |
description: Scene for ambient state. Will be activated when no motion is detected. Default value = scene.none | |
default: scene.none | |
selector: | |
entity: | |
domain: scene | |
time_scene_ambient_start: | |
name: Ambient time frame start | |
description: Time from which on ambient scene will be activated | |
default: "00:00:00" | |
selector: | |
time: | |
time_scene_ambient_end: | |
name: Ambient time frame end | |
description: Time from which on ambient scene will be not activated | |
default: "00:00:00" | |
selector: | |
time: | |
scene_morning: | |
name: Scene for the morning | |
default: scene.none | |
selector: | |
entity: | |
domain: scene | |
time_scene_morning: | |
name: Time for the morning scene | |
description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none | |
default: "00:00:00" | |
selector: | |
time: | |
scene_day: | |
name: Scene for the bright day | |
default: scene.none | |
selector: | |
entity: | |
domain: scene | |
time_scene_day: | |
name: Time for the day scene | |
description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none | |
default: "00:00:00" | |
selector: | |
time: | |
scene_evening: | |
name: Scene for the evening | |
default: scene.none | |
selector: | |
entity: | |
domain: scene | |
time_scene_evening: | |
name: Time for the evening scene | |
description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none | |
default: "00:00:00" | |
selector: | |
time: | |
scene_night: | |
name: Scene for the dark night | |
default: scene.none | |
selector: | |
entity: | |
domain: scene | |
time_scene_night: | |
name: Time for the night scene | |
description: A time input which defines the time from which on the scene will be activated if motion is detectedd. Default value = scene.none | |
default: "00:00:00" | |
selector: | |
time: | |
no_motion_wait: | |
name: Wait time | |
description: Time to leave the light on after last motion is detected. | |
default: 120 | |
selector: | |
number: | |
min: 0 | |
max: 3600 | |
unit_of_measurement: seconds | |
mode: restart | |
max_exceeded: silent | |
variables: | |
scene_ambient: !input scene_ambient | |
scene_morning: !input scene_morning | |
scene_day: !input scene_day | |
scene_evening: !input scene_evening | |
scene_night: !input scene_night | |
automation_blocker: !input automation_blocker | |
trigger: | |
platform: state | |
entity_id: !input motion_entity | |
from: "off" | |
to: "on" | |
condition: | |
- condition: template | |
value_template: "{{ automation_blocker == 'input_boolean.none' or (states[automation_blocker].state == 'on') }}" | |
action: | |
- choose: | |
- conditions: | |
- "{{ scene_morning != 'scene.none'}}" | |
- condition: time | |
after: !input time_scene_morning | |
before: !input time_scene_day | |
sequence: | |
- scene: !input scene_morning | |
- conditions: | |
- "{{ scene_day != 'scene.none'}}" | |
- condition: time | |
after: !input time_scene_day | |
before: !input time_scene_evening | |
sequence: | |
- scene: !input scene_day | |
- conditions: | |
- "{{ scene_evening != 'scene.none'}}" | |
- condition: time | |
after: !input time_scene_evening | |
before: !input time_scene_night | |
sequence: | |
- scene: !input scene_evening | |
- conditions: | |
- "{{ scene_night != 'scene.none'}}" | |
- condition: time | |
after: !input time_scene_night | |
before: !input time_scene_morning | |
sequence: | |
- scene: !input scene_night | |
default: | |
- service: light.turn_on | |
target: !input light_target | |
- wait_for_trigger: | |
platform: state | |
entity_id: !input motion_entity | |
from: "on" | |
to: "off" | |
- delay: !input no_motion_wait | |
- choose: | |
- conditions: | |
- "{{ scene_ambient != 'scene.none'}}" | |
- condition: time | |
after: !input time_scene_ambient_start | |
before: !input time_scene_ambient_end | |
sequence: | |
- scene: !input scene_ambient | |
default: | |
- service: light.turn_off | |
target: !input light_target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment