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

Localisation also applies to sensor names #406

Open
ppuschmann opened this issue Apr 6, 2024 · 8 comments
Open

Localisation also applies to sensor names #406

ppuschmann opened this issue Apr 6, 2024 · 8 comments
Labels
wontfix This will not be worked on

Comments

@ppuschmann
Copy link

ppuschmann commented Apr 6, 2024

The problem

Hi there,

I was wondering why the charger-card did not show an values for my Easse charger when it was in action and found out that my sensors are also localised:

Example:

  • sensor.CHARGERNAME_dynamic_circuit_limit --> sensor.CHARGERNAME_dynamisches_stromkreislimit
  • sensor.CHARGERNAME_reason_for_no_current--> sensor.CHARGERNAME_grund_fur_keinen_strom

I see this as a problem, because we lose the sensor name as a common interface for integrations.

Additional information

Apparently the sensor names are generated of the "name" items:

"dynamic_circuit_limit": {
  "name": "Dynamisches Stromkreislimit"
},
"easee_reason_no_current": {
  "name": "Grund für keinen Strom",
  "state": {

see

"dynamic_circuit_limit": {
"name": "Dynamisches Stromkreislimit"
},
"easee_reason_no_current": {
"name": "Grund für keinen Strom",
"state": {

Version of Easee integration having the issue?

easee-v0.9.58

Version of Home Assistant Core having the issue?

core-2024.3.3

@ppuschmann ppuschmann added the bug Something isn't working label Apr 6, 2024
@astrandb
Copy link
Collaborator

astrandb commented Apr 6, 2024

This is how localization works in Home Assistant and not specific to this integration.
Entity names follow the system language (Settings->System->General). The internal sensor names are created with the selected system langage when the integration is installed. If you change system language later, the internal names are unchanged but the display names are changed.

Translation of states and attributes follow the language set in the personal profile.

@ppuschmann
Copy link
Author

Hi @astrandb , thank you very mch for the quick reply.

This is how localization works in Home Assistant and not specific to this integration.
Entity names follow the system language (Settings->System->General). The internal sensor names are created with the selected system langage when the integration is installed. If you change system language later, the internal names are unchanged but the display names are changed.

OMFG, I didn't knew this. 🤯

But why?
If this is really an official decision, I'd like to remove it.

I'll then try to reinstall the integration and see what happens.

@ppuschmann
Copy link
Author

So I changed the locale, reinstalled the integration and finally got english names, as expected.

This is how localization works in Home Assistant and not specific to this integration.
Entity names follow the system language (Settings->System->General). The internal sensor names are created with the selected system langage when the integration is installed. If you change system language later, the internal names are unchanged but the display names are changed.

Some more information on this ^

Apparently the core integration do not translate the resource / sensor ids, but only the description.

It'd be really great if we/you could adjust to this style, because I think that technical terms, like the resource ids should not get translated at all.

@astrandb
Copy link
Collaborator

Apparently the core integration do not translate the resource / sensor ids, but only the description.

Well, that is not correct IMO.

Just to be sure what you are referring to:
It is unclear to me what resource / sensor id is. The term in HA is entity_id - or?
Same with description. HA term is Friendly name.

If an integration (core or custom) supports entity translation the entity_id will be created in the HA system language that is in use when the integration is installed. If you change the system language later and restart HA the friendly name will be changed but the entity_id remains unchanged.

I just verified by installing the moon integration.

@ppuschmann
Copy link
Author

Hi,
yes, you're right, we should use the correct names.
I'm currently not involved in the development around HA.

I am "complaining" about the localised entity_ids, correct.
For friendly names: Sure, these should get localised / translated.

As pointed out in the initial post, the localisation for the entity_ids is (in my eyes) not great:

sensor.CHARGERNAME_dynamic_circuit_limit --> sensor.CHARGERNAME_dynamisches_stromkreislimit

sensor.CHARGERNAME_reason_for_no_current--> sensor.CHARGERNAME_grund_fur_keinen_strom

I wanted to use this card in HA: charger-card

And found out that I got only the status, but no numbers.
The reason was "our topic": status translates to status in German, but nearly all other entity-ids were differrent.

-> and this was the point to reach out

I have currently the idea to keep my locale in English, then delete and reinstall the integrations in question, and then afterwards switch the HA language back to German, but this is hardly a good solution.

I can also understand that the change of the localisation-handling is some amount of work for you and it might even be a breaking change, but I still ask you to change this localisation setting for the entity-ids.

@astrandb
Copy link
Collaborator

I fully understand your point, but we just use the translation model that HA supplies. We will not invent a new translation architecture for this integration. There are some 3500 users of this integration and it would be a breaking change everyone except for those running in english system language. It would also lead to some confusion among users if this integration behaves differently from all other integrations in HA.

AFAIK the charger-card allows custom mapping of display elements to entity_id:s so I think you can acheive a working setup that way.

@astrandb astrandb added wontfix This will not be worked on and removed bug Something isn't working labels Apr 12, 2024
@ppuschmann
Copy link
Author

Can you point me to the "the translation model that HA supplies"?
This would help me to understand things better.

Thank you for the discussion. :-)

@astrandb
Copy link
Collaborator

HA is a continously evolving open source project and there is no comprehensive documentation that covers all design considerations. The source code is the final answer how things are implemented - in most cases.

Some design questions are discussed and decided here : https://github.com/home-assistant/architecture/discussions
Instructions and examples for implemenation are found here: https://developers.home-assistant.io/docs/translations
There is also a chat topic, devs_translations, on the HA Discord server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants