Problem with custom icons in cover template

Hi,
I have this cover template that works fine:

cover:
  - platform: template
    covers:
      cortina_sala:
        device_class: curtain
        unique_id: cortina_sala
        friendly_name: "Cortina Sala"
        open_cover:
          - service: script.turn_on
            target:
              entity_id: script.accion_cortina
            data:
              variables:
                option: Abierta
        close_cover:
          - service: script.turn_on
            target:
              entity_id: script.accion_cortina
            data:
              variables:
                option: Cerrada
        stop_cover:
          - service: script.turn_on
            target:
              entity_id: script.accion_cortina
            data:
              variables:
                option: Pausada
        icon_template: >-
          {% if is_state('input_select.estado_cortina', 'Abierta') %}
            /local/icons/cortinasabiertas.png
          {% elif is_state('input_select.estado_cortina', 'Cerrada') %}
            /local/icons/cortinascerradas.png
          {% else %}
            /local/icons/cortinaflecha.png
          {% endif %} 

But I get the next error and can’t show the custom icons (I used SVG and PNG icons and get the same error):

Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:94
Integration: Template ([documentation](https://www.home-assistant.io/integrations/template), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+template%22))
First occurred: 16:15:35 (1 occurrences)
Last logged: 16:15:35

Error validating template result '/local/icons/cortinaflecha.png' from template 'Template("{% if is_state('input_select.estado_cortina', 'Abierta') %} /local/icons/cortinasabiertas.png {% elif is_state('input_select.estado_cortina', 'Cerrada') %} /local/icons/cortinascerradas.png {% else %} /local/icons/cortinaflecha.png {% endif %}")' for attribute '_icon' in entity cover.cortina_sala validation message 'contains non-whitespace: /local/icons/cortinaflecha.png'

Any ideas, what I doing wrong?

I’m fairly sure the icon element is looking for icon data as opposed to a png so something like this:

        icon_template: >-
          {% if is_state('input_select.estado_cortina', 'Abierta') %}
            "mdi:door-open"
          {% elif is_state('input_select.estado_cortina', 'Cerrada') %}
            "mdi:door-closed"
          {% else %}
            "mdi:cloud-question"
          {% endif %} 

Correct. I think the last example in the docs is incorrect and should use the entity_picture_template instead.

If entity_picture_template works for you, please edit the page or provide feedback using the links at the bottom of the doc page.

1 Like

Both are right, thank you. Using entity_picture_template I can use my custom icon images.