New template format - What? How? Where?

I wish to have template configuration in separate files the same way that the legacy format allows.

Added to configuration.yaml:
template: !include templates.yaml

Taking the following documented example. How should this be modified to live in templates.yaml?

template:
  - sensor:
      - name: "Average temperature"
        unit_of_measurement: "°C"
        state: >
          {% set bedroom = states('sensor.bedroom_temperature') | float %}
          {% set kitchen = states('sensor.kitchen_temperature') | float %}

          {{ ((bedroom + kitchen) / 2) | round(1, default=0) }}

Found this video which still doesn’t appear to explain how to do it. Everything lumped into configuration.yaml.

Still don’t get it. What do I need to do?

Take template: out and move everything left two spaces.

1 Like

out of interest - do you HAVE to move everything left 2 spaces? I only ask - because my split config is done using include_dir_merge_list and all my files (which work perfectly) maintain the indentation as if sensor, binary_sensor etc was still in the file. But maybe it is the merge part of the function that compensates for that?

That is possible too I think.

1 Like

No.

as long as you maintain consistent spacing within the included file it will be fine.

3 Likes

Thanks. That didn’t work for me before. Will give it a go.

Nope, you don’t. EDIT: Seems I’m late.

1 Like

Anybody knows why there is 4 spaces indentation between “- sensor” and “- name:” and not only 2 spaces?

post an example of properly formatted code illustrating what you are talking about.

spacing doesn’t matter as long as the fields line up. THis is valid

template:
- sensor:
                                        - name: foo
                                          state: ...
1 Like