Button-card: get sensor value - user friendly name instead of the technical value

There is any way for the below template:

{{ states('sensor.012110518400021093_selected_program') }}

which returns:

Dishcare.Dishwasher.Program.Eco50

to get friendly name as below (the same sensor via tile or entity control):

Captura de Pantalla 2023-12-04 a las 19.44.08

My target is to get user friendly names in the button-card, as of now it looks like below:

Is there any information in the sensor’s attributes which can be used?

Unfortunately not, but how it works then in the other controls?

No guarantee because I don’t use Home Connect:


type: custom:button-card
entity: sensor.012110518400021093_selected_program
name: |
  [[[
    let base = entity?.state,
        str = base.substring(base.lastIndexOf('.') + 1),
        num = str.match(/\d+/),
        p = str.split(num)[0];
    return num
      ? p + ' ' + num + '°C'
      : p;
  ]]]

1 Like

@pedolsky Thank you for the code, I ended up using JavaScript in that part, somehow I missed this option before.