Get friendly names of sensor options

Hello I want to get the state of my washing machine in a template card.

The sensor looks like this:

options:
  - '0'
  - '1'
  - '2'
  - '3'
  - '4'
  - '5'
  - '6'
  - '7'
  - '8'
  - '9'
device_class: enum
icon: mdi:information
friendly_name: Waschmaschine Machine Status

When I put this in my template card {{ states('sensor.waschmaschine_phase') }} the result looks like this:
06-07-2023_11-08-14_firefox

But when I use a entity card insted of a template card the option ‘0’ reads as ‘Bereit’ (ready in english):
06-07-2023_11-12-43_firefox

So how do I get the “friendly name” for the option ‘0’ in a template? Something like {{ states('sensor.waschmaschine_phase') | friendly_name }}?

I hope the problem is understandable.

Greetings,
Simon

state_attr("sensor.waschmaschine_phase", "friendly_name")

But apparantly, this will return

Waschmaschine Machine Status

I don’t think there is a ‘friendly name’ for the options…
My guess is that this is ‘translated’ somewhere in the device integration; but withouth knowing which integration you use I can’t say much about it…

Ofc you can always create the full blown template like:

{% if is_state('sensor.waschmaschine_phase', '0') %}
       Bereit
     {% elif is_state('sensor.waschmaschine_phase', '1')%}
        Etwas
     {% elif is_state('sensor.waschmaschine_phase', '2')%}
        NochEtwas
     {% elif is_state('sensor.waschmaschine_phase', '3')%}
        etc.etc.
     {% endif %}

2 Likes

Hi thanks for your help! I’m using this integration: GitHub - Andre0512/hon: Home Assistant integration for Haier hOn: support for Haier/Candy/Hoover home appliances like washing machines and air conditioners in 19 languages.

I looked at the repo and your were completely right. The translation is in the integration.

I installed this Integration GitHub - PiotrMachowski/Home-Assistant-custom-components-Custom-Templates: This integration adds possibility to use new functions in Home Assistant Jinja2 templating engine. and translated the sensor ({{ ct_state_translated("sensor.waschmaschine_phase", "de") }}), which worked. So thank you for for setting me in the right direction :slight_smile:

1 Like