Herbert01
(Werner)
October 11, 2022, 12:35pm
1
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
petro
(Petro)
October 11, 2022, 12:51pm
3
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
Herbert01
(Werner)
October 11, 2022, 1:08pm
4
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.
petro
(Petro)
October 11, 2022, 1:15pm
5
If it were to work it would be
- unique_id: fenster_schlafzimmer
name: "fensterstatus_schlafzimmer_dg"
...
attributes:
friendly_name: Fenster Arbeitszimmer
EdwardTFN
(Edward Firmo)
October 11, 2022, 1:41pm
6
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 %}
petro
(Petro)
October 11, 2022, 1:45pm
7
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
EdwardTFN
(Edward Firmo)
October 11, 2022, 1:57pm
8
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?
petro
(Petro)
October 11, 2022, 1:58pm
9
Nope, you aren’t. That’s too much for some people.
Herbert01
(Werner)
October 11, 2022, 2:35pm
10
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
petro
(Petro)
October 11, 2022, 2:36pm
11
You can’t reload when switching from old to new, you have to restart.
petro
(Petro)
October 11, 2022, 2:38pm
13
Are you using a unique_id and are you changing it?
Herbert01
(Werner)
October 11, 2022, 2:41pm
14
In the moment not. Have first deactivated the new format and activated the old format.
Nonetheless
fensterstatus_schlafzimmer_dg_5
EdwardTFN
(Edward Firmo)
October 11, 2022, 3:22pm
15
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.
petro
(Petro)
October 11, 2022, 3:27pm
16
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.
Herbert01
(Werner)
October 11, 2022, 3:37pm
17
I do not understand it either. Only have the old sensor active. Checked configuration and restarted.
See image.
petro
(Petro)
October 11, 2022, 4:11pm
18
Did you EVER start up with unique_id? If yes, that’s the problem.
Herbert01
(Werner)
October 11, 2022, 4:25pm
19
Yes, I used to, but not at the moment. Can this be undone?