Creating First Template Sensor - or Not?

Of all the dumb questions I have asked, this maybe the dumberest.

I am trying to create my first template sensor, to add up the energy consumption values on Samsung air conditioners.
In my configuration.yaml file I have

template:
  - sensor: 
      total_air_con_energy:
        friendly_name: "Total Air Con Energy Consumption"
        unit_of_measurement: "kWh"
        state: >
          {% set kitchen = states('sensor.kitchen_air_conditioner_energy') | float %}
          {% set dirtykitchen = states('sensor.dirty_kitchen_air_conditioner_energy') | float %}
          {% set masterbedroom = states('sensor.master_bedroom_air_conditioner_energy') |float %}

          {{ ((kitchen + dirtykitchen + masterbedroom) +) | round(1, default=0) }}

Sort of copied from something I have seen elsewhere.

As far as I can tell, this has not created a new sensor - or I am looking for it incorrectly.
If I understand correctly, this should create a new entity - but all attempts so far to find an entity called total_air_con_energy have failed. Does not appear when I look either in entities, or in developer tools.

So please put this dumbererest guy out of his misery. What am I getting wrong ?

Just copy and paste your template, (the part below state: >)

{% set kitchen = ...
...
... default=0) }}

in Dev Tools > Templates, and you will see what you get.

Just make a sensor group with sum as your calculation type. It’s a helper. No need for a template.

As for yoru template, you have a random + sign that’s not adding anything. That will cause problems.

Thank you both
Turned out I had three errors in the code.
The helper definitely the way to go, as I had 12 entities to add, and typing them all out would have been a pain - thank you Petro (no “D” this time…)
Never knew about the Dev Tools functionality, so great help VDR
Now just got to figure out what the numbers actually mean…

Glad it’s sorted. For those looking in future, your original code above is an invalid mixture of modern format and legacy format sensor configuration.

If you’re doing the modern template: then - sensor:, you use name: instead of the slug, and do not include friendly_name:. Modern uses state:, legacy uses value_template:. You can’t mix and match.

Sorry to come back to this but I am now getting an error in the logs.
Messages are:

Invalid config

The following integrations and platforms could not be set up:
* template ([Show logs](http://192.168.68.127:8123/config/logs?filter=template))
Please check your config and [logs](http://192.168.68.127:8123/config/logs).

The logs show:

Logger: homeassistant.helpers.template
Source: helpers/template.py:233
First occurred: 12:20:47 AM (1 occurrences)
Last logged: 12:20:47 AM
Template variable warning: 'suppress_confirmation' is undefined when rendering '{"text": "{{ text }}", "event": "{{ event_id }}", "suppress_confirmation": "{{ suppress_confirmation }}"}'
Logger: homeassistant.config
Source: config.py:978
First occurred: August 19, 2023 at 1:44:10 PM (1 occurrences)
Last logged: August 19, 2023 at 1:44:10 PM
Invalid config for [template]: [total_air_con_energy] is an invalid option for [template]. Check: template->sensor->0->total_air_con_energy. (See /config/configuration.yaml, line 81)

The config currently is as follows:

template:
  - sensor: 
      total_air_con_energy:
        friendly_name: "Total Air Con Energy Consumption"
        unit_of_measurement: "kWh"
        state: >
          {% set kitchen = states('sensor.kitchen_air_conditioner_energy') | float %}
          {% set dirtykitchen = states('sensor.dirty_kitchen_air_conditioner_energy') | float %}
          {% set masterbedroom = states('sensor.master_bedroom_air_conditioner_energy') | float %}

          {{ (kitchen + dirtykitchen + masterbedroom) | round(1, default=0) }}

So have I copied something wrongly or added something I should not have ? Honestly, at this point in my HA journey, dealing with logs is a bit of a step beyond my capabilities.

You’re still mixing the two different formats of configuration.

Look at my first link and look at an example modern format sensor in the docs. Then make yours structured like that, with a name instead of the total_air_con_energy “slug” heading, and no friendly_name.

The logs don’t make sense because your config is so broken that the system can’t identify what the problem is.

Thank you Troon
Sorted