zmechu
June 25, 2023, 11:31am
1
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'
123
(Taras)
June 25, 2023, 1:35pm
2
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
zmechu
June 25, 2023, 2:54pm
3
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:
Seems not exactly what I want What is wrong?
123
(Taras)
June 25, 2023, 3:11pm
4
zmechu:
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.