Last active 1753703697

Revision e92d8bcaa41b1e94ce1e14e34aab3deb92f5be8c

YAMA.yaml Raw
1blueprint:
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
191mode: restart
192max_exceeded: silent
193variables:
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
208trigger:
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
218condition:
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)) }}'
230action:
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