Cannot get separate templates.yaml to work

Hi!

Having this in my configuration.yaml:
template: !include templates.yaml

And in my templates.yaml I have the following:

- cover:
    - name: "Zonnescherm Kantoor Boris (Inverted)"
      device_class: awning
      state: >
        {% if is_state('cover.switch_zonnescherm_kantoor_boris', 'open') %}
          closed
        {% else %}
          open
        {% endif %}
      current_position_template: >
        {% if state_attr('cover.switch_zonnescherm_kantoor_boris', 'current_position') is not none %}
          {{ 100 - state_attr('cover.switch_zonnescherm_kantoor_boris', 'current_position') }}
        {% else %}
          0
        {% endif %}
      set_cover_position:
        service: cover.set_cover_position
        target:
          entity_id: cover.switch_zonnescherm_kantoor_boris
        data:
          position: >
            {{ 100 - position }}
      open_cover:
        service: cover.close_cover
        target:
          entity_id: cover.switch_zonnescherm_kantoor_boris
      close_cover:
        service: cover.open_cover
        target:
          entity_id: cover.switch_zonnescherm_kantoor_boris
      stop_cover:
        service: cover.stop_cover
        target:
          entity_id: cover.switch_zonnescherm_kantoor_boris

    - name: "Zonnescherm Overloop (Inverted)"
      device_class: awning
      state: >
        {% if is_state('cover.switch_zonnescherm_overloop', 'open') %}
          closed
        {% else %}
          open
        {% endif %}
      current_position_template: >
        {% if state_attr('cover.switch_zonnescherm_overloop', 'current_position') is not none %}
          {{ 100 - state_attr('cover.switch_zonnescherm_overloop', 'current_position') }}
        {% else %}
          0
        {% endif %}
      set_cover_position:
        service: cover.set_cover_position
        target:
          entity_id: cover.switch_zonnescherm_overloop
        data:
          position: >
            {{ 100 - position }}
      open_cover:
        service: cover.close_cover
        target:
          entity_id: cover.switch_zonnescherm_overloop
      close_cover:
        service: cover.open_cover
        target:
          entity_id: cover.switch_zonnescherm_overloop
      stop_cover:
        service: cover.stop_cover
        target:
          entity_id: cover.switch_zonnescherm_overloop

But the templates do NOT show up. I know the file is recognized, as when I make a typo, I cannot reload HASS as it gives a YAML error for templates.yaml

What am I doing wrong?

Template cover is not part of the template integration it is a cover platform. So that config has to go under cover: not template:

It even says so on the template integration page:

So this is what you have to change your config to:

1 Like

Thanks Tom!

THis means I cannot get all the templates in one single yaml file can I?

I could create a templates-covers.yaml file and use that now
Imagine I want sensor templates in the future, I’d need to create templates-sensors.yaml and use that?

And in configuration.yaml I’d need to do:

cover:
  - platform: template
    cover: !include templates-covers.yaml

Clear! Thanks!

You could if you used packages. But that would be very confusing.

it would be best to create a covers.yaml file and put all your types of cover (including template covers) in that.

No, that is part of the template integration.

Nope. You need to do:

cover: !include templates-covers.yaml # or preferably just covers.yaml