YAMA.yaml
· 8.8 KiB · YAML
Неформатований
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
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
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'' }}'
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 | no_motion_wait: |
| 30 | name: Wait time |
| 31 | description: Time to leave the light on after last motion is detected. |
| 32 | default: 120 |
| 33 | selector: |
| 34 | number: |
| 35 | min: 0.0 |
| 36 | max: 3600.0 |
| 37 | unit_of_measurement: seconds |
| 38 | step: 1.0 |
| 39 | mode: slider |
| 40 | automation_blocker: |
| 41 | name: Automation Blocker (Optional) |
| 42 | description: Only run if this boolean is in desired state (see next input) |
| 43 | default: |
| 44 | selector: |
| 45 | entity: {} |
| 46 | automation_blocker_boolean: |
| 47 | name: Automation Blocker Chooser (Optional) |
| 48 | description: Desired state of automation blocker, choose on for on and off for |
| 49 | off |
| 50 | default: false |
| 51 | selector: |
| 52 | boolean: {} |
| 53 | no_motion_blocker: |
| 54 | name: No Motion Blocker (Optional) |
| 55 | description: No motion sequence is not run if this boolean is in desired state |
| 56 | (see next input) |
| 57 | default: |
| 58 | selector: |
| 59 | entity: {} |
| 60 | no_motion_blocker_boolean: |
| 61 | name: No Motion Chooser (Optional) |
| 62 | description: Desired state of no motion blocker, choose on for on and off for |
| 63 | off |
| 64 | default: false |
| 65 | selector: |
| 66 | boolean: {} |
| 67 | elevation_check: |
| 68 | name: Sun elevation check (Optional) |
| 69 | description: This is the angle between the sun and the horizon. Negative values |
| 70 | mean the sun is BELOW the horizon. |
| 71 | default: none |
| 72 | selector: |
| 73 | number: |
| 74 | min: -90.0 |
| 75 | max: 90.0 |
| 76 | unit_of_measurement: degrees |
| 77 | step: 1.0 |
| 78 | mode: slider |
| 79 | scene_ambient: |
| 80 | name: Ambient Scene (Optional) |
| 81 | description: Scene for ambient state. Will be activated when no motion is detected. |
| 82 | default: scene.none |
| 83 | selector: |
| 84 | entity: |
| 85 | domain: |
| 86 | - scene |
| 87 | multiple: false |
| 88 | time_scene_ambient_start: |
| 89 | name: Ambient time frame start (Optional) |
| 90 | description: Time from which on ambient scene will be activated |
| 91 | default: 00:00:00 |
| 92 | selector: |
| 93 | time: {} |
| 94 | time_scene_ambient_end: |
| 95 | name: Ambient time frame end (Optional) |
| 96 | description: Time from which on ambient scene will be not activated |
| 97 | default: 00:00:00 |
| 98 | selector: |
| 99 | time: {} |
| 100 | scene_morning: |
| 101 | name: Scene for the morning (Optional) |
| 102 | default: scene.none |
| 103 | selector: |
| 104 | entity: |
| 105 | domain: |
| 106 | - scene |
| 107 | multiple: false |
| 108 | time_scene_morning: |
| 109 | name: Time for the morning scene (Optional) |
| 110 | description: A time input which defines the time from which on the scene will |
| 111 | be activated if motion is detected. |
| 112 | default: 00:00:00 |
| 113 | selector: |
| 114 | time: {} |
| 115 | scene_day: |
| 116 | name: Scene for the bright day (Optional) |
| 117 | default: scene.none |
| 118 | selector: |
| 119 | entity: |
| 120 | domain: |
| 121 | - scene |
| 122 | multiple: false |
| 123 | time_scene_day: |
| 124 | name: Time for the day scene (Optional) |
| 125 | description: A time input which defines the time from which on the scene will |
| 126 | be activated if motion is detected. |
| 127 | default: 00:00:00 |
| 128 | selector: |
| 129 | time: {} |
| 130 | scene_evening: |
| 131 | name: Scene for the evening (Optional) |
| 132 | default: scene.none |
| 133 | selector: |
| 134 | entity: |
| 135 | domain: |
| 136 | - scene |
| 137 | multiple: false |
| 138 | time_scene_evening: |
| 139 | name: Time for the evening scene (Optional) |
| 140 | description: A time input which defines the time from which on the scene will |
| 141 | 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: |
| 151 | - scene |
| 152 | multiple: false |
| 153 | time_scene_night: |
| 154 | name: Time for the night scene (Optional) |
| 155 | description: A time input which defines the time from which on the scene will |
| 156 | be activated if motion is detectedd. |
| 157 | default: 00:00:00 |
| 158 | selector: |
| 159 | time: {} |
| 160 | scene_no_motion: |
| 161 | name: Default scene for no motion (Optional) |
| 162 | description: Set this Scene if you want to activate a scene if motion stops |
| 163 | default: scene.none |
| 164 | selector: |
| 165 | entity: |
| 166 | domain: |
| 167 | - scene |
| 168 | multiple: false |
| 169 | mode: restart |
| 170 | max_exceeded: silent |
| 171 | variables: |
| 172 | scene_ambient: !input scene_ambient |
| 173 | scene_morning: !input scene_morning |
| 174 | scene_day: !input scene_day |
| 175 | scene_evening: !input scene_evening |
| 176 | scene_night: !input scene_night |
| 177 | automation_blocker: !input automation_blocker |
| 178 | automation_blocker_boolean: !input automation_blocker_boolean |
| 179 | no_motion_blocker: !input no_motion_blocker |
| 180 | no_motion_blocker_boolean: !input no_motion_blocker_boolean |
| 181 | elevation_check: !input elevation_check |
| 182 | scene_no_motion: !input scene_no_motion |
| 183 | motion_entity: !input motion_entity |
| 184 | trigger: |
| 185 | - platform: state |
| 186 | entity_id: !input motion_entity |
| 187 | from: 'off' |
| 188 | to: 'on' |
| 189 | - platform: state |
| 190 | entity_id: !input motion_entity |
| 191 | from: 'on' |
| 192 | to: 'off' |
| 193 | for: !input no_motion_wait |
| 194 | condition: |
| 195 | - condition: or |
| 196 | conditions: |
| 197 | - '{{ automation_blocker == none }}' |
| 198 | - '{{ automation_blocker_boolean and states[automation_blocker].state == ''off'' |
| 199 | }}' |
| 200 | - '{{ not automation_blocker_boolean and states[automation_blocker].state == ''on'' |
| 201 | }}' |
| 202 | - '{{ trigger.to_state.state == ''off'' }}' |
| 203 | - condition: template |
| 204 | value_template: '{{ (trigger.to_state.state == ''off'') or (elevation_check is none) |
| 205 | or (state_attr(''sun.sun'', ''elevation'') <= elevation_check | float(90)) }}' |
| 206 | action: |
| 207 | - choose: |
| 208 | - conditions: |
| 209 | - condition: template |
| 210 | value_template: '{{ trigger.to_state.state == ''on'' }}' |
| 211 | sequence: |
| 212 | - choose: |
| 213 | - conditions: |
| 214 | - '{{ scene_morning != ''scene.none''}}' |
| 215 | - condition: time |
| 216 | after: !input time_scene_morning |
| 217 | before: !input time_scene_day |
| 218 | sequence: |
| 219 | - scene: !input scene_morning |
| 220 | - conditions: |
| 221 | - '{{ scene_day != ''scene.none''}}' |
| 222 | - condition: time |
| 223 | after: !input time_scene_day |
| 224 | before: !input time_scene_evening |
| 225 | sequence: |
| 226 | - scene: !input scene_day |
| 227 | - conditions: |
| 228 | - '{{ scene_evening != ''scene.none''}}' |
| 229 | - condition: time |
| 230 | after: !input time_scene_evening |
| 231 | before: !input time_scene_night |
| 232 | sequence: |
| 233 | - scene: !input scene_evening |
| 234 | - conditions: |
| 235 | - '{{ scene_night != ''scene.none''}}' |
| 236 | - condition: time |
| 237 | after: !input time_scene_night |
| 238 | before: !input time_scene_morning |
| 239 | sequence: |
| 240 | - scene: !input scene_night |
| 241 | default: |
| 242 | - service: light.turn_on |
| 243 | target: !input light_target |
| 244 | - conditions: |
| 245 | - condition: template |
| 246 | value_template: '{{ trigger.to_state.state == ''off'' }}' |
| 247 | - condition: or |
| 248 | conditions: |
| 249 | - '{{ no_motion_blocker is none }}' |
| 250 | - '{{ no_motion_blocker_boolean and states[no_motion_blocker].state == ''off'' |
| 251 | }}' |
| 252 | - '{{ not no_motion_blocker_boolean and states[no_motion_blocker].state == ''on'' |
| 253 | }}' |
| 254 | sequence: |
| 255 | - choose: |
| 256 | - conditions: |
| 257 | - '{{ scene_ambient != ''scene.none'' }}' |
| 258 | - condition: time |
| 259 | after: !input time_scene_ambient_start |
| 260 | before: !input time_scene_ambient_end |
| 261 | sequence: |
| 262 | - scene: !input scene_ambient |
| 263 | - conditions: |
| 264 | - '{{ scene_no_motion != ''scene.none'' }}' |
| 265 | sequence: |
| 266 | - scene: !input scene_no_motion |
| 267 | default: |
| 268 | - service: light.turn_off |
| 269 | target: !input light_target |