State in custom cards not friendly

Hey!
I’ve googled this issues but can’t get an answer.

I use custom cards (button-card, Mushroom template). When getting the status from my entites it doesn’t show the frontend “Friendly” name (Away instead of not_home. Armed_away instead of Armed away).

Is there a way to display the friendly name instead of the backend state like all native home assistant lovelace cards do?

The code:

chips:
  - type: template
    icon: mdi:face-woman
    entity: person.xyz

The result:
image

Thanks!
Rob

You have to build the code yourself.

Alright thanks! Any pointers as to how?

Well, I don’t use custom mushroom chips and the documentation doesn’t show where to put the template. If you can point that out, I can help with the template.

Thanks, got it. I’ll be templating my way to success.

Thanks!

For reference, this is how:

chips:
  - type: template
    icon: mdi:face-woman
    entity: person.xyz
    content: |-
      {% set state=states('person.xyz') %}
      {% if state=='home' %}
      {% elif state=='not_home' %}
      Away
      {% else %}
      {{ states(entity).capitalize() }}
      {% endif %}

The last else-statement is for showing if the person has entered a named zone.

Your template won’t work as is. You should also try not to name variables the same as key words (on, off, state, this etc…) because it can cause unpredictable problems.

Also, you don’t need the first if case. It’s covered by the else statement.

Try this.

      {% set status = states('person.jason') %}
      {% if status == 'not_home' %} Away
      {% else %} {{ status.capitalize() }}
      {% endif %}
1 Like