Add entity translations to QNAP QSW (#98915)

This commit is contained in:
Joost Lekkerkerker 2023-08-30 11:20:15 +02:00 committed by GitHub
parent a89a5f486d
commit 56b99d2bc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 29 deletions

View file

@ -39,7 +39,6 @@ BUTTON_TYPES: Final[tuple[QswButtonDescription, ...]] = (
device_class=ButtonDeviceClass.RESTART,
entity_category=EntityCategory.CONFIG,
key=QSW_REBOOT,
name="Reboot",
press_action=lambda qsw: qsw.reboot(),
),
)
@ -58,6 +57,8 @@ async def async_setup_entry(
class QswButton(QswDataEntity, ButtonEntity):
"""Define a QNAP QSW button."""
_attr_has_entity_name = True
entity_description: QswButtonDescription
def __init__(
@ -68,7 +69,6 @@ class QswButton(QswDataEntity, ButtonEntity):
) -> None:
"""Initialize."""
super().__init__(coordinator, entry)
self._attr_name = f"{self.product} {description.name}"
self._attr_unique_id = f"{entry.unique_id}_{description.key}"
self.entity_description = description