Template sensors don't appear

I have been trying to add a few template sensors. In the sample below the first sensor is available, the others not.

When I load the individual state templates in the tester, they all work fine.

Would anyone have an idea what I am missing?

template:
  - sensor:
      - name: "Total Electricity Consumption"
        unique_id: total_electricity_consumption
        state: >
          {{ (states('sensor.energy_consumption_tarif_1') | float(0)) + (states('sensor.energy_consumption_tarif_2') | float(0)) }}
        unit_of_measurement: "kWh"

      - name: "Total Electricity Production"
        unique_id: total_electicity_production
        state: >
          {{ (states('sensor.energy_production_tarif_1') | float(0)) + (states('sensor.energy_production_tarif_2') | float(0)) }}
        unit_of_measurement: "kWh"

      - name: "Electricity Consumption Today"
        unique_id: daily_electricity_consumption
        state: >
          {{ (states('sensor.dsmr_daily_electricity_tarif_1') | float(0) +  states('sensor.dsmr_daily_electricity_tarif_2') | float(0) ) | round(3) }}
        unit_of_measurement: "kWh"

      - name: "Electricity Production Today"
        unique_id: daily_electicity_production
        state: >
          {{ (states('sensor.dsmr_daily_electricity_production_tarif_1') | float(0) - states('sensor.dsmr_daily_electricity_production_tarif_2') | float(0) ) | round(3) }}
        unit_of_measurement: "kWh"

Looks fine to me. Tabs instead of spaces?

Any errors in the logs?

No errors related to templates in the logs.
And also checked (again) for tabs. Wish that was true, but unfortunately just spaces.

I even tried just a single sensor, one which currently fails, but even that doesn’t work.

  1. Where are you putting this config?

  2. Did you restart HA or just reload your config? The first time you use any new integration you need to restart. Then after that you can use reload.

EDIT: Also to prevent odd results when one or more sensors are unavailable you should use an availability template in each sensor, e.g.:

template:
  - sensor:
      - name: "Total Electricity Consumption"
        unique_id: total_electricity_consumption
        state: >
          {{ (states('sensor.energy_consumption_tarif_1') | float(0)) + (states('sensor.energy_consumption_tarif_2') | float(0)) }}
        availability: >
          {{ has_value('sensor.energy_consumption_tarif_1') and has_value('sensor.energy_consumption_tarif_2') }}
        unit_of_measurement: "kWh"

More here: Why an availability template is important for energy template sensors