core icon indicating copy to clipboard operation
core copied to clipboard

wrong entity_id when esphome component name is empty

Open Masterz69 opened this issue 2 years ago • 6 comments

The problem

In ESPhome configuration device friendly_name f.e. set to XXX. Goal is to have to have entity_id for switch on that device: switch.XXX.

For that purpose set

esphome:
  name: xxx
  friendly_name: XXX

switch:
  - platform: output
    name: ''

with hope switch entity_id will be {device friendly name} + {switch name} = XXX+'' = XXX

But actually entity_id is switch.XXX_XXX.

This started to appear in esphome 2023.6.2. Previously switch entity_id was created as expected: switch.XXX.

What version of Home Assistant Core has the issue?

core-2023.8.4

What was the last working version of Home Assistant Core?

n/a

What type of installation are you running?

Home Assistant OS

Integration causing the issue

esphome

Link to integration documentation on our website

https://www.home-assistant.io/integrations/esphome/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Related to #97558, highly likely. Same in esphome 2023.6.2 & 2023.8.2.

Masterz69 avatar Sep 01 '23 18:09 Masterz69

Hey there @ottowinter, @jesserockz, @kbx81, @bdraco, mind taking a look at this issue as it has been labeled with an integration (esphome) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of esphome can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign esphome Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


esphome documentation esphome source (message by IssueLinks)

home-assistant[bot] avatar Sep 01 '23 18:09 home-assistant[bot]

Previously, approx. before #97578 it was possible to set Device Friendly Name and Component Name to '', what results in HA with entity id like {domain}.{device_name} (f.e. switch.myplug).

What is extremely Ok for devices like simple light/switch.

Now see no way how to set Device Friendly Name & have HA entity id like {domain}.{device_name}

  • for single switch/light/... entity on device.

This is not legacy way & was functional till June/July 2023 (approx.). F.e. 2023.2.4 create entity_id like {domain}.{device_name} when object name is '' and Device Friendly Name is set.

Now in same setup HA entity_id become {domain}.{device_name}_{device_name}.

Masterz69 avatar Sep 02 '23 16:09 Masterz69

Can you try name: None in ESPHome YAML?

jesserockz avatar Sep 06 '23 20:09 jesserockz

Can you try name: None in ESPHome YAML?

Same result.

In Validate see

- platform: output
  output: out_relay_1
  name: ''
  icon: mdi:ceiling-light-outline

Looks promising, but in HA anyway: image

As well it have side effects. Me using substitutions to define 'channel' prefix. When this substitution used as only in switch definition:

  channel_1_text: None

switch:
  - platform: output
    output: out_relay_1 
    name: channel_1_text

it appears in Validate as name: '', but in other places where it used to compose name it appears as regular string:

  channel_1_text: None

switch:
  - platform: template
    name: 'channel_1_text Inching'

=>

- platform: template
  name: None Inching

Fail.

Masterz69 avatar Sep 07 '23 07:09 Masterz69

I believe this was a change in HA that started adding the friendly name, but I could be wrong.

My issue is not the naming but that it is inconsistent between entities and services. So my Ns-Panel with Blackymas Blueprint device becomes switch.robs_ns_panel_robs_ns_panel_relay_1 but the service is esphome.robs_ns_panel_send_command_text_printf. This breaks the Blueprint since it is looking for the same base name between the two and it can't find the service.

I fixed this for now by just commenting out the friendly name line, so the blueprint now works again.

roblamoreaux avatar Oct 16 '23 16:10 roblamoreaux

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.