diff --git a/homeassistant/components/tplink_omada/icons.json b/homeassistant/components/tplink_omada/icons.json new file mode 100644 index 00000000000..38efc9068be --- /dev/null +++ b/homeassistant/components/tplink_omada/icons.json @@ -0,0 +1,9 @@ +{ + "entity": { + "switch": { + "poe_control": { + "default": "mdi:ethernet" + } + } + } +} diff --git a/homeassistant/components/tplink_omada/switch.py b/homeassistant/components/tplink_omada/switch.py index f8a124b94fc..618b49556d2 100644 --- a/homeassistant/components/tplink_omada/switch.py +++ b/homeassistant/components/tplink_omada/switch.py @@ -17,8 +17,6 @@ from .const import DOMAIN from .controller import OmadaSiteController, OmadaSwitchPortCoordinator from .entity import OmadaDeviceEntity -POE_SWITCH_ICON = "mdi:ethernet" - async def async_setup_entry( hass: HomeAssistant, @@ -62,8 +60,8 @@ class OmadaNetworkSwitchPortPoEControl( """Representation of a PoE control toggle on a single network port on a switch.""" _attr_has_entity_name = True + _attr_translation_key = "poe_control" _attr_entity_category = EntityCategory.CONFIG - _attr_icon = POE_SWITCH_ICON def __init__( self, @@ -74,8 +72,8 @@ class OmadaNetworkSwitchPortPoEControl( """Initialize the PoE switch.""" super().__init__(coordinator, device) self.port_id = port_id - self.port_details = self.coordinator.data[port_id] - self.omada_client = self.coordinator.omada_client + self.port_details = coordinator.data[port_id] + self.omada_client = coordinator.omada_client self._attr_unique_id = f"{device.mac}_{port_id}_poe" self._attr_name = f"{get_port_base_name(self.port_details)} PoE" diff --git a/tests/components/tplink_omada/snapshots/test_switch.ambr b/tests/components/tplink_omada/snapshots/test_switch.ambr index ee87a061a3c..78698e7ef87 100644 --- a/tests/components/tplink_omada/snapshots/test_switch.ambr +++ b/tests/components/tplink_omada/snapshots/test_switch.ambr @@ -3,7 +3,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test PoE Switch Port 1 PoE', - 'icon': 'mdi:ethernet', }), 'context': , 'entity_id': 'switch.test_poe_switch_port_1_poe', @@ -35,12 +34,12 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:ethernet', + 'original_icon': None, 'original_name': 'Port 1 PoE', 'platform': 'tplink_omada', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'poe_control', 'unique_id': '54-AF-97-00-00-01_000000000000000000000001_poe', 'unit_of_measurement': None, }) @@ -49,7 +48,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test PoE Switch Port 6 PoE', - 'icon': 'mdi:ethernet', }), 'context': , 'entity_id': 'switch.test_poe_switch_port_6_poe', @@ -81,12 +79,12 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:ethernet', + 'original_icon': None, 'original_name': 'Port 6 PoE', 'platform': 'tplink_omada', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'poe_control', 'unique_id': '54-AF-97-00-00-01_000000000000000000000006_poe', 'unit_of_measurement': None, }) @@ -95,7 +93,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test PoE Switch Port 7 PoE', - 'icon': 'mdi:ethernet', }), 'context': , 'entity_id': 'switch.test_poe_switch_port_7_poe', @@ -127,12 +124,12 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:ethernet', + 'original_icon': None, 'original_name': 'Port 7 PoE', 'platform': 'tplink_omada', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'poe_control', 'unique_id': '54-AF-97-00-00-01_000000000000000000000007_poe', 'unit_of_measurement': None, }) @@ -141,7 +138,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test PoE Switch Port 8 PoE', - 'icon': 'mdi:ethernet', }), 'context': , 'entity_id': 'switch.test_poe_switch_port_8_poe', @@ -173,12 +169,12 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:ethernet', + 'original_icon': None, 'original_name': 'Port 8 PoE', 'platform': 'tplink_omada', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'poe_control', 'unique_id': '54-AF-97-00-00-01_000000000000000000000008_poe', 'unit_of_measurement': None, }) @@ -187,7 +183,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test PoE Switch Port 2 PoE', - 'icon': 'mdi:ethernet', }), 'context': , 'entity_id': 'switch.test_poe_switch_port_2_poe', @@ -219,12 +214,12 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:ethernet', + 'original_icon': None, 'original_name': 'Port 2 PoE', 'platform': 'tplink_omada', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'poe_control', 'unique_id': '54-AF-97-00-00-01_000000000000000000000002_poe', 'unit_of_measurement': None, }) @@ -233,7 +228,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test PoE Switch Port 3 PoE', - 'icon': 'mdi:ethernet', }), 'context': , 'entity_id': 'switch.test_poe_switch_port_3_poe', @@ -265,12 +259,12 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:ethernet', + 'original_icon': None, 'original_name': 'Port 3 PoE', 'platform': 'tplink_omada', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'poe_control', 'unique_id': '54-AF-97-00-00-01_000000000000000000000003_poe', 'unit_of_measurement': None, }) @@ -279,7 +273,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test PoE Switch Port 4 PoE', - 'icon': 'mdi:ethernet', }), 'context': , 'entity_id': 'switch.test_poe_switch_port_4_poe', @@ -311,12 +304,12 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:ethernet', + 'original_icon': None, 'original_name': 'Port 4 PoE', 'platform': 'tplink_omada', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'poe_control', 'unique_id': '54-AF-97-00-00-01_000000000000000000000004_poe', 'unit_of_measurement': None, }) @@ -325,7 +318,6 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test PoE Switch Port 5 PoE', - 'icon': 'mdi:ethernet', }), 'context': , 'entity_id': 'switch.test_poe_switch_port_5_poe', @@ -357,12 +349,12 @@ 'options': dict({ }), 'original_device_class': None, - 'original_icon': 'mdi:ethernet', + 'original_icon': None, 'original_name': 'Port 5 PoE', 'platform': 'tplink_omada', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'poe_control', 'unique_id': '54-AF-97-00-00-01_000000000000000000000005_poe', 'unit_of_measurement': None, })