forked from matt8707/hass-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton_card_templates.yaml
242 lines (234 loc) · 12.3 KB
/
button_card_templates.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
base:
aspect_ratio: 1/1
show_state: true
show_icon: false
state:
- value: 'on'
styles:
card: [background-color: 'rgba(255, 255, 255, 0.8)']
name: [color: 'rgba(0, 0, 0, 0.6)']
state: [color: 'rgba(0, 0, 0, 0.6)']
tap_action:
ui_sound: |
[[[ if (entity.state === 'off' && states['switch.fullykiosk_screensaver'].state === 'off') {
hass.callService('media_player', 'play_media', {entity_id: 'media_player.tablet', media_content_id: '/local/sound/on.m4a', media_content_type: 'music'}); }
else if (entity.state === 'on' && states['switch.fullykiosk_screensaver'].state === 'off') {
hass.callService('media_player', 'play_media', {entity_id: 'media_player.tablet', media_content_id: '/local/sound/off.m4a', media_content_type: 'music'}); } ]]]
action: toggle
haptic: light
styles:
name:
[top: 57.7%, left: 11%, line-height: 2vw, position: absolute]
state:
[top: 74%, left: 11%, line-height: 2vw, position: absolute]
card:
[font-family: Sf Display, letter-spacing: 0.05vw, font-weight: 400, color: 'rgba(255, 255, 255, 0.3)', font-size: 1.34vw,
background-color: 'rgba(115, 115, 115, 0.2)', border-radius: 0.8vw, box-shadow: none, transition: none]
custom_fields:
circle:
[top: 8.5%, left: 56.2%, width: 3.5vw, position: absolute, letter-spacing: 0.03vw]
loader:
custom_fields:
loader: >
[[[ if (states[entity.entity_id.replace(entity.entity_id.split('.')[0], 'input_boolean')].state === 'on') {
return '<img src="/local/loader.svg" width="100%">'; } ]]]
styles:
custom_fields:
loader:
[filter: "[[[ return entity.state === 'off' ? 'invert(1)' : 'none'; ]]]",
top: 3%, left: 60%, width: 3.7vw, position: absolute, opacity: 0.6]
person:
template: ['base']
show_entity_picture: true
state_display: >
[[[ return entity.state === 'home' ? 'Ja' : 'Nej'; ]]]
state:
- value: 'home'
styles:
card: [background-color: 'rgba(255, 255, 255, 0.8)']
name: [color: 'rgba(0, 0, 0, 0.6)']
state: [color: 'rgba(0, 0, 0, 0.6)']
styles:
entity_picture:
[clip-path: circle(50% at center), top: 7.5%, left: 11.2%, width: 3vw, position: absolute]
custom_fields:
circle: >
[[[ function time(c) {
var s = (c / 1000); var m = (c / (1000 * 60)); var h = (c / (1000 * 60 * 60)); var d = (c / (1000 * 60 * 60 * 24));
if (s < 60) { return parseInt(s) + 's'; } else if (m < 60) { return parseInt(m) + 'm'; }
else if (h < 24) { return parseInt(h) + 'h'; } else { return parseInt(d) + 'd'; }
}
const last_changed = time(Date.now() - Date.parse(states[entity.entity_id].last_changed));
const stroke_color = entity.state === 'home' ? '#b2b2b2' : '#313638';
const fill_color = entity.state === 'home' ? 'none' : '#FFFFFF08';
return `<svg viewBox="0 0 50 50"><circle cx="25" cy="25" r="20.5" stroke="${stroke_color}" stroke-width="1.5" fill="${fill_color}" />
<text x="50%" y="54%" fill="#8d8e90" font-size="14" text-anchor="middle" alignment-baseline="middle">${last_changed}</text></svg>`; ]]]
light:
template: ['base']
custom_fields:
circle: >
[[[ if (entity.state === 'on' && entity.attributes.brightness) {
const brightness = Math.round(entity.attributes.brightness / 2.54);
const radius = 20.5; const circumference = radius * 2 * Math.PI;
return `<svg viewBox="0 0 50 50"><circle cx="25" cy="25" r="${radius}" stroke="#b2b2b2" stroke-width="1.5" fill="none" style="
transform: rotate(-90deg); transform-origin: 50% 50%; stroke-dasharray: ${circumference}; stroke-dashoffset: ${circumference - brightness / 100 * circumference};" />
<text x="50%" y="54%" fill="#8d8e90" font-size="14" text-anchor="middle" alignment-baseline="middle">${brightness}<tspan font-size="10">%</tspan></text></svg>`; } ]]]
hold_action:
action: call-service
service: browser_mod.popup
service_data:
title: '[[[ return entity.attributes.friendly_name ]]]'
deviceID: this
card:
type: entities
entities:
- type: custom:light-popup-card
entity: '[[[ return entity.entity_id ]]]'
icon: none
fullscreen: false
brightnessWidth: 130px
brightnessHeight: 360px
borderRadius: 1.7em
sliderColor: '#c7c7c7'
sliderTrackColor: rgba(25, 25, 25, 0.9)
actionSize: 4.5em
actionsInARow: 2
actions:
- service: light.turn_on
service_data:
entity_id: '[[[ return entity.entity_id ]]]'
color_temp: 153
color: "#d8d9e1"
- service: light.turn_on
service_data:
entity_id: '[[[ return entity.entity_id ]]]'
color_temp: 326
color: "#d5b08d"
- service: light.turn_on
service_data:
entity_id: '[[[ return entity.entity_id ]]]'
color_temp: 500
color: "#ce944b"
- service: browser_mod.popup
service_data:
title: '[[[ return entity.attributes.friendly_name ]]]'
deviceID: this
card:
type: entities
show_header_toggle: false
entities:
- entity: '[[[ return entity.entity_id ]]]'
secondary_info: last-changed
- type: custom:light-entity-card
entity: '[[[ return entity.entity_id ]]]'
brightness: false
color_temp: true
full_width_sliders: true
hide_header: true
show_slider_percent: true
smooth_color_wheel: true
consolidate_entities: true
shared_media:
tap_action:
action: >
[[[ if (entity.state === 'off' || entity.state === 'idle' || entity.state === 'standby') {
return 'none'; } else { return 'call-service'; } ]]]
service: media_player.media_play_pause
service_data:
entity_id: '[[[ return entity.entity_id ]]]'
double_tap_action:
action: call-service
service: >
[[[ if (entity.state === 'off' || entity.state === 'idle' || entity.state === 'standby') {
return 'media_player.turn_on'; } else { return 'media_player.turn_off'; } ]]]
service_data:
entity_id: '[[[ return entity.entity_id ]]]'
styles:
card:
[color: "[[[ if (entity.state === 'off' || entity.state === 'idle' || entity.state === 'standby' ||
entity.state === 'unknown' || entity.state === 'unavailable') { return 'rgba(255, 255, 255, 0.3)'; }
if ((entity.state != 'off' && entity.state != 'idle' && entity.state != 'standby') && (entity.attributes.entity_picture == null)) {
return 'rgba(0, 0, 0, 0.6)'; } else { return '#efefef'; } ]]]",
text-shadow: "[[[ if (entity.attributes.entity_picture == null) return 'none';
else return '1px 1px 5px rgba(18, 22, 23, 0.9)' ; ]]]"]
media:
template: ['base', 'shared_media']
styles:
custom_fields:
icon:
[opacity: "[[[ return entity.attributes.entity_picture == null ? 1 : 0; ]]]",
top: 11.5%, left: 11.5%, width: 2.9vw, position: absolute, fill: '#9da0a2']
card:
[background-color: none, background-size: cover,
background-image:
"[[[ if (entity.state === 'off' || entity.state === 'idle' || entity.state === 'standby' ||
entity.state === 'unknown' || entity.state === 'unavailable') {
return 'linear-gradient(0deg, rgba(115, 115, 115, 0.2) 0%, rgba(115, 115, 115, 0.2) 100%)'; }
if ((entity.state != 'off' && entity.state != 'idle' && entity.state != 'standby') && (entity.attributes.entity_picture == null)) {
return 'linear-gradient(0deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%)'; }
else { return 'linear-gradient(0deg, rgba(0,0,0,.8) 0%, rgba(0,0,0,0) 100%), url(' + entity.attributes.entity_picture + ')'; } ]]]"]
conditional_media:
template: ['base', 'shared_media']
state_display: >
[[[ if (entity.attributes.media_title === 'Nothing playing' || entity.attributes.media_title === 'No title' && entity.state === 'paused' ) { return 'Inget spelas'; }
if (entity.attributes.media_title === 'No title' && entity.state === 'playing') { return 'Ingen titel'; }
else { return entity.attributes.media_title; } ]]]
custom_fields:
media_image: >
<svg viewBox="0 0 50 50" />
blur: >
[[[ if (entity.attributes.entity_picture != null) {
return '<svg viewBox="0 0 50 50" />'; } ]]]
overlay: >
[[[ if (entity.state != 'off' && entity.state != 'idle' && entity.state != 'standby' && entity.state != 'unavailable') {
return '<svg viewBox="0 0 50 50" />'; } ]]]
play_pause: >
[[[ const style = `<style>.scale-up { animation: scale-up 0.3s; cubic-bezier(.05,.5,.3,1) 1; transform-origin: center center; }
@keyframes scale-up { 0% { opacity: 0; transform: scale(0); } 100% { opacity: 1; transform: scale(1); } }</style>`;
if (entity.state === 'playing') { return `<svg viewBox="0 0 166 166">${style}<path class="scale-up" d="M0 0h59.9v166H0zm106.1 0H166v166h-59.9z"/></svg>`; }
if (entity.state === 'paused') { return `<svg viewBox="0 0 166 166">${style}<path class="scale-up" d="M0 0l166 83L0 166z"/></svg>`; } ]]]
styles:
custom_fields:
media_image:
[background-image:
"[[[ return entity.attributes.entity_picture == null ? 'linear-gradient(0deg, rgba(115, 115, 115, 0.2) 0%, rgba(115, 115, 115, 0.2) 100%)'
: 'linear-gradient(0deg, rgba(13,17,19,0.9) 0%, rgba(13,17,19,0) 50%), url(' + entity.attributes.entity_picture + ')'; ]]]",
background-size: cover, top: 0%, left: 0%, width: 100%, position: absolute]
blur:
[background-image:
"[[[ return entity.attributes.entity_picture == null ? 'none' : 'url(' + entity.attributes.entity_picture + ')'; ]]]",
background-size: cover, top: 0%, left: 0%, width: 100%, filter: blur(4px), clip-path: inset(16vw 0 0 0), position: absolute]
overlay:
[background:
"[[[ return entity.attributes.entity_picture == null ? 'rgba(255, 255, 255, 0.8)' : 'rgba(0, 0, 0, 0.4)'; ]]]",
background-size: cover, z-index: 0, top: 16vw, left: 0%, width: 100%, opacity: 1, position: absolute]
play_pause:
[filter:
"[[[ return entity.attributes.entity_picture == null ? 'none' : 'drop-shadow(0 0 1.3vw rgba(0,0,0,0.7))'; ]]]",
fill: '#dedede', top: 0, right: 0, bottom: 0, left: 0, margin: auto, width: 21%, height: 21%, position: absolute]
icon:
[fill:
"[[[ if (entity.state === 'off' || entity.state === 'idle' || entity.state === 'standby' ||
entity.state === 'unknown' || entity.state === 'unavailable') return '#9da0a2';
else return 'rgba(255, 255, 255, 0.8)'; ]]]",
top: 5.35%, left: 5.35%, width: 2.95vw, position: absolute]
name:
[top: 79.8%, left: 5.3%, position: absolute, line-height: 2vw, z-index: 10]
state:
[top: 87.5%, left: 5.3%, position: absolute, line-height: 2vw, z-index: 10,
white-space: nowrap, overflow: hidden, text-overflow: ellipsis, max-width: 90%]
icon_action:
color: '#9da0a2'
styles:
card:
[background: '#FFFFFF10', border-radius: 0.6em, box-shadow: none,
transition: none, width: 4em, height: 3.7em]
name_action:
styles:
name:
[display: flex, align-items: center, justify-content: center, margin-top: 0.5px]
card:
[background: '#FFFFFF10', color: '#9da0a2', border-radius: 0.6em, box-shadow: none,
transition: none, width: 100%, padding: 1em 1.4em 1em 1.2em, font-size: 1.06em,
font-weight: 500, letter-spacing: 0.015em]
style: '#name > ha-icon {width: 1.4em; margin-right: 0.3em; }'