Simplify samsungtv unload (#117838)
parent
54d048fb11
commit
bfffcc3ad6
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue