-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathautomations.yaml
355 lines (285 loc) · 11.5 KB
/
automations.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
##########################################################
## Master Switch Control.
##########################################################
- alias: Master Switch Toggled
trigger:
platform: state
entity_id: sensor.master_switch
action:
service: light.toggle
entity_id: group.livingroom_lights
##########################################################
## Bedroom Switch Control.
##########################################################
- alias: Bedroom Switch Toggled
trigger:
platform: state
entity_id: sensor.bedroom_switch
action:
service: light.toggle
entity_id: group.bedroom_lights
##########################################################
## Kitchen Light Control
##########################################################
- alias: Kitchen motion triggered on
trigger:
platform: template
value_template: "{% if states('sensor.fibaro_system_fgms001_motion_sensor_burglar_2_10') | int == 8 or states('sensor.fibaro_system_fgms001_motion_sensor_burglar_2_10') | int == 3 %}true{% endif %}"
action:
service: light.turn_on
entity_id: light.kitchen_light
- alias: Kitchen motion triggered off
trigger:
platform: state
entity_id: sensor.fibaro_system_fgms001_motion_sensor_burglar_2_10
to: '0'
action:
service: light.turn_off
entity_id: light.kitchen_light
##########################################################
## Closet Light Control
##########################################################
- alias: Closet motion triggered on
trigger:
platform: template
value_template: "{% if states('sensor.aeotec_zw100_multisensor_6_burglar_3_10') | int == 8 or states('sensor.aeotec_zw100_multisensor_6_burglar_3_10') | int == 3 %}true{% endif %}"
action:
service: light.turn_on
entity_id: light.closet
- alias: Closet motion triggered off
trigger:
platform: state
entity_id: sensor.aeotec_zw100_multisensor_6_burglar_3_10
to: '0'
action:
service: light.turn_off
entity_id: light.closet
##########################################################
## Turn on HBO
##########################################################
- alias: Movie Time
trigger:
platform: state
entity_id: input_boolean.hbo
to: 'on'
action:
- service: homeassistant.turn_on
entity_id: switch.projector
- service: media_player.select_source
entity_id: media_player.roku_1gs3d4008651
data:
source: 'HBO GO'
- service: homeassistant.turn_off
entity_id: input_boolean.hbo
- service: scene.turn_on
entity_id: scene.movie_time
##########################################################
## Auto Away Config
##########################################################
- alias: Turn off lights when away.
trigger:
platform: state
entity_id: device_tracker.gundam212iphone_destinyiphone
from: 'home'
to: 'not_home'
action:
- service_template: >
{% if is_state('light.livingroom_lamp', 'on') %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
entity_id: input_boolean.livingroom_lamp_ha
- service_template: >
{% if is_state('light.livingroom_main', 'on') %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
entity_id: input_boolean.livingroom_main_ha
- service_template: >
{% if is_state('light.bedroom_lamp', 'on') %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
entity_id: input_boolean.bedroom_lamp_ha
- service_template: >
{% if is_state('light.livingroom_entry', 'on') %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
entity_id: input_boolean.livingroom_entry_ha
- service: homeassistant.turn_off
entity_id: group.all_lifx_lights
- alias: Return lights depending on timeframe since last on.
trigger:
platform: state
entity_id: device_tracker.gundam212iphone_destinyiphone
from: 'not_home'
to: 'home'
action:
- service_template: >
{% if is_state('input_boolean.bedroom_lamp_ha', 'on') and ( as_timestamp(now()) - states.input_boolean.bedroom_lamp_ha.last_changed.timestamp()) < (states.input_select.autoaway_timeout.state | int * 60) %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
data_template:
entity_id: >
{% if is_state('input_boolean.bedroom_lamp_ha', 'on') and ( as_timestamp(now()) - states.input_boolean.bedroom_lamp_ha.last_changed.timestamp()) < (states.input_select.autoaway_timeout.state | int * 60) %}
light.bedroom_lamp
{% else %}
input_boolean.bedroom_lamp_ha
{% endif %}
- service_template: >
{% if is_state('input_boolean.livingroom_main_ha', 'on') and ( as_timestamp(now()) - states.input_boolean.livingroom_main_ha.last_changed.timestamp()) < (states.input_select.autoaway_timeout.state | int * 60) %}
homeassistant.turn_on
{% elif ( as_timestamp(now()) - states.input_boolean.livingroom_main_ha.last_changed.timestamp()) >= (states.input_select.autoaway_timeout.state | int * 60) %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
data_template:
entity_id: >
{% if is_state('input_boolean.livingroom_main_ha', 'on') and ( as_timestamp(now()) - states.input_boolean.livingroom_main_ha.last_changed.timestamp()) < (states.input_select.autoaway_timeout.state | int * 60) %}
light.livingroom_main
{% elif ( as_timestamp(now()) - states.input_boolean.livingroom_main_ha.last_changed.timestamp()) >= (states.input_select.autoaway_timeout.state | int * 60) %}
light.livingroom_main
{% else %}
input_boolean.livingroom_main_ha
{% endif %}
- service_template: >
{% if is_state('input_boolean.livingroom_lamp_ha', 'on') and ( as_timestamp(now()) - states.input_boolean.livingroom_lamp_ha.last_changed.timestamp()) < (states.input_select.autoaway_timeout.state | int * 60) %}
homeassistant.turn_on
{% elif ( as_timestamp(now()) - states.input_boolean.livingroom_lamp_ha.last_changed.timestamp()) >= (states.input_select.autoaway_timeout.state | int * 60) %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
data_template:
entity_id: >
{% if is_state('input_boolean.livingroom_lamp_ha', 'on') and ( as_timestamp(now()) - states.input_boolean.livingroom_lamp_ha.last_changed.timestamp()) < (states.input_select.autoaway_timeout.state | int * 60) %}
light.livingroom_lamp
{% elif ( as_timestamp(now()) - states.input_boolean.livingroom_lamp_ha.last_changed.timestamp()) >= (states.input_select.autoaway_timeout.state | int * 60) %}
light.livingroom_lamp
{% else %}
input_boolean.livingroom_lamp_ha
{% endif %}
- service_template: >
{% if is_state('input_boolean.livingroom_entry_ha', 'on') and ( as_timestamp(now()) - states.input_boolean.livingroom_entry_ha.last_changed.timestamp()) < (states.input_select.autoaway_timeout.state | int * 60) %}
homeassistant.turn_on
{% elif ( as_timestamp(now()) - states.input_boolean.livingroom_entry_ha.last_changed.timestamp()) >= (states.input_select.autoaway_timeout.state | int * 60) %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
data_template:
entity_id: >
{% if is_state('input_boolean.livingroom_entry_ha', 'on') and ( as_timestamp(now()) - states.input_boolean.livingroom_entry_ha.last_changed.timestamp()) < (states.input_select.autoaway_timeout.state | int * 60) %}
light.livingroom_entry
{% elif ( as_timestamp(now()) - states.input_boolean.livingroom_entry_ha.last_changed.timestamp()) >= (states.input_select.autoaway_timeout.state | int * 60) %}
light.livingroom_entry
{% else %}
input_boolean.livingroom_entry_ha
{% endif %}
##########################################################
## Trigger Lamp Wakeup, Count Snoozes
##########################################################
- alias: Alarm Lamp Wakeup
trigger:
platform: state
entity_id: input_boolean.alarm_triggered
to: 'on'
action:
- service: input_slider.select_value
data_template:
entity_id: input_slider.alarm_snoozecount
value: '{{ (states.input_slider.alarm_snoozecount.state | int) + 1 }}'
- service: homeassistant.turn_off
entity_id: input_boolean.alarm_triggered
- service: light.turn_on
entity_id: light.bedroom_lamp
data:
brightness: 255
transition: 60
##########################################################
## If Snoozes is greater than set value
##########################################################
- alias: Snoozed Greater than Set Value
trigger:
platform: template
value_template: '{{ (states.input_slider.alarm_snoozecount.state | int) >= (states.input_select.alarm_snooze_limit.state | int ) }}'
action:
- service: homeassistant.turn_on
entity_id: input_boolean.alarmclock_snooze
##########################################################
## Turn off Snooze
##########################################################
- alias: Turn off Snooze.
trigger:
platform: state
entity_id: input_boolean.alarmclock_snooze
to: 'off'
action:
- service: light.turn_on
entity_id: light.bedroom_lamp
- service: input_slider.select_value
data_template:
entity_id: input_slider.alarm_snoozecount
value: '0'
##########################################################
## Flash Lamp
##########################################################
- alias: Flash Lamp For Alarm
trigger:
platform: time
seconds: /2
condition:
condition: state
entity_id: input_boolean.alarmclock_snooze
state: 'on'
action:
service: light.toggle
entity_id: light.bedroom_lamp
##########################################################
## Reset Notifications when I leave
##########################################################
- alias: Reset notifications when I leave (hacky)
trigger:
platform: state
entity_id: device_tracker.gundam212iphone_destinyiphone
from: 'home'
to: 'not_home'
for:
seconds: 10
action:
- service: homeassistant.turn_off
entity_id: input_boolean.motion_away_trigger
- service: homeassistant.turn_off
entity_id: input_boolean.ups_power_trigger
##########################################################
## Detect if Motion/Lights Triggered While Away
##########################################################
- alias: Detect Motion Lights Triggered While Away
trigger:
platform: template
value_template: '{{ (states.group.all_lifx_lights.state == "on") }}'
condition:
condition: state
entity_id: device_tracker.gundam212iphone_destinyiphone
state: 'not_home'
action:
service: homeassistant.turn_on
entity_id: input_boolean.motion_away_trigger
##########################################################
## Detect if UPS switches to battery power.
##########################################################
- alias: Detect UPS Switch to Battery
trigger:
platform: state
entity_id: sensor.ups_transfer_count
action:
service: homeassistant.turn_on
entity_id: input_boolean.ups_power_trigger