Revert "Add ability to ignore devices for UniFi Protect" (#77916)

This commit is contained in:
Franck Nijhof 2022-09-06 20:13:01 +02:00 committed by GitHub
parent 5632e33426
commit dbb556a812
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 75 additions and 258 deletions

View file

@ -7,21 +7,20 @@ from unittest.mock import AsyncMock, patch
import aiohttp
from pyunifiprotect import NotAuthorized, NvrError, ProtectApiClient
from pyunifiprotect.data import NVR, Bootstrap, Doorlock, Light, Sensor
from pyunifiprotect.data import NVR, Bootstrap, Light
from homeassistant.components.unifiprotect.const import (
CONF_DISABLE_RTSP,
CONF_IGNORED,
DEFAULT_SCAN_INTERVAL,
DOMAIN,
)
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.setup import async_setup_component
from . import _patch_discovery
from .utils import MockUFPFixture, get_device_from_ufp_device, init_entry, time_changed
from .utils import MockUFPFixture, init_entry, time_changed
from tests.common import MockConfigEntry
@ -212,38 +211,28 @@ async def test_device_remove_devices(
hass: HomeAssistant,
ufp: MockUFPFixture,
light: Light,
doorlock: Doorlock,
sensor: Sensor,
hass_ws_client: Callable[
[HomeAssistant], Awaitable[aiohttp.ClientWebSocketResponse]
],
) -> None:
"""Test we can only remove a device that no longer exists."""
sensor.mac = "FFFFFFFFFFFF"
await init_entry(hass, ufp, [light, doorlock, sensor], regenerate_ids=False)
await init_entry(hass, ufp, [light])
assert await async_setup_component(hass, "config", {})
entity_id = "light.test_light"
entry_id = ufp.entry.entry_id
registry: er.EntityRegistry = er.async_get(hass)
entity = registry.async_get(entity_id)
assert entity is not None
device_registry = dr.async_get(hass)
light_device = get_device_from_ufp_device(hass, light)
assert light_device is not None
live_device_entry = device_registry.async_get(entity.device_id)
assert (
await remove_device(await hass_ws_client(hass), light_device.id, entry_id)
is True
await remove_device(await hass_ws_client(hass), live_device_entry.id, entry_id)
is False
)
doorlock_device = get_device_from_ufp_device(hass, doorlock)
assert (
await remove_device(await hass_ws_client(hass), doorlock_device.id, entry_id)
is True
)
sensor_device = get_device_from_ufp_device(hass, sensor)
assert sensor_device is None
dead_device_entry = device_registry.async_get_or_create(
config_entry_id=entry_id,
connections={(dr.CONNECTION_NETWORK_MAC, "e9:88:e7:b8:b4:40")},
@ -253,10 +242,6 @@ async def test_device_remove_devices(
is True
)
await time_changed(hass, 60)
entry = hass.config_entries.async_get_entry(entry_id)
entry.options[CONF_IGNORED] == f"{light.mac},{doorlock.mac}"
async def test_device_remove_devices_nvr(
hass: HomeAssistant,