Add icon translations to Fritz (#111547)

* Add icon translations to Fritz

* Add icon translations to Fritz
pull/111577/head
Joost Lekkerkerker 2024-02-27 00:17:15 +01:00 committed by GitHub
parent 951743551a
commit 9e2db708b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 59 additions and 30 deletions

View File

@ -59,7 +59,6 @@ BUTTONS: Final = [
FritzButtonDescription(
key="cleanup",
translation_key="cleanup",
icon="mdi:broom",
entity_category=EntityCategory.CONFIG,
press_action=lambda avm_wrapper: avm_wrapper.async_trigger_cleanup(),
),

View File

@ -0,0 +1,59 @@
{
"entity": {
"button": {
"cleanup": {
"default": "mdi:broom"
}
},
"sensor": {
"external_ip": {
"default": "mdi:earth"
},
"external_ipv6": {
"default": "mdi:earth"
},
"kb_s_sent": {
"default": "mdi:upload"
},
"kb_s_received": {
"default": "mdi:download"
},
"max_kb_s_sent": {
"default": "mdi:upload"
},
"max_kb_s_received": {
"default": "mdi:download"
},
"gb_sent": {
"default": "mdi:upload"
},
"gb_received": {
"default": "mdi:download"
},
"link_kb_s_sent": {
"default": "mdi:upload"
},
"link_kb_s_received": {
"default": "mdi:download"
},
"link_noise_margin_sent": {
"default": "mdi:upload"
},
"link_noise_margin_received": {
"default": "mdi:download"
},
"link_attenuation_sent": {
"default": "mdi:upload"
},
"link_attenuation_received": {
"default": "mdi:download"
}
}
},
"services": {
"reconnect": "mdi:connection",
"reboot": "mdi:refresh",
"cleanup": "mdi:broom",
"set_guest_wifi_password": "mdi:form-textbox-password"
}
}

View File

@ -153,13 +153,11 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
FritzSensorEntityDescription(
key="external_ip",
translation_key="external_ip",
icon="mdi:earth",
value_fn=_retrieve_external_ip_state,
),
FritzSensorEntityDescription(
key="external_ipv6",
translation_key="external_ipv6",
icon="mdi:earth",
value_fn=_retrieve_external_ipv6_state,
is_suitable=lambda info: info.ipv6_active,
),
@ -184,7 +182,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfDataRate.KILOBYTES_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
icon="mdi:upload",
value_fn=_retrieve_kb_s_sent_state,
),
FritzSensorEntityDescription(
@ -193,7 +190,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfDataRate.KILOBYTES_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
icon="mdi:download",
value_fn=_retrieve_kb_s_received_state,
),
FritzSensorEntityDescription(
@ -201,7 +197,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
translation_key="max_kb_s_sent",
native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
icon="mdi:upload",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=_retrieve_max_kb_s_sent_state,
),
@ -210,7 +205,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
translation_key="max_kb_s_received",
native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
icon="mdi:download",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=_retrieve_max_kb_s_received_state,
),
@ -220,7 +214,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfInformation.GIGABYTES,
device_class=SensorDeviceClass.DATA_SIZE,
icon="mdi:upload",
value_fn=_retrieve_gb_sent_state,
),
FritzSensorEntityDescription(
@ -229,7 +222,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfInformation.GIGABYTES,
device_class=SensorDeviceClass.DATA_SIZE,
icon="mdi:download",
value_fn=_retrieve_gb_received_state,
),
FritzSensorEntityDescription(
@ -237,7 +229,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
translation_key="link_kb_s_sent",
native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
icon="mdi:upload",
value_fn=_retrieve_link_kb_s_sent_state,
),
FritzSensorEntityDescription(
@ -245,14 +236,12 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
translation_key="link_kb_s_received",
native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
icon="mdi:download",
value_fn=_retrieve_link_kb_s_received_state,
),
FritzSensorEntityDescription(
key="link_noise_margin_sent",
translation_key="link_noise_margin_sent",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
icon="mdi:upload",
value_fn=_retrieve_link_noise_margin_sent_state,
is_suitable=lambda info: info.wan_enabled and info.connection == DSL_CONNECTION,
),
@ -260,7 +249,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
key="link_noise_margin_received",
translation_key="link_noise_margin_received",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
icon="mdi:download",
value_fn=_retrieve_link_noise_margin_received_state,
is_suitable=lambda info: info.wan_enabled and info.connection == DSL_CONNECTION,
),
@ -268,7 +256,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
key="link_attenuation_sent",
translation_key="link_attenuation_sent",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
icon="mdi:upload",
value_fn=_retrieve_link_attenuation_sent_state,
is_suitable=lambda info: info.wan_enabled and info.connection == DSL_CONNECTION,
),
@ -276,7 +263,6 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
key="link_attenuation_received",
translation_key="link_attenuation_received",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
icon="mdi:download",
value_fn=_retrieve_link_attenuation_received_state,
is_suitable=lambda info: info.wan_enabled and info.connection == DSL_CONNECTION,
),

