I have my templates split in separate files in a “templates” folder and configured like:
template: !include_dir_merge_list templates/
I have several files already created, for sensors and binaries, but today I need to create a cover template and I’m unable to find the correct format.
Of course the format in the documentation doesn’t work, as it’s written for a plain configuration.yaml.
# This format doesn't work.
cover:
- platform: template
covers:
salon_persiana_principal:
device_class: garage
friendly_name: "Persiana principal"
position_template: >
{{100 - (state_attr('cover.salon_persiana1','current_position')|int)}}
set_cover_position:
service: cover.set_cover_position
data_template:
entity_id: cover.salon_persiana1
position: >
{{100 - position}}
Doesn’t give error, but the device is not there.
So I’ve tried to mimic the config on my other template files
- covers:
- name: salon_persiana_principal
# friendly_name: Persiana principal
# device_class: shade
position_template: >
{{100 - (state_attr('cover.salon_persiana1','current_position')|int)}}
set_cover_position:
service: cover.set_cover_position
data_template:
entity_id: cover.salon_persiana1
position: >
{{100 - position}}
But also doesn’t work and gives the following error:
Invalid config for [template]: [cover] is an invalid option for [template]. Check: template->cover. (See /home/homeassistant/.homeassistant/templates/covers.yaml, line 0).
Could be that the template format has became uncompatible with the other templates when in separate files?