Friendly_name with value from a state?

Is it possible to include a template state to a friendly_name in customizations or other way?

The goal i would like to achive is to change this

I have a card with 4 lines with values i have scraped from a webpage:

ST1 Gasprice                         12.34 kr
ST1 Gasprice Uppdated                    24/3
ST1 Ethanolprice                     11.22 kr
ST1 Ethanolprice Updated                 24/3

But i would love if i could have only two line, like this:

ST1 Gasprice - (24/3)               12.34 kr
ST1 Ethanolprice - (24/3)           11.22 kr

I tried this:

sensor.st1_gas_price:
  friendly_name: ST1 Gasprice - ({{states.sensor.st1_st1_gas_date.state}})
  icon: mdi:gas-station

But no luck

There’s no way I know of to use variables in anything other than value_template: or data_template: It would be a nice feature request though.

I haven’t tried this but you might want to try to create a notify message that updates when “ST1 Gasprice Uppdated” gets updated. Then I think you can print the notify message on your front end in a group that you can format any number of variable into a form you like.

This is the example which looks like it can accept variable for front end display.

{
“message”: “The sun is {% if is_state(‘sun.sun’, ‘above_horizon’) %}up{% else %}down{% endif %}!”
}

Can you point me in the right direction here?
I have not found any information on how to get a notify message to appear on the frontend?
Maybe you think of persistent notification? I could use that but then i get that persistant notification on ALL my tabs.

I took a closer look and it doesn’t appear notify will work. I have confirmed that template sensor will work. I have a template sensor that takes google calendar event message and puts it into a status on the front end. I altered it so it shows that event message twice below.

  - platform: template
    sensors:
      eventmessage:
        friendly_name: 'eventmessage'
        value_template: '{{ states.calendar.calendar.attributes.message }} and {{ states.calendar.calendar.attributes.message }}'

Yes putting 2 sensor values into a 3:rd one and have that one in a card on the front end is actually a solution i can work with.
But still, a feature to be able to have the “friendly name” templated might be usefull.

Maybe this thread could be moved to feature request.

2 Likes

Reviving this old thread. I’m looking for this exact same feature. I don’t think it has been implemented…

More specifically, I have a switch that stays on for a pre-defined amount of time. That amount of time can be read from an attribute of a sensor. I would like to be able to display that attribute in the friendly_name of that switch in the front-end. Is that possible now?

I believe the only nod to this Feature Request is the friendly_name_template option in the Template Sensor integration.