From f81b1819b0a21d31109c5100435757eb16d77c28 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 5 Mar 2024 14:00:31 +0100 Subject: [PATCH] Add icon translations to YoLink (#112364) --- .../components/yolink/binary_sensor.py | 1 - homeassistant/components/yolink/icons.json | 31 +++++++++++++++++++ homeassistant/components/yolink/number.py | 7 ++--- homeassistant/components/yolink/sensor.py | 4 --- homeassistant/components/yolink/switch.py | 2 +- 5 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 homeassistant/components/yolink/icons.json diff --git a/homeassistant/components/yolink/binary_sensor.py b/homeassistant/components/yolink/binary_sensor.py index 0762a3b5c60..51c66be3e5f 100644 --- a/homeassistant/components/yolink/binary_sensor.py +++ b/homeassistant/components/yolink/binary_sensor.py @@ -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, diff --git a/homeassistant/components/yolink/icons.json b/homeassistant/components/yolink/icons.json new file mode 100644 index 00000000000..ee9037c864a --- /dev/null +++ b/homeassistant/components/yolink/icons.json @@ -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" + } +} diff --git a/homeassistant/components/yolink/number.py b/homeassistant/components/yolink/number.py index a7ba89e1f6c..d1a52e6e46b 100644 --- a/homeassistant/components/yolink/number.py +++ b/homeassistant/components/yolink/number.py @@ -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 diff --git a/homeassistant/components/yolink/sensor.py b/homeassistant/components/yolink/sensor.py index 4401ac1aab5..80cbaf27bb3 100644 --- a/homeassistant/components/yolink/sensor.py +++ b/homeassistant/components/yolink/sensor.py @@ -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", diff --git a/homeassistant/components/yolink/switch.py b/homeassistant/components/yolink/switch.py index 69a958ba6d1..920ebd245cf 100644 --- a/homeassistant/components/yolink/switch.py +++ b/homeassistant/components/yolink/switch.py @@ -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(