Sensor value as entity name

Hello!
Is there a way to set entity name as other sensor value? That means, in a place of:

        name: blahblahblah

get kind of:

        name:  {{ states('sensor.name_value') }}

or even sth like that:

       name:  'sensor.name_value' + "some text" + 'sensor.othername_othervalue'

According to the documentation, yes.

Ensure you wrap the template in double quotes.

name:  "{{ states('sensor.name_value') }}"
name:  "{{ states('sensor.name_value') ~ 'some text' ~ states('sensor.othername_othervalue') }}"

You don’t need the outer quotes if you use a line continuation character and start the template on the next line with indentation:

name: >
  {{ states('sensor.name_value') }}
name: >
  {{ states('sensor.name_value') ~ 'some text' ~ states('sensor.othername_othervalue') }}

Reference: Important Template Rules

1 Like

Thank you for quick answer!
My configuration:

      - show_current: true
        type: weather-forecast
        entity: sensor.wemos_geiger_msv_h
        name: "{{ states('sensor.wemos_geiger_cpm') }}"
        state_color: true

after saving HA automatically changes into:

      - show_current: true
        type: weather-forecast
        entity: sensor.wemos_geiger_msv_h
        name: '{{ states(''sensor.wemos_geiger_cpm'') }}'
        state_color: true

which result in:
obraz
Seems not exactly what I want :slight_smile: What is wrong?

Your first post gave the impression you wanted to template the name option for a Template Sensor, so that’s the information I gave you.

However, your second post clarifies that you are trying to template the name option of a card. I don’t know which card you’re using (perhaps it’s the Entity card) but none of the standard cards support templates (except the Markdown card).

Some custom cards support templates so you may need to explore that option.

OK, thanks for answer!

1 Like