-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.yaml
executable file
·635 lines (614 loc) · 17.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
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
turn_on_bedroom:
alias: Allumer chambre
sequence:
- service: light.turn_on
entity_id: light.AmpouleChambre
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
80
{% else %}
150
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2500
{% else %}
4000
{% endif %}
turn_on_bedroom_weak:
alias: Allumer chambre (doux)
sequence:
- service: light.turn_on
entity_id: light.LampeChevet
data_template:
brightness: 50
kelvin: 3000
- service: light.turn_off
entity_id: light.AmpouleChambre
turn_on_bedroom_strong:
alias: Allumer chambre (fort)
sequence:
- service: light.turn_on
entity_id: light.AmpouleChambre
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
150
{% else %}
255
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
4000
{% else %}
5000
{% endif %}
turn_off_bedroom:
alias: Eteindre chambre
sequence:
- service: light.turn_off
entity_id: light.AmpouleChambre
- service: light.turn_off
entity_id: light.LampeChevet
- service: script.turn_off
entity_id: script.sunset_bedroom
turn_on_kitchen:
alias: Allumer cuisine
sequence:
- service: light.turn_on
entity_id: light.AmpouleCuisine
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
100
{% else %}
255
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
3000
{% else %}
5000
{% endif %}
- service: script.turn_on
entity_id: script.turn_on_bar_led_strip
turn_on_kitchen_weak:
alias: Allumer cuisine (doux)
sequence:
- service: light.turn_on
entity_id: light.AmpouleCuisine
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
0
{% else %}
50
{% endif %}
kelvin: 2500
- service: script.turn_on
entity_id: script.turn_on_bar_led_strip_weak
- service: light.turn_on
entity_id: light.gateway
data_template:
rgb_color: [255, 120, 19]
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
255
{% else %}
0
{% endif %}
turn_off_kitchen:
alias: Eteindre cuisine
sequence:
- service: light.turn_off
entity_id: light.AmpouleCuisine, light.gateway
- condition: state
entity_id: light.lumiere_salon
state: 'off'
- delay:
milliseconds: 200
- service: light.turn_off
entity_id: light.bar_led_strip
turn_on_livingroom:
alias: Allumer salon
sequence:
- service: light.turn_on
entity_id: light.AmpouleSalon
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
100
{% else %}
255
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
3000
{% else %}
5000
{% endif %}
- delay:
milliseconds: 500
- service: script.turn_on
entity_id: script.turn_on_livingroom_led_strip, script.turn_on_bar_led_strip
turn_on_livingroom_weak:
alias: Allumer salon (doux)
sequence:
- service: light.turn_on
entity_id: light.AmpouleSalon
data_template:
brightness: 50
kelvin: 3000
- delay:
milliseconds: 500
- service: script.turn_on
entity_id: script.turn_on_bar_led_strip_weak, script.turn_on_livingroom_led_strip_weak
turn_off_livingroom:
alias: Eteindre salon
sequence:
- service: light.turn_off
entity_id: light.AmpouleSalon, light.livingroom_led_strip
- condition: state
entity_id: light.AmpouleCuisine
state: 'off'
- delay:
milliseconds: 200
- service: light.turn_off
entity_id: light.bar_led_strip
turn_on_desk:
alias: Allumer bureau
sequence:
- service: light.turn_on
entity_id: light.AmpouleBureau
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
100
{% else %}
255
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
3000
{% else %}
4500
{% endif %}
turn_on_desk_weak:
alias: Allumer bureau (doux)
sequence:
- service: light.turn_on
entity_id: light.AmpouleBureau
data_template:
brightness: 25
kelvin: 3000
turn_off_desk:
alias: Eteindre bureau
sequence:
- service: light.turn_off
entity_id: light.AmpouleBureau
turn_on_bathroom:
alias: Allumer salle de bain
sequence:
- service: light.turn_on
entity_id: light.AmpouleSalleDeBain
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
80
{% else %}
150
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2500
{% else %}
4000
{% endif %}
- service: light.turn_on
entity_id: light.lumiere_miroir_salle_de_bain
data_template:
brightness: 70
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2000
{% else %}
4500
{% endif %}
turn_on_bathroom_weak:
alias: Allumer salle de bain (doux)
sequence:
- service: light.turn_on
entity_id: light.AmpouleSalleDeBain
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
10
{% else %}
40
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2500
{% else %}
4000
{% endif %}
- service: light.turn_on
entity_id: light.lumiere_miroir_salle_de_bain
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
50
{% else %}
70
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2000
{% else %}
4500
{% endif %}
turn_on_bathroom_strong:
alias: Allumer salle de bain (fort)
sequence:
- service: light.turn_on
entity_id: light.AmpouleSalleDeBain
data_template:
brightness: 255
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
3500
{% else %}
3800
{% endif %}
- service: light.turn_on
entity_id: light.lumiere_miroir_salle_de_bain
data_template:
brightness: 255
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2500
{% else %}
6000
{% endif %}
turn_off_bathroom:
alias: Eteindre la salle de bain
sequence:
- service: light.turn_off
entity_id: light.AmpouleSalleDeBain
- service: light.turn_off
entity_id: light.lumiere_miroir_salle_de_bain
turn_on_toilets:
alias: Allumer les toilettes
sequence:
- service: light.turn_on
entity_id: light.AmpouleToilettes
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
80
{% else %}
150
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2500
{% else %}
4000
{% endif %}
turn_on_toilets_weak:
alias: Allumer les toilettes (doux)
sequence:
- service: light.turn_on
entity_id: light.AmpouleToilettes
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
1
{% else %}
30
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2500
{% else %}
4000
{% endif %}
turn_on_toilets_strong:
alias: Allumer les toilettes (fort)
sequence:
- service: light.turn_on
entity_id: light.AmpouleToilettes
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
150
{% else %}
255
{% endif %}
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
3500
{% else %}
4500
{% endif %}
sunset_bedroom:
alias: Coucher de soleil chambre
sequence:
- condition: state
entity_id: light.AmpouleChambre
state: 'on'
- service: light.turn_on
entity_id: light.AmpouleChambre
data:
kelvin: 2500
brightness: 60
- service: light.turn_on
entity_id: light.LampeChevet
data:
kelvin: 2500
brightness: 150
- delay: 00:01:00
- service: light.turn_on
entity_id: light.AmpouleChambre
data:
kelvin: 2500
brightness: 1
transition: 180
- delay: 00:03:00
- service: light.turn_off
entity_id: light.AmpouleChambre
- service: light.turn_on
entity_id: light.LampeChevet
data:
rgb_color: [255,0,0]
brightness: 1
transition: 390
- delay: 00:06:30
- service: light.turn_off
entity_id: light.LampeChevet
speakers_timer_start:
alias: Extinction haut-parleurs avec délai
sequence:
- service: automation.turn_on
entity_id: automation.chambre16
- service: automation.turn_on
entity_id: automation.chambre17
- delay: 04:00:00
record_camera:
alias: Enregistrement caméra
sequence:
- service: camera.record
data:
entity_id: camera.ffmpeg
duration: 60
filename: '/media/Recordings/camera_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4'
m365_limit_charge:
alias: Limitation charge m365
sequence:
# wait until power usage > ~71 W, meaning that charge is ~75%
- wait_template: "{{ (states.sensor.m365_power_usage.state | int > 71 and states.sensor.m365_power_usage.state | int < 78) or (states.sensor.m365_power_usage.state | int > 142 and states.sensor.m365_power_usage.state | int < 156) }}"
# wait for one hour and stop charge
- service: timer.start
entity_id: timer.m365_charge_timer
data_template:
duration: >
{% if states.sensor.m365_power_usage.state | int > 142 %}
{% if states.sensor.m365_power_usage.state | int > 148 %}
00:00:01
{% elif states.sensor.m365_power_usage.state | int > 146 %}
00:40:00
{% elif states.sensor.m365_power_usage.state | int > 142 %}
01:00:00
{% else %}
01:10:00
{% endif %}
{% else %}
{% if states.sensor.m365_power_usage.state | int == 72 %}
01:25:00
{% elif states.sensor.m365_power_usage.state | int == 73 %}
01:15:00
{% elif states.sensor.m365_power_usage.state | int == 74 %}
00:55:00
{% else %}
00:00:01
{% endif %}
{% endif %}
- wait_template: "{{ states.timer.m365_charge_timer.state == 'idle' or states('switch.m365_plug') == 'off' }}"
- service: switch.turn_off
data:
entity_id: switch.m365_plug
turn_on_livingroom_led_strip:
alias: Allumer led salon
sequence:
- service: light.turn_on
entity_id: light.livingroom_led_strip
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
100
{% else %}
255
{% endif %}
- delay:
milliseconds: 500
- service: light.turn_on
entity_id: light.livingroom_led_strip
data_template:
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
3000
{% else %}
5000
{% endif %}
turn_on_livingroom_led_strip_weak:
alias: Allumer led salon doux
sequence:
- service: light.turn_on
entity_id: light.livingroom_led_strip
data_template:
brightness: 50
- delay:
milliseconds: 200
- service: light.turn_on
entity_id: light.livingroom_led_strip
data_template:
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2500
{% else %}
3000
{% endif %}
turn_on_bar_led_strip:
alias: Allumer led bar
sequence:
- service: light.turn_on
entity_id: light.bar_led_strip
data_template:
brightness: >
{% if now().hour >= 22 or now().hour < 9 %}
100
{% else %}
255
{% endif %}
- delay:
milliseconds: 200
- service: light.turn_on
entity_id: light.bar_led_strip
data_template:
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
3000
{% else %}
5000
{% endif %}
turn_on_bar_led_strip_weak:
alias: Allumer led bar doux
sequence:
- service: light.turn_on
entity_id: light.bar_led_strip
data_template:
brightness: 50
- delay:
milliseconds: 200
- service: light.turn_on
entity_id: light.bar_led_strip
data_template:
kelvin: >
{% if now().hour >= 22 or now().hour < 9 %}
2500
{% else %}
3000
{% endif %}
decrease_bedroom_music_volume:
alias: baisser lentement son musique chambre
sequence:
- service: input_number.set_value
entity_id: input_number.speakers_start_volume
data_template:
value: >
{{ state_attr("media_player.chambre", "volume_level") | float }}
- repeat:
while:
- condition: template
value_template: '{{ state_attr("media_player.chambre", "volume_level") | float > states.input_number.speakers_target_volume.state | float / 100}}'
sequence:
- service: media_player.volume_set
data_template:
entity_id: media_player.chambre
volume_level: >
{% set step = (states.input_number.speakers_start_volume.state | float - states.input_number.speakers_target_volume.state | float/100) / (states.input_number.speakers_volume_change_duration.state | float * 10) %}
{% set result = state_attr("media_player.chambre", "volume_level") | float - step %}
{% if result < (states.input_number.speakers_target_volume.state | float / 100) %}
{{ states.input_number.speakers_target_volume.state | float / 100 }}
{% else %}
{{ result }}
{% endif %}
- delay: 00:00:06
gateway_notification_washing_machine_cycle_finished:
alias: notification fin de cycle machine à laver
sequence:
- repeat:
sequence:
- service: light.turn_on
entity_id: light.gateway
data:
rgb_color: [36,200,255]
brightness_pct: 12
- delay: 00:00:02
- service: light.turn_on
entity_id: light.gateway
data:
rgb_color: [0,63,255]
brightness_pct: 35
- delay: 00:00:00.750
until:
- condition: state
entity_id: light.gateway
state: 'off'
gateway_notification_washing_machine_cycle_finished_killer:
alias: arrêt notification fin de cycle machine à laver
sequence:
- wait_for_trigger:
- platform: state
entity_id: light.gateway
to: "off"
- service: script.turn_off
entity_id: script.gateway_notification_washing_machine_cycle_finished
- service: light.turn_off
entity_id: light.gateway
toggle_litter_tray_sleep_mode:
alias: Activer / désactiver mode silencieux litière
sequence:
- service: litterrobot.set_sleep_mode
target:
entity_id: vacuum.vaisseau_mere_litter_box
data_template:
enabled: >
{{ not state_attr('vacuum.vaisseau_mere_litter_box', 'sleep_mode_enabled') }}
start_time: >
{{ states("input_datetime.litter_box_sleep_mode_time") }}
update_litter_tray_cleaning_wait_time:
alias: Paramétrer durée temporisation nettoyage litière
sequence:
- service: litterrobot.set_wait_time
target:
entity_id: vacuum.vaisseau_mere_litter_box
data_template:
minutes: >
{{ states("input_select.duree_temporisation_nettoyage_litere") }}
search_youtube_playlist:
alias: Rechercher Playlist Youtube
sequence:
- service: ytube_music_player.search
data:
entity_id: media_player.ytube_music_player
filter: playlists
query: '{{ states(''input_text.yt_music_search_query'') }}'
heating_blanket_limit_duration:
alias: Limitation allumage plaid chauffant
sequence:
- service: switch.turn_on
data:
entity_id: switch.heating_blanket_on_off
- service: timer.start
entity_id: timer.heating_blanket
data_template:
duration: >
{% if states.sensor.temperature_bedroom.state | int < 16 %}
01:00:00
{% elif states.sensor.temperature_bedroom.state | int < 17 %}
00:45:00
{% elif states.sensor.temperature_bedroom.state | int < 18 %}
00:30:00
{% elif states.sensor.temperature_bedroom.state | int < 19 %}
00:25:00
{% elif states.sensor.temperature_bedroom.state | int < 20 %}
00:20:00
{% else %}
00:15:00
{% endif %}
- wait_template: "{{ states.timer.heating_blanket.state == 'idle' }}"
- service: switch.turn_off
data:
entity_id: switch.heating_blanket_on_off