Attribute_templates not supported anymore?

Trying to get a template sensor created and add attributes to it. This is what I tried from docs


template:
  sensors:
    SunnyAngle:
      unit_of_measurement: "°"
      value_template: "{{ '%+.1f'|format(state_attr('sun.sun', 'elevation')) }}"
      attribute_templates:
        temp: >-
          {{ '%+.1f'|format(state_attr('sun.sun', 'elevation')) }}

From the logs

Invalid config for [template]: [attribute_templates] is an invalid option for [template]. Check: template->sensor->0->attribute_templates. (See /config/configuration.yaml, line 40).

If you are using the new modern template format, refer to this-

template:
  - sensor:
      - name: "Sun Angle"
        unit_of_measurement: "°"
        state: >-
          {{ '%.1f'|format(state_attr('sun.sun', 'elevation')) }}
        attributes:
          temp: >-
            {{ '%.1f'|format(state_attr('sun.sun', 'elevation')) }}

However, if you are still using the legacy format, refer to-

1 Like