mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Allow removal of myuplink device from GUI (#117009)
* Allow removal of device from GUI * Check that device is orphaned before removing
This commit is contained in:
parent
1b87a2dd73
commit
855ba68b62
@ -16,6 +16,7 @@ from homeassistant.helpers import (
|
|||||||
config_entry_oauth2_flow,
|
config_entry_oauth2_flow,
|
||||||
device_registry as dr,
|
device_registry as dr,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.device_registry import DeviceEntry
|
||||||
|
|
||||||
from .api import AsyncConfigEntryAuth
|
from .api import AsyncConfigEntryAuth
|
||||||
from .const import DOMAIN, OAUTH2_SCOPES
|
from .const import DOMAIN, OAUTH2_SCOPES
|
||||||
@ -96,3 +97,14 @@ def create_devices(
|
|||||||
sw_version=device.firmwareCurrent,
|
sw_version=device.firmwareCurrent,
|
||||||
serial_number=device.product_serial_number,
|
serial_number=device.product_serial_number,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def async_remove_config_entry_device(
|
||||||
|
hass: HomeAssistant, config_entry: ConfigEntry, device_entry: DeviceEntry
|
||||||
|
) -> bool:
|
||||||
|
"""Remove myuplink config entry from a device."""
|
||||||
|
|
||||||
|
myuplink_data: MyUplinkDataCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
return not device_entry.identifiers.intersection(
|
||||||
|
(DOMAIN, device_id) for device_id in myuplink_data.data.devices
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user