📝 100% Templatable Lovelace Configurations

Once again I’ve reached the limits of my understanding of Templating …

I have a couple of utility_meters and would like to show their last_period states in a pie_chart
Extracting the last_period state in a template sensor wors flawless like this:

  - platform: template
    sensors:
      ac_01_month_energy_draw_last:
        friendly_name: 'AC01 last month'
        unit_of_measurement: 'kWh'
        value_template: '{{ states.sensor.ac_01_month_energy_draw.attributes.last_period | float }}'

However, I really want to avoid creating dozens of template sensors…

so I tried this:

entities:
  - input_number.total_power_consumption_last_month
type: 'custom:config-template-card'
variables:
  - '{{ states.sensor.ac_01_month_energy_draw.attributes.last_period | float }}'
card:
  entities:
    - entity: '${vars[0]}'
      name: AC01
  title: Power Consumption Last Month
  total_amount: input_number.total_power_consumption_last_month
  type: 'custom:pie-chart-card'
  unknownText: else

But it doesn’t work :confused:

How do I propperly phrase the variables?