Migrating(?) to a templates.yaml

Running HAOS accessing files via Studio Code Server.

I don’t like posting such a seemingly simple question to the forums, but I haven’t been able to find the answer via search or documentation. Current entries are just diving into the syntax (which is great) and other error corrections; but my question is more…basic.

I’ve been reading more about “advanced” templating, such as using trigger for sensor templates or obtaining forecasts. This, from my understanding, can only be achieved by creating the sensors with yaml (not with UI) via creating a templates.yaml and point to it within the configuration.yaml with “template: !include templates.yaml”…great.

When I do this, however, what happens to my old template sensors (of which I have many)? Where even are they?…below is the entire extent of my configuration.yaml with no currently existing templates.yaml

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

I found a relatively recent post here in Mar 2024; but, they talk about a split configuration, and within templates.yaml he begins reference even more yaml files I don’t have.

Thank you all.

in configuration.yaml you set template: !include template.yaml (just create the file if you do not have it) so in your example it would be like this:


automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template: !include template.yaml

Then migrate everything to the new file, and start the code without template: like for example this:

sensor:
  - name: your template sensor
    icon: mdi:currency-usd
1 Like

Thank you for the response! This covers the creation of my new template sensors via yaml; but, if I have a current template sensor I’d like to add a time trigger to, where do I find that yaml to edit and, should I move it over to the newly created templates.yaml file?

Scenario: the template sensor with a time calculation that I want to update every hour, not every minute (seemingly common fix to improve efficiency of system). I’ve read the documentation for the syntax to achieve this, but where do I edit my existing template sensor I created a month ago via the UI? Or do I simply have to recreate the sensor within the templates.yaml (but still doesn’t quench my curiosity of where all my current template sensors are written in yaml in my system haha)

Thank you again.