YAMA.yaml
· 9.9 KiB · YAML
Bruto
blueprint:
name: Yet Another Motion Automation (V11)
description: >
# YAMA V11
Turn on lights or scenes when motion is detected.
Four different scenes can be defined depending on time of day.
You can now set an Lux Entity and a Threshold for triggering.
Capabilitys:
- Trigger on motion (in fact can be triggered by anything that switches between “on” and off")
- Wait time for turning off
- Only run if entity is in desired state (optional)
- Sun elevation check (optional)
- 4 Scenes for different times of day (optional)
- Ambient support with time frame (optional)
- Default scene when motion stops (optional)
- “no motion blocker” with user choosable state (optional)
domain: automation
source_url: https://gist.github.com/DQKev/0979530e2996ced371a0f8db4432c178
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
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
lux_entity:
name: Lux Sensor
description: Lux Sensor
selector:
entity:
lux_threshold:
name: Lux Threshold
description: If under this Lux Value the State will trigger. 0 = allways
default: 0
selector:
number:
min: 0
max: 1500
unit_of_measurement: Lx
automation_blocker:
name: Automation Blocker (Optional)
description: Only run if this boolean is in desired state (see next input)
default:
selector:
entity:
automation_blocker_boolean:
name: Automation Blocker Chooser (Optional)
description: Desired state of automation blocker, choose on for on and off for off
default: false
selector:
boolean:
no_motion_blocker:
name: No Motion Blocker (Optional)
description: No motion sequence is not run if this boolean is in desired state (see next input)
default:
selector:
entity:
no_motion_blocker_boolean:
name: No Motion Chooser (Optional)
description: Desired state of no motion blocker, choose on for on and off for off
default: false
selector:
boolean:
elevation_check:
name: Sun elevation check (Optional)
description: This is the angle between the sun and the horizon. Negative values mean the sun is BELOW the horizon.
default: none
selector:
number:
min: -90
max: 90
unit_of_measurement: degrees
scene_ambient:
name: Ambient Scene (Optional)
description: Scene for ambient state. Will be activated when no motion is detected.
default: scene.none
selector:
entity:
domain: scene
time_scene_ambient_start:
name: Ambient time frame start (Optional)
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 (Optional)
description: Time from which on ambient scene will be not activated
default: "00:00:00"
selector:
time:
scene_morning:
name: Scene for the morning (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_morning:
name: Time for the morning scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detected.
default: "00:00:00"
selector:
time:
scene_day:
name: Scene for the bright day (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_day:
name: Time for the day scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detected.
default: "00:00:00"
selector:
time:
scene_evening:
name: Scene for the evening (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_evening:
name: Time for the evening scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detected.
default: "00:00:00"
selector:
time:
scene_night:
name: Scene for the dark night (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_night:
name: Time for the night scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detectedd.
default: "00:00:00"
selector:
time:
scene_no_motion:
name: Default scene for no motion (Optional)
description: Set this Scene if you want to activate a scene if motion stops
default: scene.none
selector:
entity:
domain: scene
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
automation_blocker_boolean : !input automation_blocker_boolean
no_motion_blocker: !input no_motion_blocker
no_motion_blocker_boolean: !input no_motion_blocker_boolean
elevation_check: !input elevation_check
scene_no_motion: !input scene_no_motion
motion_entity: !input motion_entity
lux_entity: !input lux_entity
lux_threshold: !input lux_threshold
trigger:
- platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
- platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
for: !input no_motion_wait
# All Conditions must be true
condition:
# Check if automation blocker exist or is in desired state, otherwise do not run
- condition: or
conditions:
- "{{ automation_blocker == none }}"
- "{{ automation_blocker_boolean and states[automation_blocker].state == 'on' }}"
- "{{ not automation_blocker_boolean and states[automation_blocker].state == 'off' }}"
# Check if elevation input exist or is below desired value, otherwise do not run
- condition: template
value_template: "{{ (elevation_check == none) or (state_attr('sun.sun','elevation') <= elevation_check | float(90)) }}"
action:
- choose:
# Trigger to state == "on"
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
- condition: template
value_template: >
{{ states(lux_entity) | float <= lux_threshold | float or states(lux_entity) | float == 0 }}
sequence:
- choose:
# Morning Scene
- conditions:
- "{{ scene_morning != 'scene.none'}}"
- condition: time
after: !input time_scene_morning
before: !input time_scene_day
sequence:
- scene: !input scene_morning
# Day Scene
- conditions:
- "{{ scene_day != 'scene.none'}}"
- condition: time
after: !input time_scene_day
before: !input time_scene_evening
sequence:
- scene: !input scene_day
# Evening Scene
- conditions:
- "{{ scene_evening != 'scene.none'}}"
- condition: time
after: !input time_scene_evening
before: !input time_scene_night
sequence:
- scene: !input scene_evening
# Night Scene
- conditions:
- "{{ scene_night != 'scene.none'}}"
- condition: time
after: !input time_scene_night
before: !input time_scene_morning
sequence:
- scene: !input scene_night
# If State -> "On" defaulting to turn light on
default:
- service: light.turn_on
target: !input light_target
# Trigger to state == "off"
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'off' }}"
# Check if no motion blocker exist or in in desired state, otherwise do not run any no motion action
- condition: or
conditions:
- "{{ no_motion_blocker == none }}"
- "{{ no_motion_blocker_boolean and states[no_motion_blocker].state == 'on' }}"
- "{{ not no_motion_blocker_boolean and states[no_motion_blocker].state == 'off' }}"
sequence:
- choose:
# Used if ambient scene is true and in ambient scene time frame
- conditions:
- "{{ scene_ambient != 'scene.none' }}"
- condition: time
after: !input time_scene_ambient_start
before: !input time_scene_ambient_end
sequence:
- scene: !input scene_ambient
# Used if default no motion scene is set
- conditions:
- "{{ scene_no_motion != 'scene.none' }}"
sequence:
- scene: !input scene_no_motion
# If State -> "off" default to turn lights off
default:
- service: light.turn_off
target: !input light_target
| 1 | blueprint: |
| 2 | name: Yet Another Motion Automation (V11) |
| 3 | description: > |
| 4 | # YAMA V11 |
| 5 | Turn on lights or scenes when motion is detected. |
| 6 | |
| 7 | Four different scenes can be defined depending on time of day. |
| 8 | |
| 9 | You can now set an Lux Entity and a Threshold for triggering. |
| 10 | |
| 11 | Capabilitys: |
| 12 | - Trigger on motion (in fact can be triggered by anything that switches between “on” and off") |
| 13 | - Wait time for turning off |
| 14 | - Only run if entity is in desired state (optional) |
| 15 | - Sun elevation check (optional) |
| 16 | - 4 Scenes for different times of day (optional) |
| 17 | - Ambient support with time frame (optional) |
| 18 | - Default scene when motion stops (optional) |
| 19 | - “no motion blocker” with user choosable state (optional) |
| 20 | domain: automation |
| 21 | source_url: https://gist.github.com/DQKev/0979530e2996ced371a0f8db4432c178 |
| 22 | input: |
| 23 | motion_entity: |
| 24 | name: Motion Sensor |
| 25 | description: Motion Sensor or a group with Motion Sensors (But can be anything switching between "on" and "off") |
| 26 | selector: |
| 27 | entity: |
| 28 | light_target: |
| 29 | name: Light |
| 30 | selector: |
| 31 | target: |
| 32 | entity: |
| 33 | domain: light |
| 34 | no_motion_wait: |
| 35 | name: Wait time |
| 36 | description: Time to leave the light on after last motion is detected. |
| 37 | default: 120 |
| 38 | selector: |
| 39 | number: |
| 40 | min: 0 |
| 41 | max: 3600 |
| 42 | unit_of_measurement: seconds |
| 43 | lux_entity: |
| 44 | name: Lux Sensor |
| 45 | description: Lux Sensor |
| 46 | selector: |
| 47 | entity: |
| 48 | lux_threshold: |
| 49 | name: Lux Threshold |
| 50 | description: If under this Lux Value the State will trigger. 0 = allways |
| 51 | default: 0 |
| 52 | selector: |
| 53 | number: |
| 54 | min: 0 |
| 55 | max: 1500 |
| 56 | unit_of_measurement: Lx |
| 57 | automation_blocker: |
| 58 | name: Automation Blocker (Optional) |
| 59 | description: Only run if this boolean is in desired state (see next input) |
| 60 | default: |
| 61 | selector: |
| 62 | entity: |
| 63 | automation_blocker_boolean: |
| 64 | name: Automation Blocker Chooser (Optional) |
| 65 | description: Desired state of automation blocker, choose on for on and off for off |
| 66 | default: false |
| 67 | selector: |
| 68 | boolean: |
| 69 | no_motion_blocker: |
| 70 | name: No Motion Blocker (Optional) |
| 71 | description: No motion sequence is not run if this boolean is in desired state (see next input) |
| 72 | default: |
| 73 | selector: |
| 74 | entity: |
| 75 | no_motion_blocker_boolean: |
| 76 | name: No Motion Chooser (Optional) |
| 77 | description: Desired state of no motion blocker, choose on for on and off for off |
| 78 | default: false |
| 79 | selector: |
| 80 | boolean: |
| 81 | elevation_check: |
| 82 | name: Sun elevation check (Optional) |
| 83 | description: This is the angle between the sun and the horizon. Negative values mean the sun is BELOW the horizon. |
| 84 | default: none |
| 85 | selector: |
| 86 | number: |
| 87 | min: -90 |
| 88 | max: 90 |
| 89 | unit_of_measurement: degrees |
| 90 | scene_ambient: |
| 91 | name: Ambient Scene (Optional) |
| 92 | description: Scene for ambient state. Will be activated when no motion is detected. |
| 93 | default: scene.none |
| 94 | selector: |
| 95 | entity: |
| 96 | domain: scene |
| 97 | time_scene_ambient_start: |
| 98 | name: Ambient time frame start (Optional) |
| 99 | description: Time from which on ambient scene will be activated |
| 100 | default: "00:00:00" |
| 101 | selector: |
| 102 | time: |
| 103 | time_scene_ambient_end: |
| 104 | name: Ambient time frame end (Optional) |
| 105 | description: Time from which on ambient scene will be not activated |
| 106 | default: "00:00:00" |
| 107 | selector: |
| 108 | time: |
| 109 | scene_morning: |
| 110 | name: Scene for the morning (Optional) |
| 111 | default: scene.none |
| 112 | selector: |
| 113 | entity: |
| 114 | domain: scene |
| 115 | time_scene_morning: |
| 116 | name: Time for the morning scene (Optional) |
| 117 | description: A time input which defines the time from which on the scene will be activated if motion is detected. |
| 118 | default: "00:00:00" |
| 119 | selector: |
| 120 | time: |
| 121 | scene_day: |
| 122 | name: Scene for the bright day (Optional) |
| 123 | default: scene.none |
| 124 | selector: |
| 125 | entity: |
| 126 | domain: scene |
| 127 | time_scene_day: |
| 128 | name: Time for the day scene (Optional) |
| 129 | description: A time input which defines the time from which on the scene will be activated if motion is detected. |
| 130 | default: "00:00:00" |
| 131 | selector: |
| 132 | time: |
| 133 | scene_evening: |
| 134 | name: Scene for the evening (Optional) |
| 135 | default: scene.none |
| 136 | selector: |
| 137 | entity: |
| 138 | domain: scene |
| 139 | time_scene_evening: |
| 140 | name: Time for the evening scene (Optional) |
| 141 | description: A time input which defines the time from which on the scene will be activated if motion is detected. |
| 142 | default: "00:00:00" |
| 143 | selector: |
| 144 | time: |
| 145 | scene_night: |
| 146 | name: Scene for the dark night (Optional) |
| 147 | default: scene.none |
| 148 | selector: |
| 149 | entity: |
| 150 | domain: scene |
| 151 | time_scene_night: |
| 152 | name: Time for the night scene (Optional) |
| 153 | description: A time input which defines the time from which on the scene will be activated if motion is detectedd. |
| 154 | default: "00:00:00" |
| 155 | selector: |
| 156 | time: |
| 157 | scene_no_motion: |
| 158 | name: Default scene for no motion (Optional) |
| 159 | description: Set this Scene if you want to activate a scene if motion stops |
| 160 | default: scene.none |
| 161 | selector: |
| 162 | entity: |
| 163 | domain: scene |
| 164 | |
| 165 | |
| 166 | mode: restart |
| 167 | max_exceeded: silent |
| 168 | |
| 169 | variables: |
| 170 | scene_ambient: !input scene_ambient |
| 171 | scene_morning: !input scene_morning |
| 172 | scene_day: !input scene_day |
| 173 | scene_evening: !input scene_evening |
| 174 | scene_night: !input scene_night |
| 175 | automation_blocker: !input automation_blocker |
| 176 | automation_blocker_boolean : !input automation_blocker_boolean |
| 177 | no_motion_blocker: !input no_motion_blocker |
| 178 | no_motion_blocker_boolean: !input no_motion_blocker_boolean |
| 179 | elevation_check: !input elevation_check |
| 180 | scene_no_motion: !input scene_no_motion |
| 181 | motion_entity: !input motion_entity |
| 182 | lux_entity: !input lux_entity |
| 183 | lux_threshold: !input lux_threshold |
| 184 | |
| 185 | trigger: |
| 186 | - platform: state |
| 187 | entity_id: !input motion_entity |
| 188 | from: "off" |
| 189 | to: "on" |
| 190 | - platform: state |
| 191 | entity_id: !input motion_entity |
| 192 | from: "on" |
| 193 | to: "off" |
| 194 | for: !input no_motion_wait |
| 195 | |
| 196 | |
| 197 | # All Conditions must be true |
| 198 | condition: |
| 199 | # Check if automation blocker exist or is in desired state, otherwise do not run |
| 200 | - condition: or |
| 201 | conditions: |
| 202 | - "{{ automation_blocker == none }}" |
| 203 | - "{{ automation_blocker_boolean and states[automation_blocker].state == 'on' }}" |
| 204 | - "{{ not automation_blocker_boolean and states[automation_blocker].state == 'off' }}" |
| 205 | # Check if elevation input exist or is below desired value, otherwise do not run |
| 206 | - condition: template |
| 207 | value_template: "{{ (elevation_check == none) or (state_attr('sun.sun','elevation') <= elevation_check | float(90)) }}" |
| 208 | |
| 209 | action: |
| 210 | - choose: |
| 211 | # Trigger to state == "on" |
| 212 | - conditions: |
| 213 | - condition: template |
| 214 | value_template: "{{ trigger.to_state.state == 'on' }}" |
| 215 | - condition: template |
| 216 | value_template: > |
| 217 | {{ states(lux_entity) | float <= lux_threshold | float or states(lux_entity) | float == 0 }} |
| 218 | sequence: |
| 219 | - choose: |
| 220 | # Morning Scene |
| 221 | - conditions: |
| 222 | - "{{ scene_morning != 'scene.none'}}" |
| 223 | - condition: time |
| 224 | after: !input time_scene_morning |
| 225 | before: !input time_scene_day |
| 226 | sequence: |
| 227 | - scene: !input scene_morning |
| 228 | # Day Scene |
| 229 | - conditions: |
| 230 | - "{{ scene_day != 'scene.none'}}" |
| 231 | - condition: time |
| 232 | after: !input time_scene_day |
| 233 | before: !input time_scene_evening |
| 234 | sequence: |
| 235 | - scene: !input scene_day |
| 236 | # Evening Scene |
| 237 | - conditions: |
| 238 | - "{{ scene_evening != 'scene.none'}}" |
| 239 | - condition: time |
| 240 | after: !input time_scene_evening |
| 241 | before: !input time_scene_night |
| 242 | sequence: |
| 243 | - scene: !input scene_evening |
| 244 | # Night Scene |
| 245 | - conditions: |
| 246 | - "{{ scene_night != 'scene.none'}}" |
| 247 | - condition: time |
| 248 | after: !input time_scene_night |
| 249 | before: !input time_scene_morning |
| 250 | sequence: |
| 251 | - scene: !input scene_night |
| 252 | # If State -> "On" defaulting to turn light on |
| 253 | default: |
| 254 | - service: light.turn_on |
| 255 | target: !input light_target |
| 256 | |
| 257 | # Trigger to state == "off" |
| 258 | - conditions: |
| 259 | - condition: template |
| 260 | value_template: "{{ trigger.to_state.state == 'off' }}" |
| 261 | # Check if no motion blocker exist or in in desired state, otherwise do not run any no motion action |
| 262 | - condition: or |
| 263 | conditions: |
| 264 | - "{{ no_motion_blocker == none }}" |
| 265 | - "{{ no_motion_blocker_boolean and states[no_motion_blocker].state == 'on' }}" |
| 266 | - "{{ not no_motion_blocker_boolean and states[no_motion_blocker].state == 'off' }}" |
| 267 | sequence: |
| 268 | - choose: |
| 269 | # Used if ambient scene is true and in ambient scene time frame |
| 270 | - conditions: |
| 271 | - "{{ scene_ambient != 'scene.none' }}" |
| 272 | - condition: time |
| 273 | after: !input time_scene_ambient_start |
| 274 | before: !input time_scene_ambient_end |
| 275 | sequence: |
| 276 | - scene: !input scene_ambient |
| 277 | # Used if default no motion scene is set |
| 278 | - conditions: |
| 279 | - "{{ scene_no_motion != 'scene.none' }}" |
| 280 | sequence: |
| 281 | - scene: !input scene_no_motion |
| 282 | # If State -> "off" default to turn lights off |
| 283 | default: |
| 284 | - service: light.turn_off |
| 285 | target: !input light_target |