easee_hass icon indicating copy to clipboard operation
easee_hass copied to clipboard

Localisation also applies to sensor names

Open ppuschmann opened this issue 10 months ago • 8 comments

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 https://github.com/nordicopen/easee_hass/blob/5608be4c5ab234de67399752778722bb66ea5cbf/custom_components/easee/translations/de.json#L140-L145

Version of Easee integration having the issue?

easee-v0.9.58

Version of Home Assistant Core having the issue?

core-2024.3.3

ppuschmann avatar Apr 06 '24 07:04 ppuschmann

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.

astrandb avatar Apr 06 '24 08:04 astrandb

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 avatar Apr 06 '24 13:04 ppuschmann

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.

ppuschmann avatar Apr 12 '24 07:04 ppuschmann

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.

astrandb avatar Apr 12 '24 08:04 astrandb

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.

ppuschmann avatar Apr 12 '24 12:04 ppuschmann

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 avatar Apr 12 '24 13:04 astrandb

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. :-)

ppuschmann avatar Apr 13 '24 06:04 ppuschmann

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

astrandb avatar Apr 13 '24 07:04 astrandb