New sensor configuration "friendly_name" possible?

Hello,

I am currently converting my sensors to the new format.

For example, my code previously looked like this:

      fensterstatus_arbeitszimmer:
        friendly_name: Fenster Arbeitszimmer
        value_template: |
          {% set b1 = states('binary_sen......................................

This is how I convert it to the new format:

      - name: "fensterstatus_arbeitszimmer"
        state: |
          {% set b1 = states('binary_sen...............................

With the new format, however, I couldn’t find a way to specify a “friendly_name”.
Is that somehow possible?

Greeting Werner

Try:

Option 1

or

Option 2

I don’t believe that works anymore. Someone wanted dynamic names in name: and now that functionality is lost. I haven’t tried in a while, so :man_shrugging:

Hello,

unfortunately I’m not good at it.
Just tested it like this:

      - unique_id: fenster_schlafzimmer
        name: "fensterstatus_schlafzimmer_dg"
        state: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_007cf906_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_698aff06_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} geschlossen
          {% elif b1 == 'on' and b2 == 'off' %} gekippt
          {% elif b2 == 'on' %} offen
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} nicht verfügbar
          {% else %} ?
          {% endif %}
        icon: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_007cf906_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_698aff06_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} mdi:window-closed-variant
          {% elif b1 == 'on' and b2 == 'off' %} mdi:angle-acute
          {% elif b2 == 'on' %} mdi:window-open-variant
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} mdi:exclamation
          {% else %} ?
          {% endif %}   

Unfortunately does not work.

If it were to work it would be

      - unique_id: fenster_schlafzimmer
        name: "fensterstatus_schlafzimmer_dg"
        ...
        attributes:
          friendly_name: Fenster Arbeitszimmer

As you already have an unique_id you can now change the name using the UI in the Devices & Services area (tab Entities).

Anyway, if you want to create a new one, try this:

      - name: Fenster Arbeitszimmer
        unique_id: b82c8f67-4bec-4978-a9fc-28b04e9b3091
        state: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_007cf906_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_698aff06_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} geschlossen
          {% elif b1 == 'on' and b2 == 'off' %} gekippt
          {% elif b2 == 'on' %} offen
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} nicht verfügbar
          {% else %} ?
          {% endif %}
        icon: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_007cf906_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_698aff06_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} mdi:window-closed-variant
          {% elif b1 == 'on' and b2 == 'off' %} mdi:angle-acute
          {% elif b2 == 'on' %} mdi:window-open-variant
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} mdi:exclamation
          {% else %} ?
          {% endif %}

He want’s the name different from the entity_id. which is the functionality that is hard to replicate in the new style. So your solution will make the entity_id: sensor.fenster_arbeitszimmer instead of sensor.fensterstatus_arbeitszimmer

He can go to the Entities tab under Devices and Services, select the entity and then rename the friendly name or the entity_id.
Am I missing something?

Nope, you aren’t. That’s too much for some people.

Hello,

Of course that is also possible and I would do the math.
Currently I have the problem that the sensor is renamed after each test.

Original:

fensterstatus_schlafzimmer_dg

New:

fensterstatus_schlafzimmer_dg_1
fensterstatus_schlafzimmer_dg_2

You can’t reload when switching from old to new, you have to restart.

I did that.

Are you using a unique_id and are you changing it?

In the moment not. Have first deactivated the new format and activated the old format.
Nonetheless
fensterstatus_schlafzimmer_dg_5

I don’t think this is the point… the point is that some people, and here I will include myself, don’t know about all the possibilities in Home Assistant. :wink:

Sorry, I don’t follow you.

You can only have 1. If you aren’t using a unique_id and the entity exists in HA, it will append _# to it. If you restart HA, you should only get the number of entities that come through. If you Reload templates, you’re going to get a _# for every time you change the unique_id.

I do not understand it either. Only have the old sensor active. Checked configuration and restarted.
See image.

Did you EVER start up with unique_id? If yes, that’s the problem.

Yes, I used to, but not at the moment. Can this be undone?

Yes, delete them