Add icon translations to Vodafone Station (#112349)

This commit is contained in:
Joost Lekkerkerker 2024-03-05 18:27:31 +01:00 committed by GitHub
parent 4a7eab92bb
commit e076b6aacf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 46 additions and 15 deletions

View File

@ -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."""

View File

@ -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"
}
}
}
}

View File

@ -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,
),
)