Use shorthand attributes in automation for name (#115246)

This commit is contained in:
J. Nick Koston 2024-04-09 07:04:12 -10:00 committed by GitHub
parent f8aec03c03
commit 59d92f16bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -420,15 +420,10 @@ class UnavailableAutomationEntity(BaseAutomationEntity):
raw_config: ConfigType | None,
) -> None:
"""Initialize an automation entity."""
self._name = name
self._attr_name = name
self._attr_unique_id = automation_id
self.raw_config = raw_config
@property
def name(self) -> str:
"""Return the name of the entity."""
return self._name
@cached_property
def referenced_labels(self) -> set[str]:
"""Return a set of referenced labels."""
@ -488,7 +483,7 @@ class AutomationEntity(BaseAutomationEntity, RestoreEntity):
trace_config: ConfigType,
) -> None:
"""Initialize an automation entity."""
self._name = name
self._attr_name = name
self._trigger_config = trigger_config
self._async_detach_triggers: CALLBACK_TYPE | None = None
self._cond_func = cond_func
@ -504,11 +499,6 @@ class AutomationEntity(BaseAutomationEntity, RestoreEntity):
self._trace_config = trace_config
self._attr_unique_id = automation_id
@property
def name(self) -> str:
"""Return the name of the entity."""
return self._name
@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return the entity state attributes."""
@ -732,7 +722,7 @@ class AutomationEntity(BaseAutomationEntity, RestoreEntity):
translation_placeholders={
"service": f"{err.domain}.{err.service}",
"entity_id": self.entity_id,
"name": self.name or self.entity_id,
"name": self._attr_name or self.entity_id,
"edit": f"/config/automation/edit/{self.unique_id}",
},
)