mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Allow WeatherFlow devices to be removed (#103556)
Allow WeatherFlow devices to be removed if they haven't reported
This commit is contained in:
parent
9c0bfc1b58
commit
53b15fd16d
@ -9,6 +9,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform
|
||||||
from homeassistant.core import Event, HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
from homeassistant.helpers.device_registry import DeviceEntry
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from homeassistant.helpers.start import async_at_started
|
from homeassistant.helpers.start import async_at_started
|
||||||
|
|
||||||
@ -75,3 +76,17 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
await client.stop_listening()
|
await client.stop_listening()
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
|
async def async_remove_config_entry_device(
|
||||||
|
hass: HomeAssistant, config_entry: ConfigEntry, device_entry: DeviceEntry
|
||||||
|
) -> bool:
|
||||||
|
"""Remove a config entry from a device."""
|
||||||
|
client: WeatherFlowListener = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
return not any(
|
||||||
|
identifier
|
||||||
|
for identifier in device_entry.identifiers
|
||||||
|
if identifier[0] == DOMAIN
|
||||||
|
for device in client.devices
|
||||||
|
if device.serial_number == identifier[1]
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user