Displaying combined sensors

So I wanted to have a combined energy consumption of my house, but didn’t want to put a relay in series with my main breaker so I preserve what I am calling essential load, refrigerator, etc, and didn’t insert a point of failure on that circuit

so I created a helping entity that adds all my energy sensors, but often times I lose communication with one of them, and my entity changes to unknown. I wanted to enter the YAML code for the helping entity, but I don’t quite seem to find it.

Tried creating a template on configuration.yaml (which I know was a bad idea)

 - sensor:
      - name: "Energia total"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >
          {% set sensors = [
            states('sensor.220_potencia'),
            states('sensor.iluminacao_geral_potencia'),
            states('sensor.tomadas_potencia')
          ] %}
          {% set valid = sensors | map('float', default=0) %}
          {{ valid | sum }}

But I didn’t find the sensor.Energia_total to use it on the dashboard

Does anyone have any ideas how can I achieve that goal?

try this way

          {{
            (
              (states('sensor.220_potencia') | float(0)) +
              (states('sensor.iluminacao_geral_potencia') | float(0)) +
              (states('sensor.tomadas_potencia') | float(0))
            )
          }}

after that reboot HA, and see if yousee sensor.energia_total.

i use this for a temperature sensor

{% set temps = [
            states('sensor.comedor_temperature'),
            states('sensor.comedor_temperature_2')
          ] %}
          {% set valid = temps | select('match', '^[0-9.]+$') | map('float') | list %}
          {% if valid | length > 0 %}
            {{ (valid | sum / valid | length) | round(1) }}
          {% else %}
            unavailable
          {% endif %}

thank you so much

Also to prevent possible future issues see: Why an availability template is important for energy template sensors