Last active 1753703697

Revision d88bbe4898d752ba5cea97b163bb76c60b2af067

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