Sensor templates in sensors.yaml

I just learned that the template integration format has changed since I last made one. I used to use what is now the legacy format and I have them in a sensors.yaml file. I want to use the new format but I get an error no matter where I place the information and no matter what I include. What do I need to do to get it to work?

This is the data that I am trying to enter into my sensors.yaml file

template:
  - sensor:
      - name: Deebot N8 Pro+ Battery
        unit_of_measurement: "%"
        state: '{{ state_attr('vacuum.deebot_n8_pro', 'battery_level') }}'

You can’t use the new method in packages. It is not supported. :frowning:

If you want to use a seperate file for all your templates, you have to use something like this in configuration.yaml:

template: !include template.yaml

EDIT: Didn’t read thoroughly, sorry. But it points into the same direction. Use a seperate file for template in configuration.yaml:

template: !include template.yaml
1 Like