diff --git a/homeassistant/components/unifi/__init__.py b/homeassistant/components/unifi/__init__.py index 71404ef4bc2..15b0fbafead 100644 --- a/homeassistant/components/unifi/__init__.py +++ b/homeassistant/components/unifi/__init__.py @@ -76,9 +76,7 @@ async def async_remove_config_entry_device( """Remove config entry from a device.""" hub = config_entry.runtime_data return not any( - identifier - for _, identifier in device_entry.connections - if identifier in hub.api.clients or identifier in hub.api.devices + identifier in hub.api.devices for _, identifier in device_entry.connections ) diff --git a/tests/components/unifi/test_init.py b/tests/components/unifi/test_init.py index 7aeaa85649f..e04277e6c04 100644 --- a/tests/components/unifi/test_init.py +++ b/tests/components/unifi/test_init.py @@ -178,13 +178,13 @@ async def test_remove_config_entry_device( assert await async_setup_component(hass, "config", {}) ws_client = await hass_ws_client(hass) - # Try to remove an active client from UI: not allowed + # Try to remove an active client from UI: allowed device_entry = device_registry.async_get_device( connections={(dr.CONNECTION_NETWORK_MAC, client_payload[0]["mac"])} ) response = await ws_client.remove_device(device_entry.id, config_entry.entry_id) - assert not response["success"] - assert device_registry.async_get_device( + assert response["success"] + assert not device_registry.async_get_device( connections={(dr.CONNECTION_NETWORK_MAC, client_payload[0]["mac"])} )