From 38ba966d74e4f781a52cdb93019a4a476d338d0a Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 28 Feb 2024 11:21:19 +0100 Subject: [PATCH] Add icon translations to Devolo home network (#111367) --- .../devolo_home_network/binary_sensor.py | 1 - .../components/devolo_home_network/button.py | 4 +-- .../components/devolo_home_network/icons.json | 36 +++++++++++++++++++ .../components/devolo_home_network/sensor.py | 3 -- .../components/devolo_home_network/switch.py | 2 -- .../snapshots/test_binary_sensor.ambr | 3 +- .../snapshots/test_button.ambr | 12 +++---- .../snapshots/test_sensor.ambr | 9 ++--- .../snapshots/test_switch.ambr | 6 ++-- 9 files changed, 48 insertions(+), 28 deletions(-) create mode 100644 homeassistant/components/devolo_home_network/icons.json diff --git a/homeassistant/components/devolo_home_network/binary_sensor.py b/homeassistant/components/devolo_home_network/binary_sensor.py index 35b79b57f1d..cf8358b69a3 100644 --- a/homeassistant/components/devolo_home_network/binary_sensor.py +++ b/homeassistant/components/devolo_home_network/binary_sensor.py @@ -52,7 +52,6 @@ SENSOR_TYPES: dict[str, DevoloBinarySensorEntityDescription] = { device_class=BinarySensorDeviceClass.PLUG, entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, - icon="mdi:router-network", value_func=_is_connected_to_router, ), } diff --git a/homeassistant/components/devolo_home_network/button.py b/homeassistant/components/devolo_home_network/button.py index 9b3dd75ef98..eba1ad05157 100644 --- a/homeassistant/components/devolo_home_network/button.py +++ b/homeassistant/components/devolo_home_network/button.py @@ -40,12 +40,11 @@ BUTTON_TYPES: dict[str, DevoloButtonEntityDescription] = { IDENTIFY: DevoloButtonEntityDescription( key=IDENTIFY, entity_category=EntityCategory.DIAGNOSTIC, - icon="mdi:led-on", + device_class=ButtonDeviceClass.IDENTIFY, press_func=lambda device: device.plcnet.async_identify_device_start(), # type: ignore[union-attr] ), PAIRING: DevoloButtonEntityDescription( key=PAIRING, - icon="mdi:plus-network-outline", press_func=lambda device: device.plcnet.async_pair_device(), # type: ignore[union-attr] ), RESTART: DevoloButtonEntityDescription( @@ -56,7 +55,6 @@ BUTTON_TYPES: dict[str, DevoloButtonEntityDescription] = { ), START_WPS: DevoloButtonEntityDescription( key=START_WPS, - icon="mdi:wifi-plus", press_func=lambda device: device.device.async_start_wps(), # type: ignore[union-attr] ), } diff --git a/homeassistant/components/devolo_home_network/icons.json b/homeassistant/components/devolo_home_network/icons.json new file mode 100644 index 00000000000..816d0e36d03 --- /dev/null +++ b/homeassistant/components/devolo_home_network/icons.json @@ -0,0 +1,36 @@ +{ + "entity": { + "binary_sensor": { + "connected_to_router": { + "default": "mdi:router-network" + } + }, + "button": { + "pairing": { + "default": "mdi:plus-network-outline" + }, + "start_wps": { + "default": "mdi:wifi-plus" + } + }, + "sensor": { + "connected_plc_devices": { + "default": "mdi:lan" + }, + "connected_wifi_clients": { + "default": "mdi:wifi" + }, + "neighboring_wifi_networks": { + "default": "mdi:wifi-marker" + } + }, + "switch": { + "switch_guest_wifi": { + "default": "mdi:wifi" + }, + "switch_leds": { + "default": "mdi:led-off" + } + } + } +} diff --git a/homeassistant/components/devolo_home_network/sensor.py b/homeassistant/components/devolo_home_network/sensor.py index 66395e3a465..750bb9ad13d 100644 --- a/homeassistant/components/devolo_home_network/sensor.py +++ b/homeassistant/components/devolo_home_network/sensor.py @@ -68,14 +68,12 @@ SENSOR_TYPES: dict[str, DevoloSensorEntityDescription[Any]] = { key=CONNECTED_PLC_DEVICES, entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, - icon="mdi:lan", value_func=lambda data: len( {device.mac_address_from for device in data.data_rates} ), ), CONNECTED_WIFI_CLIENTS: DevoloSensorEntityDescription[list[ConnectedStationInfo]]( key=CONNECTED_WIFI_CLIENTS, - icon="mdi:wifi", state_class=SensorStateClass.MEASUREMENT, value_func=len, ), @@ -83,7 +81,6 @@ SENSOR_TYPES: dict[str, DevoloSensorEntityDescription[Any]] = { key=NEIGHBORING_WIFI_NETWORKS, entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, - icon="mdi:wifi-marker", value_func=len, ), PLC_RX_RATE: DevoloSensorEntityDescription[DataRate]( diff --git a/homeassistant/components/devolo_home_network/switch.py b/homeassistant/components/devolo_home_network/switch.py index 99c23f77d35..af0569a016f 100644 --- a/homeassistant/components/devolo_home_network/switch.py +++ b/homeassistant/components/devolo_home_network/switch.py @@ -42,7 +42,6 @@ class DevoloSwitchEntityDescription( SWITCH_TYPES: dict[str, DevoloSwitchEntityDescription[Any]] = { SWITCH_GUEST_WIFI: DevoloSwitchEntityDescription[WifiGuestAccessGet]( key=SWITCH_GUEST_WIFI, - icon="mdi:wifi", is_on_func=lambda data: data.enabled is True, turn_on_func=lambda device: device.device.async_set_wifi_guest_access(True), # type: ignore[union-attr] turn_off_func=lambda device: device.device.async_set_wifi_guest_access(False), # type: ignore[union-attr] @@ -50,7 +49,6 @@ SWITCH_TYPES: dict[str, DevoloSwitchEntityDescription[Any]] = { SWITCH_LEDS: DevoloSwitchEntityDescription[bool]( key=SWITCH_LEDS, entity_category=EntityCategory.CONFIG, - icon="mdi:led-off", is_on_func=bool, turn_on_func=lambda device: device.device.async_set_led_setting(True), # type: ignore[union-attr] turn_off_func=lambda device: device.device.async_set_led_setting(False), # type: ignore[union-attr] diff --git a/tests/components/devolo_home_network/snapshots/test_binary_sensor.ambr b/tests/components/devolo_home_network/snapshots/test_binary_sensor.ambr index 517652c1d84..7545fff55f1 100644 --- a/tests/components/devolo_home_network/snapshots/test_binary_sensor.ambr +++ b/tests/components/devolo_home_network/snapshots/test_binary_sensor.ambr @@ -4,7 +4,6 @@ 'attributes': ReadOnlyDict({ 'device_class': 'plug', 'friendly_name': 'Mock Title Connected to router', - 'icon': 'mdi:router-network', }), 'context': , 'entity_id': 'binary_sensor.mock_title_connected_to_router', @@ -36,7 +35,7 @@ 'options': dict({ }), 'original_device_class': , - 'original_icon': 'mdi:router-network', + 'original_icon': None, 'original_name': 'Connected to router', 'platform': 'devolo_home_network', 'previous_unique_id': None, diff --git a/tests/components/devolo_home_network/snapshots/test_button.ambr b/tests/components/devolo_home_network/snapshots/test_button.ambr index da8b1455271..26be12805ce 100644 --- a/tests/components/devolo_home_network/snapshots/test_button.ambr +++ b/tests/components/devolo_home_network/snapshots/test_button.ambr @@ -45,8 +45,8 @@ # name: test_button[identify_device_with_a_blinking_led-plcnet-async_identify_device_start] StateSnapshot({ 'attributes': ReadOnlyDict({ + 'device_class': 'identify', 'friendly_name': 'Mock Title Identify device with a blinking LED', - 'icon': 'mdi:led-on', }), 'context': , 'entity_id': 'button.mock_title_identify_device_with_a_blinking_led', @@ -77,8 +77,8 @@ 'name': None, 'options': dict({ }), - 'original_device_class': None, - 'original_icon': 'mdi:led-on', + 'original_device_class': , + 'original_icon': None, 'original_name': 'Identify device with a blinking LED', 'platform': 'devolo_home_network', 'previous_unique_id': None, @@ -224,7 +224,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mock Title Start PLC pairing', - 'icon': 'mdi:plus-network-outline', }), 'context': , 'entity_id': 'button.mock_title_start_plc_pairing', @@ -256,7 +255,7 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:plus-network-outline', + 'original_icon': None, 'original_name': 'Start PLC pairing', 'platform': 'devolo_home_network', 'previous_unique_id': None, @@ -313,7 +312,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mock Title Start WPS', - 'icon': 'mdi:wifi-plus', }), 'context': , 'entity_id': 'button.mock_title_start_wps', @@ -345,7 +343,7 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:wifi-plus', + 'original_icon': None, 'original_name': 'Start WPS', 'platform': 'devolo_home_network', 'previous_unique_id': None, diff --git a/tests/components/devolo_home_network/snapshots/test_sensor.ambr b/tests/components/devolo_home_network/snapshots/test_sensor.ambr index 40c6179fc3c..f961104a14f 100644 --- a/tests/components/devolo_home_network/snapshots/test_sensor.ambr +++ b/tests/components/devolo_home_network/snapshots/test_sensor.ambr @@ -3,7 +3,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mock Title Connected PLC devices', - 'icon': 'mdi:lan', }), 'context': , 'entity_id': 'sensor.mock_title_connected_plc_devices', @@ -35,7 +34,7 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:lan', + 'original_icon': None, 'original_name': 'Connected PLC devices', 'platform': 'devolo_home_network', 'previous_unique_id': None, @@ -49,7 +48,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mock Title Connected Wifi clients', - 'icon': 'mdi:wifi', 'state_class': , }), 'context': , @@ -84,7 +82,7 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:wifi', + 'original_icon': None, 'original_name': 'Connected Wifi clients', 'platform': 'devolo_home_network', 'previous_unique_id': None, @@ -98,7 +96,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mock Title Neighboring Wifi networks', - 'icon': 'mdi:wifi-marker', }), 'context': , 'entity_id': 'sensor.mock_title_neighboring_wifi_networks', @@ -130,7 +127,7 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:wifi-marker', + 'original_icon': None, 'original_name': 'Neighboring Wifi networks', 'platform': 'devolo_home_network', 'previous_unique_id': None, diff --git a/tests/components/devolo_home_network/snapshots/test_switch.ambr b/tests/components/devolo_home_network/snapshots/test_switch.ambr index 865b881a215..760e240fee3 100644 --- a/tests/components/devolo_home_network/snapshots/test_switch.ambr +++ b/tests/components/devolo_home_network/snapshots/test_switch.ambr @@ -89,7 +89,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mock Title Enable guest Wifi', - 'icon': 'mdi:wifi', }), 'context': , 'entity_id': 'switch.mock_title_enable_guest_wifi', @@ -121,7 +120,7 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:wifi', + 'original_icon': None, 'original_name': 'Enable guest Wifi', 'platform': 'devolo_home_network', 'previous_unique_id': None, @@ -135,7 +134,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mock Title Enable LEDs', - 'icon': 'mdi:led-off', }), 'context': , 'entity_id': 'switch.mock_title_enable_leds', @@ -167,7 +165,7 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:led-off', + 'original_icon': None, 'original_name': 'Enable LEDs', 'platform': 'devolo_home_network', 'previous_unique_id': None,