View File

@ -17,7 +17,6 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_ICON,
ATTR_STATE,
ATTR_UNIT_OF_MEASUREMENT,
STATE_UNAVAILABLE,
@ -32,11 +31,9 @@ from tests.common import MockConfigEntry, async_fire_time_changed
SENSOR_STATES: dict[str, dict[str, Any]] = {
"sensor.mock_title_external_ip": {
ATTR_STATE: "1.2.3.4",
ATTR_ICON: "mdi:earth",
},
"sensor.mock_title_external_ipv6": {
ATTR_STATE: "fec0::1",
ATTR_ICON: "mdi:earth",
},
"sensor.mock_title_last_restart": {
# ATTR_STATE: "2022-02-05T17:46:04+00:00",
@ -50,65 +47,53 @@ SENSOR_STATES: dict[str, dict[str, Any]] = {
ATTR_STATE: "3.4",
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
ATTR_UNIT_OF_MEASUREMENT: "kB/s",
ATTR_ICON: "mdi:upload",
},
"sensor.mock_title_download_throughput": {
ATTR_STATE: "67.6",
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
ATTR_UNIT_OF_MEASUREMENT: "kB/s",
ATTR_ICON: "mdi:download",
},
"sensor.mock_title_max_connection_upload_throughput": {
ATTR_STATE: "2105.0",
ATTR_UNIT_OF_MEASUREMENT: "kbit/s",
ATTR_ICON: "mdi:upload",
},
"sensor.mock_title_max_connection_download_throughput": {
ATTR_STATE: "10087.0",
ATTR_UNIT_OF_MEASUREMENT: "kbit/s",
ATTR_ICON: "mdi:download",
},
"sensor.mock_title_gb_sent": {
ATTR_STATE: "1.7",
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
ATTR_UNIT_OF_MEASUREMENT: "GB",
ATTR_ICON: "mdi:upload",
},
"sensor.mock_title_gb_received": {
ATTR_STATE: "5.2",
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
ATTR_UNIT_OF_MEASUREMENT: "GB",
ATTR_ICON: "mdi:download",
},
"sensor.mock_title_link_upload_throughput": {
ATTR_STATE: "51805.0",
ATTR_UNIT_OF_MEASUREMENT: "kbit/s",
ATTR_ICON: "mdi:upload",
},
"sensor.mock_title_link_download_throughput": {
ATTR_STATE: "318557.0",
ATTR_UNIT_OF_MEASUREMENT: "kbit/s",
ATTR_ICON: "mdi:download",
},
"sensor.mock_title_link_upload_noise_margin": {
ATTR_STATE: "9.0",
ATTR_UNIT_OF_MEASUREMENT: "dB",
ATTR_ICON: "mdi:upload",
},
"sensor.mock_title_link_download_noise_margin": {
ATTR_STATE: "8.0",
ATTR_UNIT_OF_MEASUREMENT: "dB",
ATTR_ICON: "mdi:download",
},
"sensor.mock_title_link_upload_power_attenuation": {
ATTR_STATE: "7.0",
ATTR_UNIT_OF_MEASUREMENT: "dB",
ATTR_ICON: "mdi:upload",
},
"sensor.mock_title_link_download_power_attenuation": {
ATTR_STATE: "12.0",
ATTR_UNIT_OF_MEASUREMENT: "dB",
ATTR_ICON: "mdi:download",
},
}