Dynamic card population

Hey Guys,
Just a quick question.
Why cant I do this?

variables:
  p: '01'
type: custom:bubble-card
entity: sensor.plant_{{ p }}_humidity

I’d like to be able to populate the card based on variables.
Is this even possible? And if not, why not? lol

Thanks.

Because the card developer didn’t want to include templating, or hasn’t gotten around to adding it yet.

Support for templating in dashboard cards is a relatively uncommon feature…

You might find it more useful to describe what your end goal is and ask for help achieving that, rather than asking why a certain method doesn’t work.

1 Like

The why not is two fold here:

  1. Generally cards don’t support templates unless a custom card supports in it’s own way.
  2. Bubble card supports JS Templates for styles, but not JInja templates.

If you are after modularising your config then there are custom card solutions like config-template-card, decluttering-card, streamline-card, and uix-forge which is part of UI eXtension (UIX).

Okay, simply put I have 38 plant moisture sensors, each with their own battery and humidity entities, and all are named in the same manner:

sensor.plant_01_humidity
sensor.plant_01_battery

So, whenever I want to add another card I have to change 2 values within the YAML, it would be helpful if I only had to change the variable and have the card use that variable to select the correct humidity / battery pair.
It would also be useful to auto populate the name field using that variable (ie Plant 01).
It’s basically a time saving thing, change 1 variable and have the card display the correct information automatically.

I find this absolutely insane considering how many awesome things it allows users to do. Wish more cards supported jinja! I use almost exclusively Mushroom Template card for this reason.