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