From e076b6aacfa0ac00366bec7f322a3922b067d24b Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 5 Mar 2024 18:27:31 +0100 Subject: [PATCH] Add icon translations to Vodafone Station (#112349) --- .../vodafone_station/device_tracker.py | 7 +-- .../components/vodafone_station/icons.json | 44 +++++++++++++++++++ .../components/vodafone_station/sensor.py | 10 ----- 3 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 homeassistant/components/vodafone_station/icons.json diff --git a/homeassistant/components/vodafone_station/device_tracker.py b/homeassistant/components/vodafone_station/device_tracker.py index 9f98da88d22..ebe985cb744 100644 --- a/homeassistant/components/vodafone_station/device_tracker.py +++ b/homeassistant/components/vodafone_station/device_tracker.py @@ -61,6 +61,8 @@ def async_add_new_tracked_entities( class VodafoneStationTracker(CoordinatorEntity[VodafoneStationRouter], ScannerEntity): """Representation of a Vodafone Station device.""" + _attr_translation_key = "device_tracker" + def __init__( self, coordinator: VodafoneStationRouter, device_info: VodafoneStationDeviceInfo ) -> None: @@ -98,11 +100,6 @@ class VodafoneStationTracker(CoordinatorEntity[VodafoneStationRouter], ScannerEn """Return the hostname of device.""" return self._attr_name - @property - def icon(self) -> str: - """Return device icon.""" - return "mdi:lan-connect" if self._device.connected else "mdi:lan-disconnect" - @property def ip_address(self) -> str | None: """Return the primary ip address of the device.""" diff --git a/homeassistant/components/vodafone_station/icons.json b/homeassistant/components/vodafone_station/icons.json new file mode 100644 index 00000000000..b504fc5cc5f --- /dev/null +++ b/homeassistant/components/vodafone_station/icons.json @@ -0,0 +1,44 @@ +{ + "entity": { + "device_tracker": { + "device_tracker": { + "default": "mdi:lan-disconnect", + "state": { + "home": "mdi:lan-connect" + } + } + }, + "sensor": { + "external_ipv4": { + "default": "mdi:earth" + }, + "external_ipv6": { + "default": "mdi:earth" + }, + "external_ip_key": { + "default": "mdi:earth" + }, + "active_connection": { + "default": "mdi:wan" + }, + "fw_version": { + "default": "mdi:new-box" + }, + "phone_num1": { + "default": "mdi:phone" + }, + "phone_num2": { + "default": "mdi:phone" + }, + "sys_cpu_usage": { + "default": "mdi:chip" + }, + "sys_memory_usage": { + "default": "mdi:memory" + }, + "sys_reboot_cause": { + "default": "mdi:restart-alert" + } + } + } +} diff --git a/homeassistant/components/vodafone_station/sensor.py b/homeassistant/components/vodafone_station/sensor.py index b383c2d193a..c5fff05a164 100644 --- a/homeassistant/components/vodafone_station/sensor.py +++ b/homeassistant/components/vodafone_station/sensor.py @@ -72,26 +72,22 @@ SENSOR_TYPES: Final = ( VodafoneStationEntityDescription( key="wan_ip4_addr", translation_key="external_ipv4", - icon="mdi:earth", is_suitable=lambda info: info["wan_ip4_addr"] not in NOT_AVAILABLE, ), VodafoneStationEntityDescription( key="wan_ip6_addr", translation_key="external_ipv6", - icon="mdi:earth", is_suitable=lambda info: info["wan_ip6_addr"] not in NOT_AVAILABLE, ), VodafoneStationEntityDescription( key="vf_internet_key_ip_addr", translation_key="external_ip_key", - icon="mdi:earth", is_suitable=lambda info: info["vf_internet_key_ip_addr"] not in NOT_AVAILABLE, ), VodafoneStationEntityDescription( key="inter_ip_address", translation_key="active_connection", device_class=SensorDeviceClass.ENUM, - icon="mdi:wan", options=LINE_TYPES, value=_line_connection, ), @@ -112,19 +108,16 @@ SENSOR_TYPES: Final = ( VodafoneStationEntityDescription( key="fw_version", translation_key="fw_version", - icon="mdi:new-box", entity_category=EntityCategory.DIAGNOSTIC, ), VodafoneStationEntityDescription( key="phone_num1", translation_key="phone_num1", - icon="mdi:phone", is_suitable=lambda info: info["phone_unavailable1"] == "0", ), VodafoneStationEntityDescription( key="phone_num2", translation_key="phone_num2", - icon="mdi:phone", is_suitable=lambda info: info["phone_unavailable2"] == "0", ), VodafoneStationEntityDescription( @@ -137,7 +130,6 @@ SENSOR_TYPES: Final = ( VodafoneStationEntityDescription( key="sys_cpu_usage", translation_key="sys_cpu_usage", - icon="mdi:chip", native_unit_of_measurement=PERCENTAGE, entity_category=EntityCategory.DIAGNOSTIC, value=lambda coordinator, key: float(coordinator.data.sensors[key][:-1]), @@ -145,7 +137,6 @@ SENSOR_TYPES: Final = ( VodafoneStationEntityDescription( key="sys_memory_usage", translation_key="sys_memory_usage", - icon="mdi:memory", native_unit_of_measurement=PERCENTAGE, entity_category=EntityCategory.DIAGNOSTIC, value=lambda coordinator, key: float(coordinator.data.sensors[key][:-1]), @@ -153,7 +144,6 @@ SENSOR_TYPES: Final = ( VodafoneStationEntityDescription( key="sys_reboot_cause", translation_key="sys_reboot_cause", - icon="mdi:restart-alert", entity_category=EntityCategory.DIAGNOSTIC, ), )