Zuletzt aktiv 1753703697

Änderung 5366ccfa589dbaa6cb96c35d2ded6476f112b651

YAMA.yaml Orginalformat
1blueprint:
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
166mode: restart
167max_exceeded: silent
168
169variables:
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
185trigger:
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
198condition:
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
209action:
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