-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadalight.yaml
More file actions
527 lines (512 loc) · 16.3 KB
/
adalight.yaml
File metadata and controls
527 lines (512 loc) · 16.3 KB
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
blueprint:
name: 自適應燈光
description: 讓燈光於一天的不同時間點自動變化合適的亮度、色溫
domain: automation
author: WOOW TECH CO., LTD.
source_url: https://github.com/WOOWTECH/HA_blueprint_adalight/blob/main/adalight.yaml
homeassistant:
min_version: "2024.6.0"
input:
light_entities:
name: 燈光 (可複選)
description: 選擇要自適應的燈光(可多選)
selector:
entity:
multiple: true
filter:
domain: light
# ——— 全域條件 (選填) —————————————
global_conditions_settings:
name: Global Conditions (選填)
icon: mdi:earth
collapsed: true
input:
global_conditions:
name: 額外全域條件
default: []
selector: { condition: {} }
# ——— 生效星期 (選填) —————————————
weekday_settings:
name: 生效星期 (選填)
icon: mdi:calendar-week
collapsed: true
input:
condition_weekday:
name: 選擇星期
default: [mon, tue, wed, thu, fri, sat, sun]
selector:
select:
multiple: true
mode: list
options:
- { label: 週一, value: mon }
- { label: 週二, value: tue }
- { label: 週三, value: wed }
- { label: 週四, value: thu }
- { label: 週五, value: fri }
- { label: 週六, value: sat }
- { label: 週日, value: sun }
# ——— 早晨模式 —————————————
event_morning:
name: 早晨模式
icon: mdi:weather-sunset-up
collapsed: true
input:
time_morning:
name: 早晨模式 - 開始時間
default: "07:00:00"
selector:
time:
colortemp_morning:
name: 早晨模式 - 色溫值
description: 單位Kelvin
default: 6410
selector:
color_temp:
unit: kelvin
min: 2000
max: 6500
brightness_morning:
name: 早晨模式 - 亮度值
description: 1~100%
default: 100
selector:
number:
mode: slider
min: 1
max: 100
step: 1
transition_morning:
name: 早晨模式 - 漸變時間 (秒)
default: 60
selector:
number:
min: 0
max: 300
step: 1
unit_of_measurement: s
# ——— 白天模式 —————————————
event_noon:
name: 白天模式
icon: mdi:white-balance-sunny
collapsed: true
input:
time_noon:
name: 白天模式 - 開始時間
default: "10:00:00"
selector:
time:
colortemp_noon:
name: 白天模式 - 色溫值
description: 單位Kelvin
default: 4291
selector:
color_temp:
unit: kelvin
min: 2000
max: 6500
brightness_noon:
name: 白天模式 - 亮度值
description: 1~100%
default: 100
selector:
number:
mode: slider
min: 1
max: 100
step: 1
transition_noon:
name: 白天模式 - 漸變時間 (秒)
default: 60
selector:
number:
min: 0
max: 300
step: 1
unit_of_measurement: s
# ——— 傍晚模式 —————————————
event_evening:
name: 傍晚模式
icon: mdi:weather-sunset-down
collapsed: true
input:
time_evening:
name: 傍晚模式 - 開始時間
default: "18:00:00"
selector:
time:
colortemp_evening:
name: 傍晚模式 - 色溫值
description: 單位Kelvin
default: 2890
selector:
color_temp:
unit: kelvin
min: 2000
max: 6500
brightness_evening:
name: 傍晚模式 - 亮度值
description: 1~100%
default: 100
selector:
number:
mode: slider
min: 1
max: 100
step: 1
transition_evening:
name: 傍晚模式 - 漸變時間 (秒)
default: 60
selector:
number:
min: 0
max: 300
step: 1
unit_of_measurement: s
# ——— 晚上模式 —————————————
event_night:
name: 晚上模式
icon: mdi:theme-light-dark
collapsed: true
input:
time_night:
name: 晚上模式 - 開始時間
default: "20:00:00"
selector:
time:
colortemp_night:
name: 晚上模式 - 色溫值
description: 單位Kelvin
default: 2237
selector:
color_temp:
unit: kelvin
min: 2000
max: 6500
brightness_night:
name: 晚上模式 - 亮度值
description: 1~100%
default: 57
selector:
number:
mode: slider
min: 1
max: 100
step: 1
transition_night:
name: 晚上模式 - 漸變時間 (秒)
default: 60
selector:
number:
min: 0
max: 300
step: 1
unit_of_measurement: s
# ——— 睡前模式 —————————————
event_before_sleep:
name: 睡前模式
icon: mdi:weather-night
collapsed: true
input:
time_before_sleep:
name: 睡前模式 - 開始時間
default: "22:00:00"
selector:
time:
colortemp_before_sleep:
name: 睡前模式 - 色溫值
description: 單位Kelvin
default: 2000
selector:
color_temp:
unit: kelvin
min: 2000
max: 6500
brightness_before_sleep:
name: 睡前模式 - 亮度值
description: 1~100%
default: 35
selector:
number:
mode: slider
min: 1
max: 100
step: 1
transition_before_sleep:
name: 睡前模式 - 漸變時間 (秒)
default: 60
selector:
number:
min: 0
max: 300
step: 1
unit_of_measurement: s
# ——— 夜間模式 —————————————
event_midnight:
name: 夜間模式
icon: mdi:sleep
collapsed: true
input:
time_midnight:
name: 夜間模式 - 開始時間
default: "00:00:00"
selector:
time:
colortemp_midnight:
name: 夜間模式 - 色溫值
description: 單位Kelvin
default: 2000
selector:
color_temp:
unit: kelvin
min: 2000
max: 6500
brightness_midnight:
name: 夜間模式 - 亮度值
description: 1~100%
default: 4
selector:
number:
mode: slider
min: 1
max: 100
step: 1
transition_midnight:
name: 夜間模式 - 漸變時間 (秒)
default: 60
selector:
number:
min: 0
max: 300
step: 1
unit_of_measurement: s
variables:
_light_entities: !input light_entities
triggers:
- trigger: state
entity_id: !input light_entities
from: "off"
to: "on"
id: light_from_off_to_on
- trigger: time
at: !input time_morning
id: time_morning_begin
- trigger: time
at: !input time_noon
id: time_noon_begin
- trigger: time
at: !input time_evening
id: time_evening_begin
- trigger: time
at: !input time_night
id: time_night_begin
- trigger: time
at: !input time_before_sleep
id: time_before_sleep_begin
- trigger: time
at: !input time_midnight
id: time_midnight_begin
conditions:
- condition: time
weekday: !input condition_weekday
- condition: !input global_conditions
actions:
# ---------- 開燈時依當前時段套用(僅調整觸發的燈) ----------
- if:
- condition: trigger
id: light_from_off_to_on
then:
- choose:
- conditions:
- condition: time
after: !input time_morning
before: !input time_noon
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_morning
brightness_pct: !input brightness_morning
transition: !input transition_morning
target:
entity_id: "{{ trigger.entity_id }}"
- conditions:
- condition: time
after: !input time_noon
before: !input time_evening
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_noon
brightness_pct: !input brightness_noon
transition: !input transition_noon
target:
entity_id: "{{ trigger.entity_id }}"
- conditions:
- condition: time
after: !input time_evening
before: !input time_night
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_evening
brightness_pct: !input brightness_evening
transition: !input transition_evening
target:
entity_id: "{{ trigger.entity_id }}"
- conditions:
- condition: time
after: !input time_night
before: !input time_before_sleep
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_night
brightness_pct: !input brightness_night
transition: !input transition_night
target:
entity_id: "{{ trigger.entity_id }}"
- conditions:
- condition: time
after: !input time_before_sleep
before: !input time_midnight
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_before_sleep
brightness_pct: !input brightness_before_sleep
transition: !input transition_before_sleep
target:
entity_id: "{{ trigger.entity_id }}"
- conditions:
- condition: time
after: !input time_midnight
before: !input time_morning
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_midnight
brightness_pct: !input brightness_midnight
transition: !input transition_midnight
target:
entity_id: "{{ trigger.entity_id }}"
# ---------- 各時間點到時自動過渡(僅調整已開啟的燈) ----------
- if:
- condition: trigger
id:
- time_morning_begin
- time_noon_begin
- time_evening_begin
- time_night_begin
- time_before_sleep_begin
- time_midnight_begin
then:
- choose:
- conditions:
- condition: and
conditions:
- condition: trigger
id: time_morning_begin
- condition: state
entity_id: !input light_entities
state: "on"
match: any
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_morning
brightness_pct: !input brightness_morning
transition: !input transition_morning
target:
entity_id: >
{{ expand(_light_entities) | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}
- conditions:
- condition: and
conditions:
- condition: trigger
id: time_noon_begin
- condition: state
entity_id: !input light_entities
state: "on"
match: any
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_noon
brightness_pct: !input brightness_noon
transition: !input transition_noon
target:
entity_id: >
{{ expand(_light_entities) | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}
- conditions:
- condition: and
conditions:
- condition: trigger
id: time_evening_begin
- condition: state
entity_id: !input light_entities
state: "on"
match: any
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_evening
brightness_pct: !input brightness_evening
transition: !input transition_evening
target:
entity_id: >
{{ expand(_light_entities) | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}
- conditions:
- condition: and
conditions:
- condition: trigger
id: time_night_begin
- condition: state
entity_id: !input light_entities
state: "on"
match: any
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_night
brightness_pct: !input brightness_night
transition: !input transition_night
target:
entity_id: >
{{ expand(_light_entities) | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}
- conditions:
- condition: and
conditions:
- condition: trigger
id: time_before_sleep_begin
- condition: state
entity_id: !input light_entities
state: "on"
match: any
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_before_sleep
brightness_pct: !input brightness_before_sleep
transition: !input transition_before_sleep
target:
entity_id: >
{{ expand(_light_entities) | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}
- conditions:
- condition: and
conditions:
- condition: trigger
id: time_midnight_begin
- condition: state
entity_id: !input light_entities
state: "on"
match: any
sequence:
- action: light.turn_on
data:
color_temp_kelvin: !input colortemp_midnight
brightness_pct: !input brightness_midnight
transition: !input transition_midnight
target:
entity_id: >
{{ expand(_light_entities) | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}
mode: single