Skip to content

Instantly share code, notes, and snippets.

@AdamJHowell
Created March 15, 2024 06:53
Show Gist options
  • Save AdamJHowell/724dc1ecbab097399eece55fa237d0e3 to your computer and use it in GitHub Desktop.
Save AdamJHowell/724dc1ecbab097399eece55fa237d0e3 to your computer and use it in GitHub Desktop.
HA card TypeError
ButtonCardJSTemplateError: TypeError: states['sensor.home_assistant_supervisor_cpu_percent'] is undefined in 'return `<ha-icon icon="mdi:cpu-64-bit" style="width: 20px; height: 20px; color: #74B72E;">...'
tap_action:
action: more-info
type: custom:button-card
group_expand: false
hold_action:
action: none
double_tap_action:
action: none
layout: vertical
size: 40%
color_type: icon
show_name: true
show_state: false
show_icon: true
show_units: true
show_label: false
show_entity_picture:
false
show_live_stream: false
card_size: 3
entity: sensor.system_monitor_processor_temperature
icon: mdi:cpu-64-bit
aspect_ratio: 1/1
name: CPU<br/>Usage
styles:
card:
- background-color: '#222222'
- border-radius: 10%
- padding: 7%
- color: '#DDDDDD'
- font-size: 12px
- text-shadow: 0px 0px 5px black
- text-transform: capitalize
grid:
- grid-template-areas: '"i n" "temp temp" "cpu cpu" "ram ram" "sd sd"'
- grid-template-columns: 1fr 1fr
- grid-template-rows: 1fr min-content min-content min-content
name:
- font-weight: bold
- font-size: 14px
- color: '#DDDDDD'
- text-align: left
- margin-top: '-10px'
- justify-self: start
- padding-bottom: 4px
img_cell:
- justify-content: start
- align-items: start
- margin: none
icon:
- align-self: start
- color: '#FFD700'
- width: 80%
- overflow: visible
- margin-top: '-17%'
custom_fields:
temp:
- padding-bottom: 2px
- align-self: middle
- justify-self: start
cpu:
- padding-bottom: 2px
- align-self: middle
- justify-self: start
- '--text-color-sensor': >-
[[[ if (states["sensor.system_monitor_processor_use"].state > 80)
return "red"; ]]]
ram:
- padding-bottom: 2px
- align-self: middle
- justify-self: start
- '--text-color-sensor': >-
[[[ if (states["sensor.system_monitor_memory_usage"].state > 80)
return "red"; ]]]
sd:
- align-self: middle
- justify-self: start
- '--text-color-sensor': >-
[[[ if (states["sensor.system_monitor_disk_usage_config"].state > 80)
return "red"; ]]]
custom_fields:
cpu: |
[[[
return `<ha-icon
icon="mdi:cpu-64-bit"
style="width: 20px; height: 20px; color: #74B72E;">
</ha-icon><span> Total: <span style="color: var(--text-color-sensor);">${states['sensor.system_monitor_processor_use'].state}%</span></span>`
]]]
ram: |
[[[
return `<ha-icon
icon="mdi:cpu-64-bit"
style="width: 20px; height: 20px; color: #74B72E;">
</ha-icon><span> Supervisor: <span style="color: var(--text-color-sensor);">${states['sensor.home_assistant_supervisor_cpu_percent'].state}%</span></span>`
]]]
sd: |
[[[
return `<ha-icon
icon="mdi:cpu-64-bit"
style="width: 20px; height: 20px; color: #74B72E;">
</ha-icon><span> Core: <span style="color: var(--text-color-sensor);">${states['sensor.home_assistant_core_cpu_percent'].state}%</span></span>`
]]]
lock:
enabled: false
duration: 5
unlock: tap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment