-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathbutton-card-example.yaml
248 lines (240 loc) · 8.77 KB
/
button-card-example.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
243
244
245
246
247
248
---
## Install button-card from here https://github.com/custom-cards/button-card
resources:
- url: /local/button-card.js
type: module
## button-card templates
button_card_templates:
## General template (used in other templates)
esxi_stats_general:
styles:
card:
- background-color: '#837e80'
- border-radius: 10%
- padding: 10%
- color: ivory
- text-shadow: 0px 0px 1px black
- text-transform: capitalize
grid:
- grid-template-columns: 1fr 1fr
- grid-template-rows: 1fr min-content min-content min-content min-content
icon:
- width: 70%
- margin-top: -10%
name:
- font-weight: bold
- font-size: 13px
- color: white
- align-self: middle
- justify-self: start
- padding-bottom: 4px
img_cell:
- justify-content: start
- align-items: start
- margin: none
## hosts template
esxi_stats_hosts:
show_icon: false
template: esxi_stats_general
styles:
grid:
- grid-template-areas: '"i uptime" "n n" "version version" "cpu_total cpu_total" "mem_total mem_total"'
- grid-template-columns: 1fr 1fr
- grid-template-rows: min-content min-content min-content min-content
custom_fields:
version:
- font-size: 12px
- padding-bottom: 2px
- align-self: middle
- justify-self: start
cpu_total:
- font-size: 12px
- padding-bottom: 2px
- align-self: middle
- justify-self: start
mem_total:
- font-size: 12px
- padding-bottom: 2px
- align-self: middle
- justify-self: start
## vm template
esxi_stats_vm:
icon: 'mdi:server'
aspect_ratio: 1/1
template: esxi_stats_general
styles:
grid:
- grid-template-areas: '"i uptime" "n n" "cpu cpu" "ram ram" "state state"'
custom_fields:
uptime:
- icon: "mdi:arrow-up"
cpu:
- font-size: 12px
- padding-bottom: 2px
- align-self: middle
- justify-self: start
ram:
- font-size: 12px
- padding-bottom: 2px
- align-self: middle
- justify-self: start
state:
- font-size: 12px
- padding-bottom: 2px
- align-self: middle
- justify-self: start
## datastore template
esxi_stats_datastores:
icon: 'mdi:harddisk'
aspect_ratio: 1/1
template: esxi_stats_general
styles:
grid:
- grid-template-areas: '"i free" "n n" "capacity capacity" "hosts hosts" "vms vms"'
custom_fields:
capacity:
- font-size: 12px
- padding-bottom: 2px
- align-self: middle
- justify-self: start
hosts:
- font-size: 12px
- padding-bottom: 2px
- align-self: middle
- justify-self: start
vms:
- font-size: 12px
- padding-bottom: 2px
- align-self: middle
- justify-self: start
views:
- title: ESXi Stats example
cards:
## button card for a host. Uses esxi_stats_general and esxi_stats_hosts templates above
- type: custom:button-card
entity: sensor.<NAME_OF_SENSOR>
name: <CARD NAME HERE>
template: esxi_stats_hosts
custom_fields:
uptime: >
[[[
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span><span style="color: var(--text-color-sensor);">
${ states['sensor.<NAME_OF_SENSOR>'].attributes.uptime_hours } hours
</span></span>`
]]]
version: >
[[[
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span> Version: <span style="color: var(--text-color-sensor);">
${ states['sensor.<NAME_OF_SENSOR>'].attributes.version }
</span></span>`
]]]
cpu_total: >
[[[
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span> CPU Cap: <span style="color: var(--text-color-sensor);">
${ states['sensor.<NAME_OF_SENSOR>'].attributes.cpuusage_ghz } /
${ states['sensor.<NAME_OF_SENSOR>'].attributes.cputotal_ghz } GHz</span></span>`
]]]
mem_total: >
[[[
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span> Memory: <span style="color: var(--text-color-sensor);">
${ states['sensor.<NAME_OF_SENSOR>'].attributes.memusage_gb } /
${ states['sensor.<NAME_OF_SENSOR>'].attributes.memtotal_gb } GB</span></span>`
]]]
## button card for a datastore. Uses esxi_stats_general and esxi_stats_datastore templates above
- type: custom:button-card
entity: sensor.<NAME_OF_SENSOR>
name: <CARD NAME HERE>
template: esxi_stats_datastores
custom_fields:
free: >
[[[
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span><span style="color: var(--text-color-sensor);">
${states['sensor.<NAME_OF_SENSOR>'].attributes.free_space_gb}</span></span>`
]]]
capacity: >
[[[
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span> Capacity: <span style="color: var(--text-color-sensor);">
${states['sensor.<NAME_OF_SENSOR>'].attributes.total_space_gb}</span></span>`
]]]
hosts: >
[[[
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span> Hosts: <span style="color: var(--text-color-sensor);">
${states['sensor.<NAME_OF_SENSOR>'].attributes.connected_hosts}</span></span>`
]]]
vms: >
[[[
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span> VMs: <span style="color: var(--text-color-sensor);">
${states['sensor.<NAME_OF_SENSOR>'].attributes.virtual_machines}</span></span>`
]]]
## button card for a virtual machine. Uses esxi_stats_general and esxi_stats_vm templates above
- type: custom:button-card
entity: sensor.<NAME_OF_SENSOR>
name: <CARD NAME HERE>
template: esxi_stats_vm
styles:
icon:
- color: >
[[[
if ( states['sensor.<NAME_OF_SENSOR>'].attributes.status == "green")
return "green";
if ( states['sensor.<NAME_OF_SENSOR>'].attributes.status == "warning" )
return "yellow";
return "red";
]]]
custom_fields:
uptime: >
[[[
return `<ha-icon
icon="mdi:arrow-up"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span><span style="color: var(--text-color-sensor);">
${states['sensor.<NAME_OF_SENSOR>'].attributes.<VM_NAME_HERE>.uptime_hours}</span></span>`
]]]
cpu: >
[[[
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span>CPU: <span style="color: var(--text-color-sensor);">
${states['sensor.<NAME_OF_SENSOR>'].attributes.cpu_count}</span></span>`
]]]
ram: >
[[[
return `<ha-icon
icon="mdi:memory"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span>Mem: <span style="color: var(--text-color-sensor);">
${states['sensor.<NAME_OF_SENSOR>'].attributes.memory_allocated_mb} MB</span></span>`
]]]
state: >
[[[
return `<ha-icon
icon="mdi:harddisk"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span>State: <span style="color: var(--text-color-sensor);">
${states['sensor.<NAME_OF_SENSOR>'].attributes.state}</span></span>`
]]]