crashmatt
(Matthew Coleman)
September 3, 2022, 9:58pm
1
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) }}
crashmatt
(Matthew Coleman)
September 3, 2022, 10:15pm
2
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?
nickrout
(Nick Rout)
September 3, 2022, 10:48pm
3
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?
nickrout
(Nick Rout)
September 3, 2022, 10:55pm
5
That is possible too I think.
1 Like
finity
September 3, 2022, 11:14pm
6
No.
as long as you maintain consistent spacing within the included file it will be fine.
3 Likes
crashmatt
(Matthew Coleman)
September 4, 2022, 7:59am
7
Thanks. That didn’t work for me before. Will give it a go.
petro
(Petro)
September 4, 2022, 11:38am
8
Nope, you don’t. EDIT: Seems I’m late.
1 Like
Toreca
December 17, 2022, 10:58am
9
Anybody knows why there is 4 spaces indentation between “- sensor” and “- name:” and not only 2 spaces?
finity
December 17, 2022, 11:06am
10
post an example of properly formatted code illustrating what you are talking about.
petro
(Petro)
December 17, 2022, 11:12am
11
spacing doesn’t matter as long as the fields line up. THis is valid
template:
- sensor:
- name: foo
state: ...
1 Like