Design Functional Card Light Card Light Card with slider
This card uses the Material 3 theme D06, TealBlue
Description Aspect Ratio Target Size A card that can control a light and includes a slider for brightness percentage 3/1 Grid with 2 columns
SAK Tool Used for Circle The half circle, as the left part of the circle is cutoff by the card. Animated, state dependent Icon Entity Icon. Animated, state dependent Switch The Switch to toggle the light Name Name of Entity State Brightness Attribute (from slider) Slider Slider to control the brightness of the light
Interaction Part Description Left part Toggles the light once tapped Slider Sets the brightness of the light Other parts All tools connected to an entity do show by default the "more-info" dialog once clicked
Usage 1.0.0-rc.3
Replace example entities with your entities!
1
2
3
4
5
6
7
8
9
10
11
12
13 - type : 'custom:swiss-army-knife-card'
entities :
- entity : light.livingroom_light_duo_right_light
name : 'Light /w Slider'
- entity : light.livingroom_light_duo_right_light
attribute : brightness
unit_of_measurement : "%"
- entity : light.livingroom_light_duo_right_light
secondary_info : last_changed
format : relative
layout :
template :
name : sak_layout_fce_light_with_slider
Data Default Required Description entities The single entity on the card sak_layout_light_toggle_service true The actual service to call to toggle the light. If you have a switch to control the light, the light.toggle
service won't work and you have to replace this with switch.toggle
YAML Template Definition 1.0.0-rc.3
Full definition of layout template 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 sak_layout_fce_light_with_slider :
template :
type : layout
defaults :
- sak_layout_light_toggle_service : light.toggle
layout :
aspectratio : 3/1
toolsets :
# ================================================================
- toolset : column-icon
position :
cx : 0
cy : 50
tools :
# ------------------------------------------------------------
- type : circle
position :
cx : 50
cy : 50
radius : 50
entity_index : 0
animations :
- state : 'on'
styles :
circle :
fill : var(--theme-sys-color-primary)
# animation: flash 2s ease-in-out 5
- state : 'off'
styles :
circle :
fill : var(--theme-sys-color-secondary-container)
# Remove user actions part to just display the state
# or disable pointer-events via a class or style
# Using a class enables the use of variables that can
# disable pointer-events to none!
user_actions :
tap_action :
haptic : light
actions :
- action : call-service
service : light.toggle
styles :
circle :
fill : var(--theme-sys-color-secondary-container)
stroke : var(--theme-sys-color-secondary)
stroke-width : 0em
# ------------------------------------------------------------
- type : 'segarc'
id : 0
position :
cx : 50
cy : 50
start_angle : 25
end_angle : 155
width : 6
radius : 59
entity_index : 1
scale :
min : 0
max : 100
width : 6
offset : 12
show :
scale : false
style : 'colorlist'
derived_entity :
input : '[[[ return state ]]]'
state : >
[[[
if (typeof(entity) === 'undefined') return;
if (typeof(state) === 'undefined') return;
var bri = Math.round(state / 2.55);
return (bri ? bri : '0');
]]]
unit : >
[[[
if (typeof(state) === 'undefined') return undefined;
return '%';
]]]
segments :
colorlist :
gap : 1
colors :
- 'var(--primary-text-color)'
animation :
duration : 5
styles :
foreground :
fill : darkgrey
background :
fill : var(--theme-sys-elevation-surface-neutral4)
# ------------------------------------------------------------
- type : icon
position :
cx : 75
cy : 50
align : center
icon_size : 30
entity_index : 0
animations :
- state : 'on'
styles :
icon :
# animation: spin 3s linear infinite
fill : var(--primary-background-color)
- state : 'off'
styles :
icon :
# fill: var(--theme-sys-color-on-secondary-container)
fill : var(--theme-sys-color-secondary)
styles :
icon :
fill : var(--theme-sys-color-secondary)
# opacity: 0.7
pointer-events : none
# ================================================================
- toolset : switch
position :
cx : 25 # On 1/3 of card width
cy : 75
scale : 1.8
tools :
# ------------------------------------------------------------
- type : switch
position :
cx : 50
cy : 50
orientation : 'horizontal'
track :
width : 15
height : 5
radius : 2.5
thumb :
width : 3
height : 3
radius : 2.5
offset : 4.5
entity_index : 0
user_actions :
tap_action :
haptic : light
actions :
- action : call-service
service : '[[sak_layout_light_toggle_service]]'
styles :
track :
--switch-checked-track-color : var(--primary-background-color)
--switch-unchecked-track-color : var(--theme-sys-color-secondary)
# --switch-checked-button-color:
thumb :
--thumb-stroke : 'var(--primary-background-color)'
# ================================================================
- toolset : column-name
position :
cx : 80
cy : 25
tools :
# ------------------------------------------------------------
- type : name
position :
cx : 50
cy : 50
entity_index : 0
styles :
name :
text-anchor : start
font-size : 25em
font-weight : 700
opacity : 1
# ================================================================
- toolset : slider
position :
cx : 180
cy : 80
tools :
# ------------------------------------------------------------
- type : slider
position :
cx : 50
cy : 50
orientation : horizontal
capture :
width : 200
height : 35
active :
# width: 200
height : 30
radius : 5
track :
width : 200
height : 30
radius : 5
thumb :
width : 30
height : 30
radius : 5
label :
# placement can be none, thumb, position (cx,cy)
placement : position
cx : -50
cy : 20
entity_index : 1
# Does this work??
animations :
# - state: >
# [[[
# if (typeof(state) === 'undefined') return state;
# return 'no-match';
# ]]]
- state : 'undefined'
operator : '=='
styles :
thumb :
# animation: spin 3s linear infinite
# fill: var(--primary-background-color)
fill : var(--theme-sys-color-secondary-container)
# - state: '50'
# operator: '<='
# styles:
# track:
# # fill: var(--theme-sys-color-on-secondary-container)
# fill: var(--theme-sys-color-secondary)
- state : 'undefined'
operator : '!='
styles :
track :
dummy : 1
derived_entity :
input : '[[[ return state ]]]'
state : >
[[[
if (typeof(entity) === 'undefined') return;
if (typeof(state) === 'undefined') return;
var bri = Math.round(state / 2.55);
return (bri ? bri : '0');
]]]
unit : >
[[[
if (typeof(state) === 'undefined') return undefined;
return '%';
]]]
show :
# uom: none
active : true
user_actions :
drag_action :
update_interval : 200 # Update every 200msec
haptic : selection
actions :
- action : call-service
service : light.turn_on
parameter : brightness_pct
tap_action :
haptic : light
actions :
- action : call-service
service : light.turn_on
parameter : brightness_pct
scale :
min : 1
max : 100
step : 1
styles :
label :
text-anchor : start
font-size : 20em
font-weight : 500
pointer-events : auto
uom :
font-weight : 600
capture :
pointer-events : all
touch-action : none
active :
# fill: url(#sak-light-brightness-gradient--orange) #white
fill : var(--theme-sys-elevation-surface-neutral10)
fill : var(--theme-sys-color-secondary)
fill : var(--theme-sys-color-primary)
fill-opacity : 0.3
pointer-events : none
track :
# fill: url(#sak-light-brightness-gradient)
fill : var(--theme-sys-elevation-surface-neutral4)
fill-opacity : 1
stroke-width : 0.2em
stroke : var(--theme-sys-elevation-surface-neutral10)
pointer-events : none
thumb :
# stroke-width: 1.2em
# stroke: var(--primary-background-color)
# stroke-opacity: 1
# fill: var(--primary-text-color)
fill : var(--theme-sys-color-primary)
fill-opacity : 1
pointer-events : none
transition : all .5s ease