This code gives me errro and i dont know why

Hi there
I want to make a template that creates an entity that is the sum of 2 other
I was trying the code below for example but it gives me a errro:

Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See ?, line ?).

does anyone know why?

Code:

sensor:
  - platform: template
    sensors:
        bomba_calor_energy:
        friendly_name: 'Bomba de Calor Energia'
        unit_of_measurement: 'kWh'
        value_template: >
            {{(states('sensor.bomba_calor_ac_channel_a_energy') | float)}}

note that, the line:
{{(states('sensor.bomba_calor_ac_channel_a_energy') | float)}}
runs sucessufully in the developer tools / template

Incorrect indentation. Should be:

- platform: template
  sensors:
    bomba_calor_energy:
      friendly_name: 'Bomba de Calor Energia'
      unit_of_measurement: 'kWh'
      value_template: >
        {{ states('sensor.bomba_calor_ac_channel_a_energy') | float }}

You should also be using the new format for new template sensors.

Btw, why users SHOULD use a new format?
Assume, a simple sensor is needed - why cannot we use an old legacy format?
Yes, the legacy format lacks some “new features” like “state_class”, but it allows to use a templated “friendly_name” (which is not available for the “new format”).

Ofc, we may suspect that some day the legacy format will be deprecated, so probably users should transfer their sensors to the “new format”.
I interfered into this discussion mainly just to clarify - may be somewhere (like in Discord) there is a discussion “lets kill the legacy format”…