Template works in developer tools but not in template card?

Hi all. I have a simple template to show the state of my Tado TRVs on my dash board. It should should the number heating or idle if none. When I test the code in the developer tools it works just fine. But then when I stick it into thTexte secondary information field of a template card it doesn’t output anything.

I am fairly new to home assistant and certainly YAML so learning as I go. Just a little lost here.

The code:


{% if states.climate|selectattr('attributes.hvac_action', 'equalto', 'heating')|list|length > 0 %}
{{ states.climate|selectattr('attributes.hvac_action', 'equalto', 'heating')|list|length }} heating
{% else %} Idle
{% endif %}

I’ve attached photos of the code working in developer tools but not on my dashboard. Any help would be appreciated :slight_smile:


the template will show " Idle " what ever is wrong, so have it ever showed “Heating” ?

Please share the card configuration. Most core cards do not allow templating without seeing the card’s details we cannot give accurate guidance.

@boheme61 I used to have it show a when the thermostats were in heat mode but this wasn’t actually what I wanted, as they basically always stay in Auto mode. When I switched it I had to do so digging on how to get the specific attribute to show, but no the template card has never shown “Heating”

@Didgeridrew It is a mushroom template card. But I have put the code below


type: custom:mushroom-template-card
primary: Heating
secondary: >-
  {% if states.climate|selectattr('attributes.hvac_action', 'equalto',
  'heating')|list|length > 0 %}
    {{ states.climate|selectattr('attributes.hvac_action', 'equalto', 'heating')|list|length }} heating
  {% else %} Idle

  {% endif %}
icon: mdi:radiator
icon_color: >-
  {% if states.climate|selectattr('attributes.hvac_action', 'equalto',
  'heating')|list|length > 0 %}
    red
  {% endif %}
layout: vertical
fill_container: true
tap_action:
  action: more-info
hold_action:
  action: toggle
double_tap_action:
  action: none
entity: group.thermostats

no idea what has changed but as of today it now works :man_shrugging:t4:

  • Core 2024.12.1
  • Supervisor 2024.11.4
  • Operating System 14.0
  • Frontend 20241127.6