mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Remove legacy UniFi PoE client clean up (#100318)
This commit is contained in:
parent
23a891ebb1
commit
7b00265cfe
@ -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.
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user