Add icon translations to YoLink (#112364)

This commit is contained in:
Joost Lekkerkerker 2024-03-05 14:00:31 +01:00 committed by GitHub
parent afdb7d15ca
commit f81b1819b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 35 additions and 10 deletions

View File

@ -49,7 +49,6 @@ SENSOR_DEVICE_TYPE = [
SENSOR_TYPES: tuple[YoLinkBinarySensorEntityDescription, ...] = (
YoLinkBinarySensorEntityDescription(
key="door_state",
icon="mdi:door",
device_class=BinarySensorDeviceClass.DOOR,
value=lambda value: value == "open" if value is not None else None,
exists_fn=lambda device: device.device_type == ATTR_DEVICE_DOOR_SENSOR,

View File

@ -0,0 +1,31 @@
{
"entity": {
"number": {
"config_volume": {
"default": "mdi:volume-high"
}
},
"sensor": {
"power_failure_alarm": {
"default": "mdi:flash"
},
"power_failure_alarm_mute": {
"default": "mdi:volume-mute"
},
"power_failure_alarm_volume": {
"default": "mdi:volume-high"
},
"power_failure_alarm_beep": {
"default": "mdi:bullhorn"
}
},
"switch": {
"manipulator_state": {
"default": "mdi:pipe"
}
}
},
"services": {
"play_on_speaker_hub": "mdi:speaker"
}
}

View File

@ -23,7 +23,7 @@ from .const import DOMAIN
from .coordinator import YoLinkCoordinator
from .entity import YoLinkEntity
OPTIONS_VALUME = "options_volume"
OPTIONS_VOLUME = "options_volume"
@dataclass(frozen=True, kw_only=True)
@ -49,14 +49,13 @@ def get_volume_value(state: dict[str, Any]) -> int | None:
DEVICE_CONFIG_DESCRIPTIONS: tuple[YoLinkNumberTypeConfigEntityDescription, ...] = (
YoLinkNumberTypeConfigEntityDescription(
key=OPTIONS_VALUME,
key=OPTIONS_VOLUME,
translation_key="config_volume",
native_min_value=1,
native_max_value=16,
mode=NumberMode.SLIDER,
native_step=1.0,
native_unit_of_measurement=None,
icon="mdi:volume-high",
exists_fn=lambda device: device.device_type in SUPPORT_SET_VOLUME_DEVICES,
should_update_entity=lambda value: value is not None,
value=get_volume_value,
@ -124,7 +123,7 @@ class YoLinkNumberTypeConfigEntity(YoLinkEntity, NumberEntity):
"""Update the current value."""
if (
self.coordinator.device.device_type == ATTR_DEVICE_SPEAKER_HUB
and self.entity_description.key == OPTIONS_VALUME
and self.entity_description.key == OPTIONS_VOLUME
):
await self.update_speaker_hub_volume(value)
self._attr_native_value = value

View File

@ -168,7 +168,6 @@ SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
key="state",
translation_key="power_failure_alarm",
device_class=SensorDeviceClass.ENUM,
icon="mdi:flash",
options=["normal", "alert", "off"],
exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM,
),
@ -176,7 +175,6 @@ SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
key="mute",
translation_key="power_failure_alarm_mute",
device_class=SensorDeviceClass.ENUM,
icon="mdi:volume-mute",
options=["muted", "unmuted"],
exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM,
value=lambda value: "muted" if value is True else "unmuted",
@ -185,7 +183,6 @@ SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
key="sound",
translation_key="power_failure_alarm_volume",
device_class=SensorDeviceClass.ENUM,
icon="mdi:volume-high",
options=["low", "medium", "high"],
exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM,
value=cvt_volume,
@ -194,7 +191,6 @@ SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = (
key="beep",
translation_key="power_failure_alarm_beep",
device_class=SensorDeviceClass.ENUM,
icon="mdi:bullhorn",
options=["enabled", "disabled"],
exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM,
value=lambda value: "enabled" if value is True else "disabled",

View File

@ -46,8 +46,8 @@ DEVICE_TYPES: tuple[YoLinkSwitchEntityDescription, ...] = (
),
YoLinkSwitchEntityDescription(
key="manipulator_state",
translation_key="manipulator_state",
name=None,
icon="mdi:pipe",
exists_fn=lambda device: device.device_type == ATTR_DEVICE_MANIPULATOR,
),
YoLinkSwitchEntityDescription(