Hi,
configuration.yaml:
template alexatimer: !include configuration/template-alexatimer.yaml
configuration/template-alexatimer.yaml
- sensor:
- name: "Timer2 Wohnzimmer"
state: >
{% if states('sensor.echo_wohnzimmer_next_timer') != 'unavailable' %}
{{ ((as_timestamp(states('sensor.echo_wohnzimmer_next_timer')) - as_timestamp(now()))/60) | int + 1 }}
{% else %}
0
{% endif %}
unit_of_measurement: Minutes
icon: hass:timer
This is not working as no “Timer2 Wohnzimmer” sensor is created. No error in the logs, too. Semms like it is ignored completely. The same code copied to the template:
section in configuration.yaml is working. Anyone an idea why the code does not work if seperated?
pedolsky
(Pedolsky)
September 12, 2021, 7:09pm
2
Have you tried
template alexatimer: !include template-alexatimer.yaml
?
I now moved my template-alexatimer.yaml to the same folder as configuration.yaml and used this:
template alexatimer: !include template-alexatimer.yaml
Still not working, no difference
pedolsky
(Pedolsky)
September 12, 2021, 7:31pm
4
Ah, I got it not before. You have a folder called „configuration“ (I mixed it up with the genuine „config“ folder). How did you bind your custom folder?
What do you mean with “bind”? Actually, I think that it isn’t related to the folder, as other integrations like the following are working as expected:
configuration.yaml
homematic: !include configuration/homematic.yaml
configuration/homematic.yaml
interfaces:
rf:
...
Shorter example:
configuration.yaml
template:
- sensor:
- name: "Testsensor Intern"
state: 3
template alexatimer: !include configuration/template-alexatimer.yaml
configuration/template-alexatimer.yaml
- sensor:
- name: "Testsensor Extern"
state: 3
Only “Testsensor Intern” and not “Testsensor Extern” shows up in Home Assistant. Why?
pedolsky
(Pedolsky)
September 12, 2021, 8:02pm
7
I know, it is in the documentation examples but I would try without the dash in the file name.
As an alternative, you might have a look at that discussion:
https://community.home-assistant.io/t/migrating-legacy-templates-to-the-new-template-section/305757/42