-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblueprint_snippets.yaml
90 lines (79 loc) · 2.86 KB
/
blueprint_snippets.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
Lighting Blueprint to-dos:
- Support non-adaptive lighting configurations (Update every block with condition)
- Detect Inovelli switches for applying inovelli_blue_led_script, don't assume all switches are Inovelli
- AL switch updates are broken (enable color, sleep, etc.)
# Turn on primary lights and wait for them to all be on
sequence:
- action: light.turn_on
target:
entity_id:
"{{ primary_lights }}"
- delay:
milliseconds: 300
- wait_template: >
{% set lights_on = primary_lights | map('states') | select('equalto', 'on') | list %}
{{ lights_on | length == primary_lights | length }}
timeout: '00:00:10'
# For each switch defined in Adaptive Lighting switches, set switch options
sequence2:
- repeat:
for_each: "{{ primary_lights_adaptive_lighting_switches }}"
sequence:
- action: adaptive_lighting.change_switch_settings
data:
use_defaults: configuration
entity_id: "{{ repeat.item }}"
prefer_rgb_color: "{{ enable_rgb_color }}"
# Set Adaptive Lighting to manual and turn off AL switches
sequence3:
- action: adaptive_lighting.set_manual_control
data:
manual_control: true
lights:
"{{ primary_lights }}"
- action: switch.turn_off
target:
entity_id:
"{{ primary_lights_adaptive_lighting_switches }}"
# Turn on parimary lights if HA control is enabled
sequence4:
- if:
- condition: template
value_template: "{{ primary_lights_direct_control_enabled == true }}"
then:
- action: light.turn_on
target:
entity_id:
"{{ primary_lights }}"
# set secondary adaptive lighting switch config and apply
sequence5:
- action: adaptive_lighting.apply
data:
lights:
"{{ secondary_lights }}"
adapt_brightness: true
turn_on_lights: true
adapt_color: true
prefer_rgb_color: false
transition: '1'
# old code for determining adaptive lighting switches
# {%- set data = namespace(switches=[]) %}
# {%- for light in secondary_lights %}
# {%- set data.switches = data.switches + ['switch.adaptive_lighting_' + light.replace('light.','')] %}
# {%- endfor %}
# {{ data.switches }}
primary_lights_ha_control_enabled: >
{%- set direct_control = false %}
{%- if (primary_lights_ha_control == true) or (action == 'on') or (action == 'off') %}
{%- set direct_control = true %}
{%- endif %}
{{ direct_control }}
secondary_lights_state: >
{%- set secondary_lights_state = 'off' %}
{%- if secondary_lights is defined and (secondary_lights | length > 0) %}
{%- set secondary_lights_states = expand(secondary_lights) | selectattr('state') | map(attribute='state') | join(',') %}
{%- if 'on' in secondary_lights_states %}
{%- set secondary_lights_state = 'on' %}
{%- endif %}
{%- endif %}
{{ secondary_lights_state }}