Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capitalize entity name in Home Assistant #16702

Merged
merged 5 commits into from
Feb 21, 2023

Conversation

Drafteed
Copy link
Contributor

Hello!

What do think about this small change?

vs

@TheJulianJES
Copy link

From https://developers.home-assistant.io/blog/2022/07/10/entity_naming/

Device, Area, and Entity names all start with a capital letter, the rest of the words are lower case (unless it's a word that represents a brand/name/abbreviation of course).

@Drafteed
Copy link
Contributor Author

Drafteed commented Feb 16, 2023

Good! Looks like a match requirements.

@Koenkk
Copy link
Owner

Koenkk commented Feb 18, 2023

@TheJulianJES If I understand it correctly, Aqara Button Battery does not satisfy these requirements.

  • Device, Area, and Entity names all start with a capital letter ✅
  • the rest of the words are lower case (unless it's a word that represents a brand/name/abbreviation of course). 🚫

Shouldn't it be Aqara button battery?

@Drafteed
Copy link
Contributor Author

The name of my device (Aqara Button) seems to be misleading.

Based on this documentation the entity should be named simply: Battery, without device name. In the Home Assistant UI, it will automatically displayed as: Device name + space + Entity name (e.g. Aqara button Battery, where Aqara button is device name, and Battery is entity name) if entity set has_entity_name=True.

But, I do not see the has_entity_name support in MQTT integration or docs to do this. Anyway, the entity name (e.g. Battery) sould start with a capital letter.

Some integrations with has_entity_name support:

@Koenkk
Copy link
Owner

Koenkk commented Feb 19, 2023

@frenck could you confirm that Aqara Button Battery is preferred? (over Aqara Button battery) (capital B difference)

@frenck
Copy link
Contributor

frenck commented Feb 19, 2023

I'm missing the full context, as it is unclear what is the device name and what is the entity name. Both should start with a capital letter.

Yet, this PR seems to do magic with names using methods like capitalize, which will always lead to wrong things. For example, if I have a sensor or device with my name it, an abbreviation or any other company name, it will mess with those as well.

So looking at this PR, I don't see how it is matching anything Home Assistant aims for, nor do I understand what it is fixing. The only thing I see is how it could make things worse.

But, maybe I'm misunderstanding this PR.

../Frenck

@Drafteed
Copy link
Contributor Author

Drafteed commented Feb 19, 2023

Aqara Button is my device name:

This PR is not changing the name of the device.

This PR change only first letter of entity name (e.g. battery -> Battery, power usage -> Power usage) if name of device starts with a capital letter.

@frenck
Copy link
Contributor

frenck commented Feb 19, 2023

@Drafteed Sure, but it will also change VOC or voc into Voc, which is wrong (as an example)

@Drafteed
Copy link
Contributor Author

Drafteed commented Feb 21, 2023

change VOC or voc into Voc

VOC will not be changed, but voc yes, will be transformed to Voc (utils.capitalize).

HA frontend now do the same logic:

Device name: Aqara button
Entity name: Aqara button device temperature
Entity name: Aqara button voc

Anyway, entity (exposed property) name in Z2M always consist of only lowercase words separated by underscores and I don't see a way to do it right other than add a "human-readble name" field to each property of each 2719 (!) device.

Yes, this solution will not be ideal in cases where the name is an abbreviation, but it's much easier.

@Koenkk Koenkk merged commit f5cceb1 into Koenkk:dev Feb 21, 2023
@Koenkk
Copy link
Owner

Koenkk commented Feb 21, 2023

Thanks!

@frenck
Copy link
Contributor

frenck commented Feb 21, 2023

HA frontend now do the same logic:

It does not, which is what the whole changing process is about (and what we are going through). The whole device naming and entity naming part is changing. All this PR does is introduce something in the middle (instead of correctly handling it). Which is an odd thing to do.

I honestly think this change is wrong and should be reverted.

../Frenck

@Drafteed
Copy link
Contributor Author

Drafteed commented Feb 21, 2023

@Koenkk please revert this PR.

Let's summarize. I did some small research. To do this thing right, we need:
1. Add support has_entity_name support in Home Assistant MQTT autodiscovery (needed for https://developers.home-assistant.io/blog/2022/07/10/entity_naming/). Done in #95159
2. Add title property in Base entity (https://github.com/Koenkk/zigbee-herdsman-converters/blob/261066095215898c006e7c9c390c677129fae630/lib/exposes.js#L8) and add method to define this, e.g. withTitle(title: str).
4. Set an approceate title for all presets (https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/lib/exposes.js) and their features.
5. Manually set an approceate title for all devices properties that exposed not from preset (e.g. https://github.com/Koenkk/zigbee-herdsman-converters/blob/261066095215898c006e7c9c390c677129fae630/devices/xiaomi.js#L2085-L2103).
6. Add support in zigbee2mqtt frontend and config.
7. Make a new "entity name standart" in zigbee2mqtt and make changes in the docs.

Probably overkill to change one letter case.

@Drafteed Drafteed deleted the ha-capitalize-entity-name branch February 21, 2023 18:13
Koenkk added a commit that referenced this pull request Feb 22, 2023
@Koenkk
Copy link
Owner

Koenkk commented Feb 22, 2023

@Drafteed done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants