Simplify samsungtv unload (#117838)

pull/117851/head^2
epenet 2024-05-21 10:01:52 +02:00 committed by GitHub
parent 54d048fb11
commit bfffcc3ad6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 7 deletions

View File

@ -160,7 +160,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: SamsungTVConfigEntry) ->
bridge.register_update_config_entry_callback(_update_config_entry)
async def stop_bridge(event: Event) -> None:
async def stop_bridge(event: Event | None = None) -> None:
"""Stop SamsungTV bridge connection."""
LOGGER.debug("Stopping SamsungTVBridge %s", bridge.host)
await bridge.async_close_remote()
@ -168,6 +168,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: SamsungTVConfigEntry) ->
entry.async_on_unload(
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_bridge)
)
entry.async_on_unload(stop_bridge)
await _async_update_ssdp_locations(hass, entry)
@ -269,12 +270,7 @@ async def _async_create_bridge_with_updated_data(
async def async_unload_entry(hass: HomeAssistant, entry: SamsungTVConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
bridge = entry.runtime_data
LOGGER.debug("Stopping SamsungTVBridge %s", bridge.host)
await bridge.async_close_remote()
return unload_ok
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: