I am a 77 year old man and have just started using Home Assistant to make some simple improvements to my home.
Probably, the question is obvious, but I want to be sure.
Are the templates saved in the file “templates.yaml”, located in HASSIO/config?
Thank you very much for your help.
Hola Viejo!
Exactly what are you looking for? Are you talking about card in the Lovelace UI? I don’t think have a file called templates.yaml… some more details would be appreciated.
Thank you for your interest.
It is not related to a Lovelace card. I have read the HA “Templating” documentation, but I don’t understand how the template editor works using “template developer tools”.
I have written my first file in yaml format with the template data.
What name should I name him and in what folder should I keep him?
I understand that the name must be “templates.yaml” and I must save it in HASSIO/config.
Apologies for my English
Translated with www.DeepL.com/Translator
There is no such thing.
There is no expectation of a templates.yaml in the config directory. There is nothing that references that.
I think you are misunderstanding what the templating is for.
You use templating to access attributes for creating entities or automations. You use the dev tools templating to figure out how to access the attribute you want, and implement that in your entity or automation creation.
Now I hope I understand. The templates are included in the file “configuration.yaml”, in a section that starts with
-
platform: template
and then follow the different templates.
For example:- platform: template sensors: moon_phases: friendly_name: 'Fases de la luna' entity_id: sensor.moon value_template: >
Is this correct?
Almost. It goes in a section for sensors
Would that be right?
#####################################
# Empieza la sección SENSORES
#####################################
sensor:
# Se añade el sensor de Fecha y Hora
- platform: time_date
display_options:
- 'date'
- 'time'
# Fases de la Luna
- platform: moon
- platform: template
sensors:
moon_phases:
friendly_name: 'Fases de la luna'
entity_id: sensor.moon
value_template: >
# folllow template data .....
# Se añade el sensor de
# temperatura y humedad DHT22
- platform: dht
sensor: DHT22
pin: 4
name: DHT22
# temperature_offset: 2.1
# humidity_offset: -3.2
monitored_conditions:
- temperature
- humidity
#################################
# Finaliza sección SENSORES
#################################
That looks right to me, just fill in your value_template: and all should be good.
Thank you so much for your patience and help a newbie.
Hey Javier, I think what you initially tried to achieve was to create a file where to store your sensors configuration in a file called templates.yaml rather than have everything in the configuration.yaml.
Both approaches work but the benefit of having a separated yaml file is that it is better organised and easier to manage (specially when your configuration.yaml gets big).
Here is more info
Home it helps