-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomations.yaml
748 lines (684 loc) · 18.4 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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
# Prep the bedroom for sleep on nights when we have work the next day
- alias: Bedroom Nightime
initial_state: true
trigger:
- at: '21:45:00'
platform: time
condition:
condition: time
weekday:
- mon
- tue
- wed
- thu
- sun
action:
- service: script.bedroom_nighttime
# At 7am, wake the room up, on the weekdays
- alias: Bedroom Morning
initial_state: true
trigger:
- platform: time
at: '7:00:00'
condition:
condition: and
conditions:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: sensor.bed_occupancy
state: 'Occupied'
action:
- service: script.bedroom_morning
# Run the robot vaccum on Tuesday and Thursday @10am
- alias: Consuela Clean House
initial_state: true
trigger:
- platform: time
at: '10:00:00'
condition:
condition: time
weekday:
- tue
- thu
action:
- service: switch.turn_on
entity_id: switch.eufy_robovac
- service: notify.house_members
data:
message: "Consuela is hard at work making your house clean for you when you get home"
# Turn on electric blanket at 9:30pm when it is less than 55°F outside
- alias: Turn on Electric Blanket
initial_state: true
trigger:
- platform: time
at: '21:30:00'
condition:
condition: template
value_template: '{{ states.weather.dark_sky.attributes.temperature < 60 }}'
action:
- service: switch.turn_on
data:
entity_id: switch.heated_blanket
# Turn off electric blanket at 10:15
- alias: Turn off Electric Blanket
initial_state: true
trigger:
- platform: time
at: '22:15:00'
condition:
condition: state
entity_id: switch.heated_blanket
state: 'on'
action:
- service: switch.turn_off
data:
entity_id: switch.heated_blanket
# Turn on living room lamp and close curtains 20 minutes before sunset
- alias: Lamp at Sunset
initial_state: true
trigger:
- event: sunset
offset: -00:20:00
platform: sun
action:
- service: switch.turn_on
data:
entity_id:
- switch.living_room_lamp
- switch.outside_christmas_lights
- switch.christmas_tree
- switch.garland
- service: light.turn_on
data:
entity_id: light.kitchen_cabinets
- service: cover.close_cover
data:
entity_id: cover.bedroom_window_coverings
# Turn off living_room_lamp and porch_switch at 10pm
- alias: Turn off Lamp
initial_state: true
trigger:
- at: '22:00:00'
platform: time
action:
- service: switch.turn_off
data:
entity_id:
- switch.living_room_lamp
- switch.kitchen_switch
- switch.porch_switch
- switch.exterior_garage_light
- switch.garage_shelf_light
- switch.garage_door_shelf_light
- switch.garage_light
- switch.christmas_tree
- switch.garland
- switch.outside_christmas_lights
- switch.fireplace
- service: light.turn_off
data:
entity_id:
- light.kitchen_cabinets
- light.kitchen_switch
# On travel turn on
- alias: AWAY
initial_state: true
trigger:
platform: state
entity_id: input_boolean.away
to: 'on'
action:
- service: automation.turn_off
data:
entity_id:
- automation.bedroom_morning
- automation.bedroom_nightime
- automation.turn_on_electric_blanket
- automation.turn_on_porch_light_at_dusk
- service: climate.set_away_mode
data:
entity_id: climate.hallway
away_mode: 'on'
# On travel turn off
- alias: HOME
trigger:
platform: state
entity_id: input_boolean.away
to: 'off'
action:
- service: automation.turn_on
data:
entity_id:
- automation.bedroom_morning
- automation.bedroom_nightime
- automation.turn_on_electric_blanket
- automation.turn_on_porch_light_at_dusk
# Turn on office light with motion when dark
# 20 min before sunset or 20 min after sunset
- alias: Turn on Office Light w/ Motion
trigger:
- platform: state
entity_id: sensor.office_motion
to: 'Motion'
condition:
condition: or
conditions:
- condition: sun
after: sunset
after_offset: "-00:20:00"
- condition: sun
before: sunrise
before_offset: "00:20:00"
action:
service: switch.turn_on
entity_id: switch.office_lamp
# Turn off office lights 15 minutes after motion stops
- alias: Turn off Office Light w/o Motion
trigger:
platform: state
entity_id: sensor.office_motion
to: 'No Motion'
for:
minutes: 15
action:
service: switch.turn_off
entity_id:
- switch.office_lamp
- switch.office_closet
# Turn on office closet light with motion
- alias: Turn on Office Closet Light w/ Motion
trigger:
- platform: state
entity_id: binary_sensor.office_closet_occupancy
to: 'on'
action:
service: switch.turn_on
entity_id: switch.office_closet
# Turn off office closet light with no motion for 20 minutes
- alias: Turn off Office Closet Light w/o Motion
trigger:
- platform: state
entity_id: binary_sensor.office_closet_occupancy
to: 'off'
for:
minutes: 20
action:
service: switch.turn_off
entity_id: switch.office_closet
# Turn off office closet after 30 minutes of being left on
- alias: Turn off Office Closet
trigger:
platform: state
entity_id: switch.office_closet
from: 'off'
to: 'on'
for:
minutes: 30
action:
service: switch.turn_off
entity_id: switch.office_closet
# Turn on porch switch at dusk (15 minutes before sunset)
# If outside christmas lights are plugged in, turn them on instead of the
# exterior garage light
- alias: Turn on porch light at dusk
trigger:
- platform: sun
event: sunset
offset: "-00:15:00"
action:
service: switch.turn_on
data_template:
entity_id: >
{% if is_state("switch.outside_christmas_lights","unavailable") %}
switch.exterior_garage_light, switch.porch_switch
{%- else -%}
switch.outside_christmas_lights, switch.porch_switch
{%- endif %}
# Turn off porch switch at 9:45pm
- alias: Turn off porch light at 9:45PM
trigger:
- platform: time
at: '21:45:00'
action:
service: switch.turn_off
entity_id:
- switch.porch_switch
- switch.exterior_garage_light
# Turn off porch switch at sunrise if left on
- alias: Turn off porch light at sunrise
trigger:
- platform: sun
event: sunrise
offset: -00:02:00
action:
service: switch.turn_off
entity_id:
- switch.porch_switch
- switch.exterior_garage_light
# Adjust Flux color when flux lights turn on
- alias: Adjust Flux Color
trigger:
- platform: state
entity_id:
- light.kitchen_cabinets
- light.cornice
to: 'on'
action:
service: switch.fluxer_update
# Turn on porch light when front door opens and the sun isn't up and christmas lights are not on
- alias: Turn on Porch Light w/ Door
trigger:
- platform: state
entity_id: binary_sensor.front_door
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: template
value_template: "{{ not is_state('switch.outside_christmas_lights', 'on') }}"
- condition: or
conditions:
- condition: sun
after: sunset
after_offset: "00:05:00"
- condition: sun
before: sunrise
action:
service: switch.turn_on
entity_id:
- switch.porch_switch
- switch.exterior_garage_light
- switch.living_room_lamp
# Turn off porch light ten minutes after front door opens after 9:45PM and until 10 minutes after sunrise
- alias: Turn off Porch Light after Door Close
trigger:
- platform: state
entity_id: binary_sensor.front_door
from: 'on'
to: 'off'
for:
minutes: 10
condition:
condition: or
conditions:
- condition: time
after: '21:45:00'
- condition: sun
before: sunrise
before_offset: "00:10:00"
action:
service: switch.turn_off
entity_id:
- switch.porch_switch
- switch.exterior_garage_light
- switch.living_room_lamp
# Turn on garage light when wither door opens, or motion is detected
# between 5 minutes before sunset until sunrise
- alias: Turn on Garage Light w/ Door
trigger:
- platform: state
entity_id:
- binary_sensor.garage_house_door
- binary_sensor.garage_occupancy
from: 'off'
to: 'on'
- platform: state
entity_id: cover.garage_door_opener
from: 'closed'
to: 'open'
condition:
condition: or
conditions:
- condition: sun
after: sunset
after_offset: "-00:05:00"
- condition: sun
before: sunrise
action:
service: switch.turn_on
entity_id:
- switch.garage_light
- switch.garage_shelf_light
- switch.garage_door_shelf_light
# Turn off garage light ten minutes after either garage door closes, or motion is no longer detected
# between 5 minutes before sunset and 15 minutes after sunrise
- alias: Turn off Garage Light after Door Close
trigger:
- platform: state
entity_id:
- binary_sensor.garage_house_door
- binary_sensor.garage_occupancy
from: 'on'
to: 'off'
for:
minutes: 10
- platform: state
entity_id: cover.garage_door_opener
from: 'open'
to: 'closed'
for:
minutes: 10
condition:
condition: or
conditions:
- condition: sun
after: sunset
after_offset: "-00:05:00"
- condition: sun
before: sunrise
before_offset: "00:15:00"
action:
service: switch.turn_off
entity_id:
- switch.garage_light
- switch.garage_shelf_light
- switch.garage_door_shelf_light
# Notify Josh when Sam gets home
- alias: Message when Sam comes home
trigger:
- platform: state
entity_id: device_tracker.sams_phone
#from: 'away'
to: 'home'
for:
minutes: 10
action:
service: notify.josh_phone
data:
message: "Hey your girl just got home!!"
# If moisture is detected beneath the sink
- alias: Leaky Sink
trigger:
- platform: state
entity_id: binary_sensor.kitchen_sink_moisture
to: 'on'
action:
- service: notify.house_members
data:
message: "Moisture detected underneath the sink!!! Quick action required!!"
- service: tts.google_say
entity_id:
- media_player.master_bedroom_speaker
- media_player.kitchen_speaker
- media_player.garage_speaker
- media_player.gh_home_hub
data:
message: "The sink is leaking, please address immediately"
# Turn on Laundry room light with motion
- alias: Laundry Light On
trigger:
- platform: state
entity_id: binary_sensor.laundry_room_occupancy
to: 'on'
action:
service: switch.turn_on
entity_id: switch.laundry_room_light
# Turn off Laundry room light with motion
- alias: Laundry Light Off
trigger:
- platform: state
entity_id: binary_sensor.laundry_room_occupancy
to: 'off'
for:
minutes: 10
action:
service: switch.turn_off
entity_id: switch.laundry_room_light
# Refrigerator is off, attempt to turn back on
- alias: Fridge looses power
trigger:
- platform: state
entity_id: switch.refrigerator_power
to: 'off'
for:
minutes: 15
- platform: state
entity_id: switch.refrigerator_power
to: 'unavailable'
for:
minutes: 15
# - platform: state
# entity_id: device_tracker.refridgerator
# to: 'not_home'
# for:
# minutes: 10
action:
- service: switch.turn_on
entity_id: switch.refrigerator_power
- service: notify.house_members
data:
message: "Refrigerator has lost power, act quickly to save food!"
- service: tts.google_say
entity_id:
- media_player.master_bedroom_speaker
- media_player.kitchen_speaker
data:
message: "The refridgerator has lost power!"
# Playing Movies
- alias: Play Movies
trigger:
- platform: state
entity_id: media_player.plex_shield_android_tv
from: 'paused'
to: 'playing'
condition:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
action:
- service: switch.turn_off
entity_id:
- switch.living_room_lamp
- switch.fluxer
- service: light.turn_on
data:
brightness_pct: 5
kelvin: 2000
entity_id:
- light.kitchen_switch
- light.kitchen_cabinets
- alias: Pause Movies
trigger:
- platform: state
entity_id: media_player.plex_shield_android_tv
from: 'playing'
to: 'paused'
condition:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
action:
- service: switch.turn_on
entity_id:
- switch.living_room_lamp
- service: light.turn_on
data:
brightness_pct: 100
kelvin: 2000
entity_id:
- light.kitchen_switch
- light.kitchen_cabinets
- alias: Movie Stop
trigger:
- platform: state
entity_id: media_player.plex_shield_android_tv
to: 'idle'
action:
service: switch.turn_on
entity_id:
- switch.fluxer
# When HA starts
- alias: HASS Startup
trigger:
- platform: homeassistant
event: start
action:
- service: switch.turn_on
entity_id:
- switch.refrigerator_power
- switch.washing_machine_power
- service: notify.josh_phone
data:
message: "Home Assitant is back up and running"
# Security when away
- alias: Away Security
trigger:
- platform: state
entity_id:
- sensor.living_room_motion
- sensor.office_motion
to: 'Motion'
- platform: state
entity_id:
- binary_sensor.front_door
- binary_sensor.garage_house_door
- binary_sensor.patio_door
- binary_sensor.kitchen_window
to: 'on'
- platform: state
entity_id: cover.garage_door_opener
to: 'opened'
condition:
- condition: state
entity_id: input_boolean.away
state: 'on'
action:
- service: notify.house_members
data_template:
message: 'ALERT!!! {{trigger.entity_id}} went from {{trigger.from_state.state}} to {{trigger.to_state.state}}'
# Bedroom Cube Turn off light
- alias: bedroom cube off
trigger:
- platform: template
value_template: "{{ is_state_attr('sensor.master_bedroom_cube','from_side', 0) }}"
# entity_id: sensor.master_bedroom_cube.attributes.from_side
# from: '0'
action:
- service: light.toggle
entity_id: group.bedroom_lights
# Bedroom Cube Turn on light
- alias: bedroom cube on
trigger:
- platform: template
value_template: "{{ is_state_attr('sensor.master_bedroom_cube','to_side', 0) }}"
# entity_id: sensor.master_bedroom_cube.attributes.from_side
# from: '0'
action:
- service: light.toggle
entity_id: group.bedroom_lights
# Syncs the shelf lights with the garage overhead light
- alias: Sync Garage Lights
trigger:
- platform: state
entity_id: switch.garage_light
action:
service_template: >
switch.turn_{{ 'on' if trigger.to_state.state == 'on' else 'off'}}
data:
entity_id:
- switch.garage_shelf_light
- switch.garage_door_shelf_light
# Turns off lights when you get into bed after 9pm and before 7am
- alias: Turn lights off when in bed
trigger:
- platform: state
entity_id: input_select.bed_occupancy
to: 'Sam & Josh'
for:
seconds: 10
condition:
- condition: time
after: '21:00:00'
before: '7:00:00'
action:
- service: light.turn_off
data:
entity_id: light.bedroom_lights
# Turn on red underbed lights when getting out of bed after 10pm and before 7am
- alias: Turn on bed night lights
trigger:
- platform: state
entity_id: sensor.bed_occupancy
from: 'Sam & Josh'
condition:
- condition: time
after: '22:00:00'
before: '7:00:00'
action:
- service: light.turn_on
data:
entity_id: light.underbed_leds
brightness_pct: 15
rgb_color: [255, 0, 0]
# Turn off night light 10 minutes after it turned on, if hasn't turned off already
- alias: Turn off bed night lights
trigger:
- platform: state
entity_id: light.underbed_leds
to: 'on'
for:
minutes: 10
condition:
condition: and
conditions:
- condition: time
after: '22:00:00'
before: '7:00:00'
- condition: template
value_template: "{{ state_attr('light.underbed_leds', 'brightness') < 40 }}"
action:
- service: light.turn_on
data:
entity_id: light.underbed_leds
brightness_pct: 15
rgb_color: [255, 0, 0]
# - alias: Play random audio clip
# initial_state: true
# trigger:
# - platform: state
# entity_id: light.kitchen_switch
# to: 'on'
# action:
# - service: media_player.play_media
# data_template:
# entity_id: media_player.gh_home_hub
# media_content_type: 'audio/wav'
# media_content_id: >
# https://hass.joshilles.com/local/audio/
# {{- [
# "silence_lambs_liver.wav",
# "silence_lambs_lotion.wav",
# "silence_lambs_hose.wav",
# "t1_be_back.wav",
# "t1_terminated.wav",
# "t2_hasta_la_vista.wav",
# "t3_postponed.wav",
# "christmas_vacation_no_good.wav",
# "bushw_eavesdropping1.wav"
# ] | random
# }}
# - alias: Plex webhooks
# trigger:
# platform: webhook
# webhook_id: 'plex'
# action:
# - service: system_log.write
# data_template:
# level: 'warning'
# message: >
# {% set place_holder = trigger.data.payload.__class__.__name__ %}
# {{ place_holder }}
# # {% set place_holder = trigger.data.payload.decode()|tojson %}
# # {{ place_holder["event"] }}
# - service: notify.josh_phone
# data_template:
# message: >
# {% set place_holder = trigger.data.payload.__class__.__name__ %}
# {{ place_holder }}