Display Attribute in Custom:Button_Card

Hello all. I’m trying to get my pool temperature to display in a custom card. I’ve figured out how to get the attribute and display it using an Entity card, but I can’t get this Button Card to show it.

The Entity Card says “Pool Temperature” with the correct value. The button_card just says “Pool Temperature” but does not display a value. Here is my code:

type: custom:button-card
name: "Pool Temperature"
tap_action:
  action: navigate
  navigation_path: '#pool'
sensors:
      current_pool_temperature:
        unit_of_measurement: °F
        friendly_name: Pool Temperature
        value_template: >-
          {{ state_attr("climate.pentair_f6_70_52_pool_heat",
          "current_temperature") }}'
entity: climate.pentair_f6_70_52_pool_heat
attribute: "current_temperature"
styles:
  card:
    - padding: 18px
  name:
    - font-size: 18px
    - font-weight: 500
    - color: black

start with this and then add your additional customizations. i don’t know a ton about that particular card and i’m not sure about what you’re doing w/ sensors in that card, so i’ll just show how you can get attributes showing as you asked.

type: 'custom:button-card'
color_type: icon
entity: climate.pentair_f6_70_52_pool_heat
show_state: false
show_name: false
show_label: true
label: >
  [[[  return states['climate.pentair_f6_70_52_pool_heat'].attributes.current_temperature; ]]]



1 Like

To add to that, button-card is one of very few cards in HA, that don’t use Jinja2 as template language (what you did with {{ ), but rather Javascript (what @armedad made with the [[[ ).

If you want to template in button-card, you can’t use Jinja2. :slight_smile:

1 Like

You are a genius! Thank you.

Thanks for the explanation. I had no idea why my version wasn’t working.

1 Like