Help with icon template

Good afternoon,
I’m relatively new to Home Assistant and still trying to get a hold of yaml code, and I’m trying to edit the yaml code for a chip card in the Mushroom cards. I’ve created a helper with 5 different options for the state of my home (Home, Away, Night, Guest, Vacation).

I’d like to change the icon based upon the state of that entry. This is the code I’m trying.


  - type: entity
    entity: input_select.house_mode
    icon_template: >-
      {% if is_state("input_selct.house_mode", "Home") %}
        mdi:home
      {% elif is_state("input_select.house_mode", "Away") %}
        mdi:mdi:home-export-outline
      {% elif is_state("input_select.house_mode", "Night") %}
        mdi:weather-night
      {% elif is_state("input_select.house_mode", "Vacation") %}
        mdi:beach
      {% else %}        
        mdi:party-popper
      {% endif %}

I’m getting the following configuration errors and failing to understand the issue.

*At path: chips.3.icon_template – Expected a value of type never, but received: `"{% if is_state(“input_selct.house_mode”, “Home”) %}\n mdi:home\n{% elif is_state(“input_select.house_mode”, “Away”) %}\n mdi:mdi:home-export-outline\n{% elif is_state(“input_select.house_mode”, “Night”) %}\n mdi:weather-night\n{% elif is_state(“input_select.house_mode”, “Vacation”) %}\n mdi:beach\n{% else %} \n mdi:party-popper\n{% endif %}"

Your chip type should be template. The error is coming from the use of icon_template:. You need to use icon:.

- type: template
    entity: input_select.house_mode
    icon: >-
      {% if is_state(entity, "Home") %}
        mdi:home
      {% elif is_state(entity, "Away") %}
        mdi:mdi:home-export-outline
      {% elif is_state(entity, "Night") %}
        mdi:weather-night
      {% elif is_state(entity, "Vacation") %}
        mdi:beach
      {% else %}        
        mdi:party-popper
      {% endif %}

Thanks so much! That did the trick. So much to learn!

1 Like