Internally states have SAME values for all languages. Only a presentation on UI have translations.
(of course if some particular sensor/input_select/input_text has internally German words - they are always German).
Just switched UI to Hebrew - the displayed state is translated as expected:
I think you misunderstood what i mean. You’re showing the friendly name of entities to change according to the language set, but this topic is about the internal names that those identities have.
No, friendly names are constant & do not depend on a language. *
What I demonstrated is that states can be language-dependent.
*OK, if an entity is provided by some integration which gives them friendly names (like “Mileage” instead of expected “Kilometerstand” or whatever)…
But here is my test:
some integration provides these entities:
My language settings are “English” (both for “server” & “frontend”).
After changing them to “Russian” I see this:
and this is a content of “entity_registry”:
{"aliases":[],"area_id":null,"categories":{},
"capabilities":{"state_class":"total_increasing"},"config_entry_id":"1a7a8ac47c5b7b9eff5b79f5245bcee7","created_at":"1970-01-01T00:00:00+00:00","device_class":null,"device_id":"a2c352e8504ac221c4fc7345c9044e88","disabled_by":null,"entity_category":null,"entity_id":"sensor.auto_xxx_mileage","hidden_by":null,"icon":null,"id":"dd0cf60326b4adec1d71fcef2573178e","has_entity_name":true,"labels":[],"modified_at":"2024-12-22T19:54:50.505101+00:00","name":null,"options":
{"conversation":{"should_expose":false}},
"original_device_class":"distance","original_icon":null,
"original_name":"Пробег","platform":"starline",
"supported_features":0,
"translation_key":"mileage",
"unique_id":"starline-mileage-862311060232889",
"previous_unique_id":null,"unit_of_measurement":"km"},
where “translation_key = mileage” & a Russian name is taken for this key.
i see, thank you.
is there any way to make use of the fact, that those entity names are translated only? how do i access one using its “original_name” or “translated_key” and is that even possible?
otherwise i may have to extract info from the entity_registry and use hass cli to rename the entities.
There is a way but with some limitations.
Assume my language for server & frontend is “English”, these entities have English names:
In a particular card I may use Russian names:
But ofc in more-info the name is still English:
(my family is multilingual so I do not care)
If i understand correctly, i should be able to use these custom dashboards with their english entities without changing anything, but this is not the case.
Many entities are not shown, helpers and template sensors are unavailable, because the entities cannot be found.
Do you mean that on a setup with changed language some old entities cannot be found? And what is “cannot be found”, are they present in Settings → Entities table?
this is a screenshot of a part of this dashboard, trying to show the entity sensor.power_meter_active_power.
The actual name of the entity is sensor.power_meter_wirkleistung, as it has been setup while havin german set as the language.
Changing the english naming to the german one in the dashboard yaml makes it work.
The entities details from the registry are pasted below.
{
"aliases": [],
"area_id": null,
"categories": {},
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "0xxx",
"created_at": "2024-12-05T16:58:02.067236+00:00",
"device_class": null,
"device_id": "1xx",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.power_meter_wirkleistung",
"hidden_by": null,
"icon": null,
"id": "xxxxx",
"has_entity_name": true,
"labels": [],
"modified_at": "2024-12-05T16:58:02.067456+00:00",
"name": null,
"options": {
"conversation": {
"should_expose": false
}
},
"original_device_class": "power",
"original_icon": "mdi:flash",
"original_name": "Wirkleistung",
"platform": "huawei_solar",
"supported_features": 0,
"translation_key": "power_meter_active_power",
"unique_id": "HV2320640477_power_meter_active_power",
"previous_unique_id": null,
"unit_of_measurement": "W"
}
This is not a name, this is entity_id.
If this entity has a unique_id - then you can change entity_id in more-info as you wish.
apologies for the confusion. entity_ids. yes. they were translated.
yes, i know that i can change them that way, but as i stated earlier
the question is, how do i do it programmatically for the more than a hundred entities that the integration provides?
Entity_id is not changed if you change a language, only a friendly_name may change (if a particular integration supports different languages).
Means - your dashboard’s code should not be changed, cards may address same entity_ids.
In my setup I may change a language several times, all dashboards still show same cards / same graphs (only displayed names may change - if I do not use a “name” option to override names).
if i don’t change my dashboard to use german entity_ids, they won’t work, as i’ve shown above.
Changing the language will not change entity_ids, only friendly names. But upon creation, those entities will be made in the chosen language. so now that i have them in the wrong language, how do i change them back?
So here i remain, still without a solution
A brute-force way w/o digging to the real issue is “replace one entity_id with another one”.
Open your dashboard in “raw yaml editor” & make this replace.
Yes, i know that that is the brute force option. it’s also quite tedious. They’re some rather complex dashboards (and multiple packages)
Hence me asking for a smarter way.
Let’s dig in to find the real issue, as you say. what can i provide you with?
Assume you have some ABC integration installed.
It provides entities for physical parameters “speed” & “time”.
If a user has “English”, then the integration creates entity_ids like “sensor.speed”, “sensor.time”.
Since I never used a different language, for me it is hard to imagine that in case of “German” the integration creates entity_ids like “sensor.geschwindigkeit” & “sensor.zeit” (sorry, this is how Google Translate tells me).
In case of “Russian” these sensors will be definitely same “sensor.speed”, “sensor.time” (some Russians told me).
But anyway, let’s imagine that I once selected “English” & then got those “sensor.speed” & “sensor.time”. And made a dashboard for these entities.
Then I switched to “German”. As I demonstrated you earlier - these entities are still “sensor.speed” & “sensor.time”, they have not got new entity_ids. So there is nothing to change in a dashboard.
If due to unknown for me reasons these entities got new entity_ids “sensor.geschwindigkeit” & “sensor.zeit” - then rename them back to “English” in more-info. Since you merely changed entity_ids - then the history SHOULD BE retained (in fact it is not currently).
Ok, i get what you’re saying.
Although it may be hard for you to imagine, it absolutely is the case here. I don’t know if it’s buggy behaviour though. maybe in your test, the integration you’re testing is missing a russian translation or home assistant doesn’t do it because of the cyrillic?
This means that i have those german entity ids now, together with the historical data.
I could reinstall the integration (set to english), but then i’d lose historical data or i’d have to migrate the data to the english id entities, which would be an endeavour of similar tediuosness as renaming them all would be. it’s 98 entities.
No idea, the integration made by a Russian person.
I added some corrections to my post above.
I would say that setting entity_ids dependently on a current language is a stupid idea… Blaming the integration ofc.
I agree on the stupid part, but i don’t think it’s the integrations choice.
Reading your edit above it seems like we’re back to the brute force renaming of all those entities to their original english ids?
Or edit ids in more-info.
I would choose this way.
In my unicorn universe all ids should be language-independent…