diff --git a/homeassistant/components/unifi/__init__.py b/homeassistant/components/unifi/__init__.py index 10959b8965c..0bde41ac611 100644 --- a/homeassistant/components/unifi/__init__.py +++ b/homeassistant/components/unifi/__init__.py @@ -6,7 +6,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady -from homeassistant.helpers import config_validation as cv, entity_registry as er +from homeassistant.helpers import config_validation as cv from homeassistant.helpers.storage import Store from homeassistant.helpers.typing import ConfigType @@ -34,9 +34,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b """Set up the UniFi Network integration.""" hass.data.setdefault(UNIFI_DOMAIN, {}) - # Removal of legacy PoE control was introduced with 2022.12 - async_remove_poe_client_entities(hass, config_entry) - try: api = await get_unifi_controller(hass, config_entry.data) controller = UniFiController(hass, config_entry, api) @@ -74,24 +71,6 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> return await controller.async_reset() -@callback -def async_remove_poe_client_entities( - hass: HomeAssistant, config_entry: ConfigEntry -) -> None: - """Remove PoE client entities.""" - ent_reg = er.async_get(hass) - - entity_ids_to_be_removed = [ - entry.entity_id - for entry in ent_reg.entities.values() - if entry.config_entry_id == config_entry.entry_id - and entry.unique_id.startswith("poe-") - ] - - for entity_id in entity_ids_to_be_removed: - ent_reg.async_remove(entity_id) - - class UnifiWirelessClients: """Class to store clients known to be wireless. diff --git a/tests/components/unifi/test_switch.py b/tests/components/unifi/test_switch.py index d376cab8add..8e536119291 100644 --- a/tests/components/unifi/test_switch.py +++ b/tests/components/unifi/test_switch.py @@ -6,7 +6,6 @@ from aiounifi.models.message import MessageKey from aiounifi.websocket import WebsocketState import pytest -from homeassistant import config_entries from homeassistant.components.switch import ( DOMAIN as SWITCH_DOMAIN, SERVICE_TURN_OFF, @@ -34,12 +33,7 @@ from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_registry import RegistryEntryDisabler from homeassistant.util import dt as dt_util -from .test_controller import ( - CONTROLLER_HOST, - ENTRY_CONFIG, - SITE, - setup_unifi_integration, -) +from .test_controller import CONTROLLER_HOST, SITE, setup_unifi_integration from tests.common import async_fire_time_changed from tests.test_util.aiohttp import AiohttpClientMocker @@ -1436,38 +1430,6 @@ async def test_poe_port_switches( assert hass.states.get("switch.mock_name_port_1_poe").state == STATE_OFF -async def test_remove_poe_client_switches( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker -) -> None: - """Test old PoE client switches are removed.""" - - config_entry = config_entries.ConfigEntry( - version=1, - domain=UNIFI_DOMAIN, - title="Mock Title", - data=ENTRY_CONFIG, - source="test", - options={}, - entry_id="1", - ) - - ent_reg = er.async_get(hass) - ent_reg.async_get_or_create( - SWITCH_DOMAIN, - UNIFI_DOMAIN, - "poe-123", - config_entry=config_entry, - ) - - await setup_unifi_integration(hass, aioclient_mock) - - assert not [ - entry - for entry in ent_reg.entities.values() - if entry.config_entry_id == config_entry.entry_id - ] - - async def test_wlan_switches( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, mock_unifi_websocket ) -> None: