Blow up if setting translation key on entities without entity name

This commit is contained in:
Erik 2025-06-16 20:00:39 +02:00
parent 2f6fcb5801
commit c85d29db7c

View File

@ -689,6 +689,10 @@ class Entity(
"""Return the name of the entity.""" """Return the name of the entity."""
if hasattr(self, "_attr_name"): if hasattr(self, "_attr_name"):
return self._attr_name return self._attr_name
if self._name_translation_key and not self.has_entity_name:
raise ValueError(
"Entity has a translation key but has_entity_name is False"
)
if ( if (
self.has_entity_name self.has_entity_name
and (name_translation_key := self._name_translation_key) and (name_translation_key := self._name_translation_key)