iantrich / config-template-card

📝 Templatable Lovelace Configurations
MIT License
443 stars 57 forks source link

Add Custom Name #97

Closed dmkjr closed 2 years ago

dmkjr commented 2 years ago

Probably less of a bug report than a syntax, but we cannot figure out how to append plain text before some code in the 'name'.

`type: custom:config-template-card entities:

That works fine but I want to create something like "Today we've used [insert sensor data]" or something similar.

Anyone that can point me in the right direction, I would appreciate it.

iantrich commented 2 years ago
name: ${"Today we've used " + states['sensor.daily_water'].state}
dmkjr commented 2 years ago

Thank you @iantrich . That worked. What about if we were doing this on the results line? For example,

type: custom:config-template-card
entities:
  - sensor.time
  - sensor.date
card:
  type: entity
  name: ${ states['sensor.date'].state }
  entity: ${"Hello World! " + states['sensor.daily_water'].state}
  icon: mdi:water

Obviously it's throwing an error in that context. Is there a 'prefix' or 'suffix' type attribute?

iantrich commented 2 years ago

No, it is just Javascript