--- ## Install button-card from here https://github.com/custom-cards/button-card ## This example shows sensor display cards and UI controls for ESXi management 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: ## UI CONTROLS SECTION ## ESXi Stats provides switches, buttons, and selectors for managing your infrastructure - type: entities title: ESXi Controls entities: # VM Power Switches - entity pattern: switch.{host}_{entry_id}_vm_switch_{vm_name} # Example: switch.192_168_1_10_abc123_vm_switch_myvm - switch.*_vm_switch_* # Host Power Switches - entity pattern: switch.{host}_{entry_id}_host_switch_{host_name} # Example: switch.192_168_1_10_abc123_host_switch_myhost - switch.*_host_switch_* # Host Reboot Buttons - entity pattern: button.{host}_{entry_id}_host_reboot_{host_name} # Example: button.192_168_1_10_abc123_host_reboot_myhost - button.*_host_reboot_* # Power Policy Selectors - entity pattern: select.{host}_{entry_id}_select_power_policy_{host_name} # Example: select.192_168_1_10_abc123_select_power_policy_myhost - select.*_select_power_policy_* ## SENSOR DISPLAY CARDS ## ESXi Stats creates individual sensors for each attribute ## Use your Home Assistant entities list to find the exact sensor names ## Replace placeholders with your actual sensor entity names ## button card for a host using individual sensors - type: custom:button-card entity: sensor._name # Replace with actual host name sensor name: template: esxi_stats_hosts custom_fields: uptime: > [[[ return ` ${ states['sensor._uptime_hours'].state } hours ` ]]] version: > [[[ return ` Version: ${ states['sensor._version'].state } ` ]]] cpu_total: > [[[ return ` CPU Cap: ${ states['sensor._cpuusage_ghz'].state } / ${ states['sensor._cputotal_ghz'].state } GHz` ]]] mem_total: > [[[ return ` Memory: ${ states['sensor._memusage_gb'].state } / ${ states['sensor._memtotal_gb'].state } GB` ]]] ## button card for a datastore. Uses esxi_stats_general and esxi_stats_datastore templates above ## Replace sensor.esxi_datastore_DATASTORENAME with your actual datastore sensor entity - type: custom:button-card entity: sensor.esxi_datastore_ name: template: esxi_stats_datastores custom_fields: free: > [[[ return ` ${states['sensor.esxi_datastore_'].attributes.free_space_gb}` ]]] capacity: > [[[ return ` Capacity: ${states['sensor.esxi_datastore_'].attributes.total_space_gb}` ]]] hosts: > [[[ return ` Hosts: ${states['sensor.esxi_datastore_'].attributes.connected_hosts}` ]]] vms: > [[[ return ` VMs: ${states['sensor.esxi_datastore_'].attributes.virtual_machines}` ]]] ## VM button card using individual sensors ## Replace placeholders with your actual VM sensor names - type: custom:button-card entity: sensor._name # Replace with actual VM name sensor name: template: esxi_stats_vm styles: icon: - color: > [[[ if ( states['sensor._status'].state == "green") return "green"; if ( states['sensor._status'].state == "warning" ) return "yellow"; return "red"; ]]] custom_fields: uptime: > [[[ return ` ${states['sensor._uptime_hours'].state}` ]]] cpu: > [[[ return ` CPU: ${states['sensor._cpu_count'].state}` ]]] ram: > [[[ return ` Mem: ${states['sensor._memory_allocated_mb'].state} MB` ]]] state: > [[[ return ` State: ${states['sensor._state'].state}` ]]]