custom_components/keymaster/__init__.py
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
    """Handle removal of an entry."""
    lockname = config_entry.data[CONF_LOCK_NAME]
    notification_id = f"{DOMAIN}_{lockname}_unload"
    async_create(
        hass,
        (
            f"Removing `{lockname}` and all of the files that were generated for "
            "it. This may take some time so don't panic. This message will "
            "automatically clear when removal is complete."
        ),
        title=f"{DOMAIN.title()} - Removing `{lockname}`",
        notification_id=notification_id,
    )

    unload_ok = all(
        await asyncio.gather(
            *[
                hass.config_entries.async_forward_entry_unload(config_entry, platform)
                for platform in PLATFORMS
            ]
        )
    )

    if unload_ok:
        # Remove all package files and the base folder if needed
        await hass.async_add_executor_job(
            delete_lock_and_base_folder, hass, config_entry
        )

        await async_reload_package_platforms(hass)

        # Unsubscribe to any listeners
        for unsub_listener in hass.data[DOMAIN][config_entry.entry_id].get(
            UNSUB_LISTENERS, []
        ):
            unsub_listener()
        hass.data[DOMAIN][config_entry.entry_id].get(UNSUB_LISTENERS, []).clear()

        hass.data[DOMAIN].pop(config_entry.entry_id)

    async_dismiss(hass, notification_id)

    return unload_ok
Handle removal of an entry.
Handle removal of an entry.
Handle removal of an entry .
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
    lockname = config_entry.data[CONF_LOCK_NAME]
    notification_id = f"{DOMAIN}_{lockname}_unload"
    async_create(
        hass,
        (
            f"Removing `{lockname}` and all of the files that were generated for "
            "it. This may take some time so don't panic. This message will "
            "automatically clear when removal is complete."
        ),
        title=f"{DOMAIN.title()} - Removing `{lockname}`",
        notification_id=notification_id,
    )
    unload_ok = all(
        await asyncio.gather(
            *[
                hass.config_entries.async_forward_entry_unload(config_entry, platform)
                for platform in PLATFORMS
            ]
        )
    )
    if unload_ok:
        await hass.async_add_executor_job(
            delete_lock_and_base_folder, hass, config_entry
        )
        await async_reload_package_platforms(hass)
        for unsub_listener in hass.data[DOMAIN][config_entry.entry_id].get(
            UNSUB_LISTENERS, []
        ):
            unsub_listener()
        hass.data[DOMAIN][config_entry.entry_id].get(UNSUB_LISTENERS, []).clear()
        hass.data[DOMAIN].pop(config_entry.entry_id)
    async_dismiss(hass, notification_id)
    return unload_ok
async def async_unload_entry ( hass : HomeAssistant , config_entry : ConfigEntry ) -> bool : lockname = config_entry . data [ CONF_LOCK_NAME ] notification_id = f"{DOMAIN}_{lockname}_unload" async_create ( hass , ( f"Removing `{lockname}` and all of the files that were generated for " "it. This may take some time so don't panic. This message will " "automatically clear when removal is complete." ) , title = f"{DOMAIN.title()} - Removing `{lockname}`" , notification_id = notification_id , ) unload_ok = all ( await asyncio . gather ( * [ hass . config_entries . async_forward_entry_unload ( config_entry , platform ) for platform in PLATFORMS ] ) ) if unload_ok : await hass . async_add_executor_job ( delete_lock_and_base_folder , hass , config_entry ) await async_reload_package_platforms ( hass ) for unsub_listener in hass . data [ DOMAIN ] [ config_entry . entry_id ] . get ( UNSUB_LISTENERS , [ ] ) : unsub_listener ( ) hass . data [ DOMAIN ] [ config_entry . entry_id ] . get ( UNSUB_LISTENERS , [ ] ) . clear ( ) hass . data [ DOMAIN ] . pop ( config_entry . entry_id ) async_dismiss ( hass , notification_id ) return unload_ok
Handle removal of an entry.
Handle removal of an entry .
"""Handle removal of an entry.""" # Remove all package files and the base folder if needed # Unsubscribe to any listeners
hass
HomeAssistant
config_entry
ConfigEntry