mirror of
https://github.com/home-assistant/core.git
synced 2026-04-17 23:53:49 +01:00
Use translation key and icons.json for Synology DSM button entities (#166862)
This commit is contained in:
@@ -34,15 +34,13 @@ class SynologyDSMbuttonDescription(ButtonEntityDescription):
|
|||||||
BUTTONS: Final = [
|
BUTTONS: Final = [
|
||||||
SynologyDSMbuttonDescription(
|
SynologyDSMbuttonDescription(
|
||||||
key="reboot",
|
key="reboot",
|
||||||
name="Reboot",
|
|
||||||
device_class=ButtonDeviceClass.RESTART,
|
device_class=ButtonDeviceClass.RESTART,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
press_action=lambda syno_api: syno_api.async_reboot,
|
press_action=lambda syno_api: syno_api.async_reboot,
|
||||||
),
|
),
|
||||||
SynologyDSMbuttonDescription(
|
SynologyDSMbuttonDescription(
|
||||||
key="shutdown",
|
key="shutdown",
|
||||||
name="Shutdown",
|
translation_key="shutdown",
|
||||||
icon="mdi:power",
|
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
press_action=lambda syno_api: syno_api.async_shutdown,
|
press_action=lambda syno_api: syno_api.async_shutdown,
|
||||||
),
|
),
|
||||||
@@ -63,6 +61,7 @@ class SynologyDSMButton(ButtonEntity):
|
|||||||
"""Defines a Synology DSM button."""
|
"""Defines a Synology DSM button."""
|
||||||
|
|
||||||
entity_description: SynologyDSMbuttonDescription
|
entity_description: SynologyDSMbuttonDescription
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -75,7 +74,6 @@ class SynologyDSMButton(ButtonEntity):
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
assert api.network is not None
|
assert api.network is not None
|
||||||
assert api.information is not None
|
assert api.information is not None
|
||||||
self._attr_name = f"{api.network.hostname} {description.name}"
|
|
||||||
self._attr_unique_id = f"{api.information.serial}_{description.key}"
|
self._attr_unique_id = f"{api.information.serial}_{description.key}"
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, api.information.serial)}
|
identifiers={(DOMAIN, api.information.serial)}
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
{
|
{
|
||||||
"entity": {
|
"entity": {
|
||||||
|
"button": {
|
||||||
|
"shutdown": {
|
||||||
|
"default": "mdi:power"
|
||||||
|
}
|
||||||
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
"cpu_15min_load": {
|
"cpu_15min_load": {
|
||||||
"default": "mdi:chip"
|
"default": "mdi:chip"
|
||||||
|
|||||||
@@ -76,6 +76,11 @@
|
|||||||
"name": "Security status"
|
"name": "Security status"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"button": {
|
||||||
|
"shutdown": {
|
||||||
|
"name": "Shutdown"
|
||||||
|
}
|
||||||
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
"cpu_15min_load": {
|
"cpu_15min_load": {
|
||||||
"name": "CPU load average (15 min)"
|
"name": "CPU load average (15 min)"
|
||||||
|
|||||||
Reference in New Issue
Block a user