-
Notifications
You must be signed in to change notification settings - Fork 52
/
scripts.yaml
432 lines (402 loc) Β· 12.1 KB
/
scripts.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
############
# Presence #
############
# Turn off master and common room things, arm security
home_empty:
sequence:
- action: homeassistant.turn_on
data:
entity_id: input_boolean.security_status
- action: homeassistant.turn_off
data:
entity_id:
- group.master_bedroom
- group.master_bathroom_lights
- group.common_areas
# Start Christmas
- switch.master_bedroom_christmas_tree #manually turn off because of goodnight script
# End Christmas
- media_player.kitchen_photo_frame
- media_player.office_photo_frame
- media_player.misc_photo_frame
# Start Christmas
# If before dark, turn off christmas trees in front
- if: "{{ now().hour < 16 }}"
then:
- action: switch.turn_off
entity_id:
- switch.office_christmas_tree
- switch.dining_room_christmas_tree
# End Christmas
# Turn on lights and disarm security
home_occupied:
sequence:
- action: homeassistant.turn_off
data:
entity_id: input_boolean.security_status
- if: "{{ now().hour <= 7 or now().hour >= 18}}"
then:
- action: light.turn_on
data:
entity_id:
- light.master_bedroom_lamps
#- light.living_room_sconces
# Not so bright if it's late..
brightness: >
{% if now().hour <= 7 or now().hour >= 22 %}
128
{% else %}
254
{% endif %}
- action: homeassistant.turn_on
data:
entity_id:
- group.under_cabinet_lights
# Start Christmas
- group.christmas # Christmas -- FYI: dining, office, master tree follow 'on' via appdaemon
- switch.master_bedroom_christmas_tree # Christmas -- we manually turn on because of goodnight script
# End Christmas
- action: media_player.turn_on
entity_id:
- media_player.kitchen_photo_frame
- media_player.office_photo_frame
# Only turn on guest bathroom frame if guest mode
- if: "{{ is_state('input_boolean.guest_mode', 'on') }}"
then:
- action: media_player.turn_on
entity_id:
- media_player.misc_photo_frame
- if: "{{ now().hour <= 7 or now().hour >= 18}}"
then:
- action: light.turn_on
data:
entity_id:
- light.guest_bedroom_nightstand_lamp
- light.back_bedroom_dresser_lamp
- light.back_bedroom_nightstand_lamp
#- light.living_room_sconces
# Not so bright if it's late..
brightness: >
{% if now().hour <= 7 or now().hour >= 22 %}
128
{% else %}
254
{% endif %}
############
# SECURITY #
############
security_disarm:
sequence:
- action: script.noop
# - action: alarm_control_panel.alarm_disarm
# entity_id: alarm_control_panel.alexa_guard_7f9e9
# - action: script.notify_wrapper
# data:
# message: Disarmed!
security_arm:
sequence:
# - action: alarm_control_panel.alarm_arm_away
# entity_id: alarm_control_panel.alexa_guard_7f9e9
- action: homeassistant.turn_on
entity_id: automation.frigate_notification_person
- action: timer.cancel
entity_id: timer.frigate_notification_snooze
# - action: script.notify_wrapper
# data:
# message: Armed!
##########
# SCENES #
##########
master_bedroom_wakeup:
sequence:
# Start Christmas
- if: "{{ now().hour < 11 }}"
then:
- action: script.turn_on
entity_id:
- script.christmas_wakeup
# End Christmas
- action: cover.open_cover
entity_id: cover.master_bedroom_blinds
- action: switch.turn_off
data:
entity_id: switch.master_bedroom_ceiling_fan
- delay: "00:00:02"
- action: script.appdaemon_ac_morning
- action: light.turn_on
target:
entity_id: light.master_bedroom_lamps
data:
transition: "{% if 30 > (as_timestamp(now()) - as_timestamp(states.switch.master_bedroom_ceiling_fan.last_changed) | round(0)) %}45{% else %}2{% endif %}"
brightness: 255
- action: homeassistant.turn_off
entity_id: input_boolean.goodnight
- action: homeassistant.turn_on
entity_id:
# Start Christmas
- group.christmas
# End Christmas
- media_player.kitchen_photo_frame
- media_player.office_photo_frame
master_bedroom_bedtime:
sequence:
- action: cover.close_cover
entity_id: cover.master_bedroom_blinds
# Start Christmas
- action: script.turn_on # Calling this way allows the sequence to continue without blocking
entity_id: script.christmas_goodnight
# End Christmas
- action: script.appdaemon_ac_night
- action: switch.turn_on #revert this
data:
entity_id: switch.master_bedroom_ceiling_fan
#- action: switch.turn_on
# data:
# entity_id: switch.master_bedroom_sound_machine
- action: light.turn_off
data:
entity_id: light.master_bedroom_ceiling_fan
transition: 5
- action: light.turn_off
data:
entity_id: light.master_bedroom_lamps
transition: 5
- action: homeassistant.turn_off
data:
entity_id: group.off_at_bedtime
- action: homeassistant.turn_on
entity_id: input_boolean.goodnight
# - action: lock.lock
# target:
# entity_id:
# - lock.front_door
# - lock.garage_exterior_door
# - lock.back_door
- if: "{{ states('input_boolean.guest_mode') == 'off' }}"
then:
- action: light.turn_off
entity_id:
- light.guest_bedroom_nightstand_lamp
- light.back_bedroom_nightstand_lamp
# Lower laptop volume
- action: shell_command.weasel_shortcut
data:
shortcut: set-volume-15
#########
# OTHER #
#########
# Change notification platform if internet offline,
notify_wrapper:
mode: parallel
sequence:
- if: '{{ states("binary_sensor.internet_reachability") == "on" }}'
then:
# If internet on and priority set: send via pushover
- if: '{{ "priority" in data }}'
then:
- action: notify.pushover
continue_on_error: true
data:
message: "{{ message }}"
data:
priority: "{{ data.priority }}"
expire: 600
retry: 30
- action: notify.signal_homeassistant
data:
message: "{{ message }}"
# If internet on and no priority set: send via signal
else:
- action: notify.signal_homeassistant
continue_on_error: true
data:
message: "{{ message }}"
# Mirror to WearOS
- action: notify.mobile_app_galaxy_watch6_kqbw
data:
message: "{{ message }}"
data:
ttl: 0
priority: high
else:
# If no internet: send via cellular
- if: '{{ "priority" in data }}'
then:
- action: notify.cellular_message
data:
message: "{{ message }}"
data:
priority: "{{ data.priority }}" # passing priority to the notify_wrapper script is optional default 0
# https://pushover.net/api#priority
else:
- action: notify.cellular_message
data:
message: "{{ message }}"
copy:
sequence:
- action: shell_command.copy
appdaemon_ac_night:
sequence:
# Also constrained by boolean in appdaemon
- condition: state
entity_id: input_boolean.ac_automation
state: "on"
- action: rest_command.adjust_night
appdaemon_ac_morning:
sequence:
# Also constrained by boolean in appdaemon
- condition: state
entity_id: input_boolean.ac_automation
state: "on"
- action: rest_command.adjust_morning
too_cold:
sequence:
- action: climate.set_temperature
data:
entity_id: climate.thermostat
temperature: "{{ float(states('sensor.thermostat_temperature')) + 2 }}"
too_hot:
sequence:
- action: climate.set_temperature
data:
entity_id: climate.thermostat
temperature: "{{ float(states('sensor.thermostat_temperature')) - 1 }}"
turn_ac_off:
sequence:
- action: climate.turn_off
data:
entity_id: climate.thermostat
# Triggered by appdaemon app
# See associated automation
panic:
sequence:
- action: notify.pushover
data:
message: "Help!"
title: "Panic!!"
data:
priority: 2
expire: 3600
retry: 30
callback: !secret panic_script_webhook_full
spotify_occusim_start:
sequence:
- action: media_player.select_source
data:
entity_id: media_player.spotify
source: "Everywhere"
- action: media_player.volume_set
data:
entity_id: media_player.spotify
volume_level: 0.6
- action: media_player.media_play
data:
entity_id: media_player.spotify
spotify_occusim_stop:
sequence:
- action: media_player.media_pause
data:
entity_id: media_player.spotify
andrew_phone_update_location:
sequence:
- action: notify.mobile_app_andrew_phone
data:
message: "request_location_update"
# Do nothing but act as a placeholder in "else" calls when using scripts in automation
noop:
sequence:
- delay: "00:00:00"
desk_led_red:
sequence:
- action: homeassistant.turn_off
entity_id: light.desk_led
- action: homeassistant.turn_on
entity_id: light.desk_led
data:
rgb_color: [255, 0, 0]
brightness: 255
#effect: "custom scan"
effect: "fast pulse"
desk_led_white:
sequence:
- action: homeassistant.turn_off
entity_id: light.desk_led
- action: homeassistant.turn_on
entity_id: light.desk_led
data:
rgb_color: [255, 255, 255]
brightness: 255
#effect: "custom scan"
effect: "fast pulse"
# Launch app on Android phone
andrew_phone_launch_watch_manager:
sequence:
- action: notify.mobile_app_andrew_phone
data:
message: "command_launch_app"
data:
package_name: "com.samsung.android.app.watchmanager"
ttl: 0
priority: high
andrew_double_latte:
alias: Make Andrew Double Latte
sequence:
- repeat:
count: 2
sequence:
- action: button.press
target:
entity_id: button.coffee_maker_select_latte
data: {}
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- action: number.min
metadata: {}
data: {}
target:
entity_id: number.coffee_maker_milk
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- action: number.max
metadata: {}
data: {}
target:
entity_id: number.coffee_maker_size
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- action: button.press
metadata: {}
data: {}
target:
entity_id: button.coffee_maker_select_play_pause
- wait_for_trigger:
- platform: state
entity_id:
- sensor.coffee_maker_status
to: Idle
for:
hours: 0
minutes: 0
seconds: 2
timeout:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
continue_on_timeout: false
icon: mdi:coffee
surround_mute:
alias: Surround Mute
sequence:
- action: esphome.living_room_speakers_mute
data: {}
description: ""