Add icon translations to Idasen desk (#111813)

pull/111954/head
Joost Lekkerkerker 2024-03-01 12:42:26 +01:00 committed by GitHub
parent 677e12b033
commit 689651ee2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 16 deletions

View File

@ -4,11 +4,7 @@ from dataclasses import dataclass
import logging
from typing import Any, Final
from homeassistant.components.button import (
ButtonDeviceClass,
ButtonEntity,
ButtonEntityDescription,
)
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
@ -40,17 +36,13 @@ class IdasenDeskButtonDescription(
BUTTONS: Final = [
IdasenDeskButtonDescription(
key="connect",
name="Connect",
icon="mdi:bluetooth-connect",
device_class=ButtonDeviceClass.RESTART,
translation_key="connect",
entity_category=EntityCategory.CONFIG,
press_action=lambda coordinator: coordinator.async_connect,
),
IdasenDeskButtonDescription(
key="disconnect",
name="Disconnect",
icon="mdi:bluetooth-off",
device_class=ButtonDeviceClass.RESTART,
translation_key="disconnect",
entity_category=EntityCategory.CONFIG,
press_action=lambda coordinator: coordinator.async_disconnect,
),
@ -86,7 +78,7 @@ class IdasenDeskButton(ButtonEntity):
"""Initialize the IdasenDesk button entity."""
self.entity_description = description
self._attr_unique_id = f"{self.entity_description.key}-{address}"
self._attr_unique_id = f"{description.key}-{address}"
self._attr_device_info = device_info
self._address = address
self._coordinator = coordinator

View File

@ -12,7 +12,6 @@ from homeassistant.components.cover import (
CoverEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_NAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.device_registry import DeviceInfo
@ -39,13 +38,15 @@ class IdasenDeskCover(CoordinatorEntity[IdasenDeskCoordinator], CoverEntity):
"""Representation of Idasen Desk device."""
_attr_device_class = CoverDeviceClass.DAMPER
_attr_icon = "mdi:desk"
_attr_supported_features = (
CoverEntityFeature.OPEN
| CoverEntityFeature.CLOSE
| CoverEntityFeature.STOP
| CoverEntityFeature.SET_POSITION
)
_attr_has_entity_name = True
_attr_name = None
_attr_translation_key = "desk"
def __init__(
self,
@ -56,7 +57,6 @@ class IdasenDeskCover(CoordinatorEntity[IdasenDeskCoordinator], CoverEntity):
"""Initialize an Idasen Desk cover."""
super().__init__(coordinator)
self._desk = coordinator.desk
self._attr_name = device_info[ATTR_NAME]
self._attr_unique_id = address
self._attr_device_info = device_info

View File

@ -0,0 +1,22 @@
{
"entity": {
"button": {
"connect": {
"default": "mdi:bluetooth-connect"
},
"disconnect": {
"default": "mdi:bluetooth-off"
}
},
"cover": {
"desk": {
"default": "mdi:desk"
}
},
"sensor": {
"height": {
"default": "mdi:arrow-up-down"
}
}
}
}

View File

@ -41,7 +41,6 @@ SENSORS = (
IdasenDeskSensorDescription(
key="height",
translation_key="height",
icon="mdi:arrow-up-down",
native_unit_of_measurement=UnitOfLength.METERS,
device_class=SensorDeviceClass.DISTANCE,
state_class=SensorStateClass.MEASUREMENT,

View File

@ -21,6 +21,14 @@
}
},
"entity": {
"button": {
"connect": {
"name": "Connect"
},
"disconnect": {
"name": "Disconnect"
}
},
"sensor": {
"height": {
"name": "Height"