1
mirror of https://github.com/home-assistant/core synced 2024-09-03 08:14:07 +02:00

Allow removing Sonos devices (#73567)

This commit is contained in:
jjlawren 2022-06-16 00:21:39 -05:00 committed by GitHub
parent b4359c7721
commit 90e402eca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,7 @@ from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOSTS, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers import config_validation as cv, device_registry as dr
from homeassistant.helpers.dispatcher import async_dispatcher_send, dispatcher_send
from homeassistant.helpers.event import async_track_time_interval, call_later
from homeassistant.helpers.typing import ConfigType
@ -396,3 +396,17 @@ class SonosDiscoveryManager:
AVAILABILITY_CHECK_INTERVAL,
)
)
async def async_remove_config_entry_device(
hass: HomeAssistant, config_entry: ConfigEntry, device_entry: dr.DeviceEntry
) -> bool:
"""Remove Sonos config entry from a device."""
known_devices = hass.data[DATA_SONOS].discovered.keys()
for identifier in device_entry.identifiers:
if identifier[0] != DOMAIN:
continue
uid = identifier[1]
if uid not in known_devices:
return True
return False