ekutner / home-connect-hass

Alternative (and improved) Home Connect integration for Home Assistant
MIT License
624 stars 58 forks source link

Entities default naming pattern and issues with Device renaming #433

Open michalk-k opened 2 days ago

michalk-k commented 2 days ago

Currently, the default pattern for entity names is prefixed by $brand $appliance - It prevents HA from automatically shortening names on Device View. Making their names unreadable

image

If the beginning of entity name equals Device name, the prefix is stripped out.

Now question: what part of the system is responsible for renaming entities while renaming the device? I though that by renaming the device to match entity prefixes, I will clean up the Device page. Unfortunatelly it ended up with even bigger mess:

  1. During renaming of the device from Susicka to Bosch Susicka, HA informed me, that no (out of 49 or so) entities will be renamed
  2. Something opposite happened
  3. All (most) entities have been renamed a). Some some remained untouched (seems a few unavailable ones)
  4. After some few forth-back attempts of device renaming I ended up with more prefixes of those entities: Bosch Bosch Susicka, Bosch Susicka, Bosch Susicka Bosch

Just wonder if should I raise an issue to HA Core, or if the renaming is done by the component, with the issue in applying the predefined pattern.

z-vrba commented 2 days ago

I use this naming pattern: "Myčka $name" and it is presented as

Snímek obrazovky 2024-11-11 v 20 18 37
michalk-k commented 2 days ago

Yes. But changing the pattern doesn't change entity names. how to enforce that?

z-vrba commented 2 days ago

I see. It is a quite long time I have renamed it, but I think I have reinstalled the integration.

ekutner commented 1 day ago

The integration generates the names based on the configured pattern. I see that you already found how to change the pattern and that is the right way to do it. After a restart/reload the integration will change the display names to match the new pattern, however, there may be some entities that are not renamed because they are unavailable. Those entities will be renamed the next time they become available. Note that if you change the names using HA that will override any name set by the integration and the pattern you set will be ignored.

michalk-k commented 1 day ago

Thank you. Good to know that it's enough to wait. I have an impression that Reload didn't make the job (to any of the entities).

ekutner commented 1 day ago

I believe it should but didn't test it. If it doesn't, try restarting HA, that should definitely do it.

michalk-k commented 23 hours ago

Neither reloading nor restart helped. I had to remove the integrated devices/entities (see screenshot) and re-add it afterwards image

The problem with such approach is, that a user has no option to select the entity naming pattern before adding entities. And tbh at that step the new user has no idea about how device and entity names and their relationship.

BTW I found that user may want to change device name - the integration doesn't provide such option during adding the device. It uses name provided by API.

Fortunatelly (for me), after adding devices (thus their entities too) I changed the pattern, and it did work this time, renaming already existing entities. So I'm happy right now I achieved cleaner view.

Now I'm really confused, why changing had effect on entity names this time, just after adding them, while it wasn't working before. (btw hyphen in name pattern prevents HA from automatic prefix removal)

And let me ask again for device renaming process. If a user uses a device rename option, is it HA core code which renames entities, or it's integration code? Why changing a device name results in renaming entities leading to the mess described in the OP? I just wanted to change device name to match prefix of already existing entity names. The message which pops up, that no entity will be renamed is even more confusing.

with regards

ekutner commented 19 hours ago

As I mentioned, once you rename entities using the HA UI it takes over the names and they will be managed by HA, which will most likely create the kind of mess you experienced. Changing the name template through the integration's "configure" UI will take effect without requiring removing and re-adding the integration.