WTH? Why not allow simple format templates in lovelace card code

Why can’t we do simple string formatting right in the Lovelace card code? Something like below.

type: entities
entities:
  - type: attribute
    entity: sensor.covid19_stats_mi
    attribute: >
      {{ "{:,}".format(states('positive')|int) }}
    name: Total Cases
    icon: 'mdi:virus'

This would simply convent the value of “positive” into a whole and add commas to it. I find it frustrating that we need to create an entire sensor template for this.

what happens when you want to add that to your UI in more than one place? It might be better to have this configurable on each sensor itself without the need to create a template sensor. Maybe in the customize section.

Oddly enough, the friendly_name: in a template sensor can’t be templated.

Yes it can… you have to use friendly_name_template.

1 Like

Eh !, I missed that one, when was that introduced ?

Like… ~2-3 years ago? It’s been there a LONG time.

To put it into perspective, it’s been there before the great folder migration of early 2019. So we can’t even check the history for when it was added.

Bugger.!
I’m gonna have to read release notes in more detail
:roll_eyes:

Does this cover ALL integrations ?

No, only specific template xxx integrations.

nope, we tried to get it to work for template binary_sensors too, but Balloob heavily opposed that… search for the FR and ye shall find the reasoning behind that.

Yeah !, I remember that battle, Paulus just shot it down !

Thanks for the memory jogger :+1: