-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlight_group.yaml
187 lines (180 loc) · 6.55 KB
/
light_group.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
####{ CreativeBC }####| Light Group |####[ github.com/wfurphy/creative-button-card-templates ]####>
light_group:
template:
- light
color: auto
variables:
items: []
__defaults:
entity: "[[[ return entity?.entity_id ]]]"
icon: mdi:lightbulb
symbol:
symbol_width: 50%
symbol_font_size: 10pt
symbol_color: var( --ha-card-background, var(--card-background-color, white) )
display: "none"
styles:
grid:
- grid-template-areas: >
[[[
if (!Array.isArray(variables.items) || !variables.items.length) {
if(!entity || !entity.attributes?.entity_id || !Array.isArray(entity.attributes.entity_id)) {
throw new Error("You must provide a light group entity or a list of items")
return ''
}
entity.attributes.entity_id.forEach(function(e,i) {
variables.items.push({
...variables.__defaults,
...{
entity: e,
symbol: String(i+1)
}})
})
}
variables._qty = variables.items.length > 6 ? 6 : variables.items.length
let pre = '\"i'
let cf = '\"'
let post = '\"'
for(let i = 0; i < variables._qty; i++) {
const sp = i ? ' ' : ''
pre += i ? ` n` : ''
cf += `${sp}li${i+1}`
post += `${sp}l`
variables.items[i].display = 'block'
variables.items[i] = {...variables.__defaults, ...variables.items[i]}
}
return pre + '\" ' + cf + '\" ' + post + '\" '
]]]
- grid-template-columns: "[[[ return `repeat(${variables._qty}, 1fr)` ]]]"
- grid-template-rows: 1fr 1fr 1fr
- justify-items: center
- align-items: center
- padding: 4px
- position: relative
- max-width: 100%
label:
- justify-self: center
- align-self: start
- text-align: center
- margin-top: -3px
name:
- justify-self: center
- align-self: center
- text-align: left
custom_fields:
li1:
- display: "[[[ return variables.items[0]?.display || 'none' ]]]"
- z-index: 5
- justify-self: center
- align-self: center
li2:
- display: "[[[ return variables.items[1]?.display || 'none' ]]]"
- z-index: 5
- justify-self: center
- align-self: center
li3:
- display: "[[[ return variables.items[2]?.display || 'none' ]]]"
- z-index: 5
- justify-self: center
- align-self: center
li4:
- display: "[[[ return variables.items[3]?.display || 'none' ]]]"
- z-index: 5
- justify-self: center
- align-self: center
li5:
- display: "[[[ return variables.items[4]?.display || 'none' ]]]"
- z-index: 5
- justify-self: center
- align-self: center
li6:
- display: "[[[ return variables.items[5]?.display || 'none' ]]]"
- z-index: 5
- justify-self: center
- align-self: center
custom_fields:
li1:
card:
type: custom:button-card
template:
- button_mini_embed
- actions
entity: "[[[ return variables.items[0]?.entity ]]]"
icon: "[[[ return variables.items[0]?.icon ]]]"
color: auto
variables:
symbol: "[[[ return variables.items[0]?.symbol ]]]"
symbol_width: "[[[ return variables.items[0]?.symbol_width ]]]"
symbol_font_size: "[[[ return variables.items[0]?.symbol_font_size ]]]"
symbol_color: "[[[ return variables.items[0]?.symbol_color ]]]"
li2:
card:
type: custom:button-card
template:
- button_mini_embed
- actions
entity: "[[[ return variables.items[1]?.entity ]]]"
icon: "[[[ return variables.items[1]?.icon ]]]"
color: auto
variables:
symbol: "[[[ return variables.items[1]?.symbol ]]]"
symbol_width: "[[[ return variables.items[1]?.symbol_width ]]]"
symbol_font_size: "[[[ return variables.items[1]?.symbol_font_size ]]]"
symbol_color: "[[[ return variables.items[1]?.symbol_color ]]]"
li3:
card:
type: custom:button-card
template:
- button_mini_embed
- actions
entity: "[[[ return variables.items[2]?.entity ]]]"
icon: "[[[ return variables.items[2]?.icon ]]]"
color: auto
variables:
symbol: "[[[ return variables.items[2]?.symbol ]]]"
symbol_width: "[[[ return variables.items[2]?.symbol_width ]]]"
symbol_font_size: "[[[ return variables.items[2]?.symbol_font_size ]]]"
symbol_color: "[[[ return variables.items[2]?.symbol_color ]]]"
li4:
card:
type: custom:button-card
template:
- button_mini_embed
- actions
entity: "[[[ return variables.items[3]?.entity ]]]"
icon: "[[[ return variables.items[3]?.icon ]]]"
color: auto
variables:
symbol: "[[[ return variables.items[3]?.symbol ]]]"
symbol_width: "[[[ return variables.items[3]?.symbol_width ]]]"
symbol_font_size: "[[[ return variables.items[3]?.symbol_font_size ]]]"
symbol_color: "[[[ return variables.items[3]?.symbol_color ]]]"
li5:
card:
type: custom:button-card
template:
- button_mini_embed
- actions
entity: "[[[ return variables.items[4]?.entity ]]]"
icon: "[[[ return variables.items[4]?.icon ]]]"
color: auto
variables:
symbol: "[[[ return variables.items[4]?.symbol ]]]"
symbol_width: "[[[ return variables.items[4]?.symbol_width ]]]"
symbol_font_size: "[[[ return variables.items[4]?.symbol_font_size ]]]"
symbol_color: "[[[ return variables.items[4]?.symbol_color ]]]"
li6:
card:
type: custom:button-card
template:
- button_mini_embed
- actions
entity: "[[[ return variables.items[5]?.entity ]]]"
icon: "[[[ return variables.items[5]?.icon ]]]"
color: auto
variables:
symbol: "[[[ return variables.items[5]?.symbol ]]]"
symbol_width: "[[[ return variables.items[5]?.symbol_width ]]]"
symbol_font_size: "[[[ return variables.items[5]?.symbol_font_size ]]]"
symbol_color: "[[[ return variables.items[5]?.symbol_color ]]]"
#########################################################################/