Allow manual delete of stale Unifi device from UI (#115267)
* Allow manual delete of stale device from UI * Add unit tests for remove_config_entry_device
This commit is contained in:
parent
b592225a87
commit
1c0c0bb0bc
2 changed files with 112 additions and 1 deletions
|
@ -7,6 +7,7 @@ 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
|
||||
from homeassistant.helpers.device_registry import DeviceEntry
|
||||
from homeassistant.helpers.storage import Store
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
|
@ -73,6 +74,18 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
|||
return await hub.async_reset()
|
||||
|
||||
|
||||
async def async_remove_config_entry_device(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry, device_entry: DeviceEntry
|
||||
) -> bool:
|
||||
"""Remove config entry from a device."""
|
||||
hub: UnifiHub = hass.data[UNIFI_DOMAIN][config_entry.entry_id]
|
||||
return not any(
|
||||
identifier
|
||||
for _, identifier in device_entry.connections
|
||||
if identifier in hub.api.clients or identifier in hub.api.devices
|
||||
)
|
||||
|
||||
|
||||
class UnifiWirelessClients:
|
||||
"""Class to store clients known to be wireless.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue