Entity Name as just Friendly Name?

I’m going a bit crazy trying to get ESPHome to set entities names how I would like. So, according to the light documentation, if I set name to none, I just get an entity as light.friendly_name, but I’m gett light.device_name_friendly_name. Any ideas what I’m doing wrong? Here’s my yaml:

# Enable logging
logger:

# Enable Home Assistant API
api:
  id: api_id

ota:
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

captive_portal:

output:
  - platform: gpio
    pin: GPIO14
    id: relay

esphome:
  name: switch-dining-room
  friendly_name: Friendly Name
  platform: ESP8266
  board: esp01_1m

light:
  - platform: binary
    output: relay
    id: mainlight
    name: none

So in this case I’m getting light.switch_dining_room_friendly_name as my entity name. Any ideas? Is this a bug?

@contagon

friendly_name: Friendly Name

This means that the friendly name is attached to ALL entity names. I suggest you delete the above friendly_name line and enter your name for this switch under the switch entity.

The instructions you posted doesnt make sense… I have probably missed something…

esphome:
  name: switch-dining-room
  friendly_name: Dining Room Light
  platform: ESP8266
  board: esp01_1m

This will add dining room light to all the entities, and, as you have none (should be None) in the light name, the light entity will be Dining Room Light

light:
  - platform: binary
    output: relay
    id: mainlight
    name: None

friendly_name: Friendly Name

This means that the friendly name is attached to ALL entity names. I suggest you delete the above friendly_name line and enter your name for this switch under the switch entity.

@JulianDH I thought this would do the trick, just tried it. Deleting the friendly name results in the light being named light.none :man_facepalming:. And then the device has the less than ideal switch-dining-room as the device name as well (but I could live with that if the light was named correctly.

This will add dining room light to all the entities, and, as you have none (should be None) in the light name, the light entity will be Dining Room Light

@Holdestmade that was the behavior I expected too and is why I’m left scratching my head. Just tried what you posted and I get an entity of light.switch_dining_room_dining_room_light. Actually, testing with other entities, it appears device_name is being added to all names, and when name: none is set, the name is just replaced with friendly_name resulting in device_name_friendly_name. This isn’t expected behavior is it?

That sounds like what Z2M does now, didn’t know it was coming to ESPHOME ?

Just checked a recent device I have done and it does not include the device name

esphome:
  name: inverter-fans
  friendly_name: Inverter Fans
  comment: ESP32 DEV BOARD
  platform: ESP8266
  board: esp01_1m

fan:
  - platform: speed
    output: fan_output
    name: None
    id: inverter_fans
    restore_mode: RESTORE_DEFAULT_OFF

This made a fan entity called Inverter Fans and the entity_id is fan.inverter_fans

Maybe its because my name and friendly name are the same ?

Also, I think it needs to be None not none

Yeah, so I just tried

esphome:
  name: switch-dining-room
  friendly_name: Switch Dining Room
  platform: ESP8266
  board: esp01_1m

light:
  - platform: binary
    output: relay
    id: mainlight
    name: None

And I get light.switch_dining_room_switch_dining_room… Could there be a bug in light entities? Seems unlikely. Idk why I’d be having different behavior. Running esphome 2023.8.3.

Just found this, are you using MQTT with esphome ?

Not a bug. It is working as designed.

Maybe this will help. The Entity ID is built from the domain, name and friendly name.
Valid characters for names are: abcdefghijklmnopqrstuvwxyz0123456789-_ (lowercase, no spaces).
Friendly Names must only consist of upper/lowercase characters, the underscore character and numbers. Spaces will be converted to underscore characters.

you’ll always get light.<device_name>_<friendly_name> from every integration.

Is the prepending of <device_name> in the entity name a recent change? I can’t seem to find anything about it in the documentation and there seems to be a lot of conflicting information about online.

If this is the new norm, is there any way to achieve light.<device_name> or light.<friendly_name>? It seems awfully redundant to have to do light.<device_name>_<friendly_name> as the device name and friendly name are generally close to identical.

2 Likes

This different behavior is somewhat irritating. If friendly_name is not set in esphome: block, <device_name> will not be prepended.

1 Like

You’re welcome to join the discussions on the behavior over on discord. I had nothing to do with it, just the messenger.

The ESPHome core help page says:

It is used by Home Assistant as the integration name, device name, and is automatically prefixed to entities where necessary.

What deems “where necessary”? If you define a esphome: + friendly_name:, is there any way to forego the automatic addition of the device name?

It seems to be more than that – some things work, some do not, with the use of “name: None”. It is as though that usage was put into some platforms but not others. I have a light that keeps coming out as Flood1_Flood1, no matter what combination of None, none, etc. I put in.

Is this just a flawed implementation, or am I misunderstanding?

esphome:
  name: flood1
  friendly_name: Flood1


light:
- platform: rgbww
  name: None

This continues to yield entity_id.flood1_flood1 and name “Flood1 Flood1”. I’m trying not to do it by removing the friendly name from esphome as I have a number of git sourced packages that use a friendly name, so my templates (used in both those packages and not) need to be consistent.

“None” just does not seem to consistently work, nor “none”, nor omitting the name field (it disappears from home assistant), nor using an empty quoted string.

Am I missing a syntax?

Linwood

PS. Correction, an empty string gives a name “Flood1” but entity_id of light.flood1_flood1 so not even quite consistent.

PPS. Well, I may have found a workaround. A blank (single character space) in the name field, i.e. ’ ', seems to work. Which is a bit weird. I bet I’m stumbling on a bug in syntax where it’s not empty, but later being blank trimmed. But … for now… it seems to work.

4 Likes

Well, this worked. The entity name did get renamed to nothing, just blank in the settings UI, but the entity id is now correctly populated, and the frontend all displays correctly. Thank you. Will use a space for future esphome configs. At least, until the devs break it again.

1 Like

I’ve been having the same issue and opened a feature request here: Add option to remove the prefixing of "friendly_name" since this affects the voice assistant · Issue #2476 · esphome/feature-requests · GitHub.