mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Allow setting an entity's name by its device class (#90767)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
@@ -125,7 +125,8 @@ class EntityPlatform:
|
||||
self.entity_namespace = entity_namespace
|
||||
self.config_entry: config_entries.ConfigEntry | None = None
|
||||
self.entities: dict[str, Entity] = {}
|
||||
self.entity_translations: dict[str, Any] = {}
|
||||
self.component_translations: dict[str, Any] = {}
|
||||
self.platform_translations: dict[str, Any] = {}
|
||||
self._tasks: list[asyncio.Task[None]] = []
|
||||
# Stop tracking tasks after setup is completed
|
||||
self._setup_complete = False
|
||||
@@ -279,7 +280,15 @@ class EntityPlatform:
|
||||
full_name = f"{self.domain}.{self.platform_name}"
|
||||
|
||||
try:
|
||||
self.entity_translations = await translation.async_get_translations(
|
||||
self.component_translations = await translation.async_get_translations(
|
||||
hass, hass.config.language, "entity_component", {self.domain}
|
||||
)
|
||||
except Exception as err: # pylint: disable=broad-exception-caught
|
||||
_LOGGER.debug(
|
||||
"Could not load translations for %s", self.domain, exc_info=err
|
||||
)
|
||||
try:
|
||||
self.platform_translations = await translation.async_get_translations(
|
||||
hass, hass.config.language, "entity", {self.platform_name}
|
||||
)
|
||||
except Exception as err: # pylint: disable=broad-exception-caught
|
||||
|
||||
Reference in New Issue
Block a user