async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
    if (entry.entry_id not in hass.data[DOMAIN]):
        return
    if (not entry.options.get('stats')):
        suffix = ('_gateway', '_zigbee', '_ble')
        registry: EntityRegistry = hass.data['entity_registry']
        remove = [entity.entity_id for entity in list(registry.entities.values()) if ((entity.config_entry_id == entry.entry_id) and entity.unique_id.endswith(suffix))]
        for entity_id in remove:
            registry.async_remove(entity_id)
    gw: Gateway3 = hass.data[DOMAIN][entry.entry_id]
    (await gw.stop())
    (await asyncio.gather(*[hass.config_entries.async_forward_entry_unload(entry, domain) for domain in DOMAINS]))
    return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
    if (entry.entry_id not in hass.data[DOMAIN]):
        return
    if (not entry.options.get('stats')):
        suffix = ('_gateway', '_zigbee', '_ble')
        registry: EntityRegistry = hass.data['entity_registry']
        remove = [entity.entity_id for entity in list(registry.entities.values()) if ((entity.config_entry_id == entry.entry_id) and entity.unique_id.endswith(suffix))]
        for entity_id in remove:
            registry.async_remove(entity_id)
    gw: Gateway3 = hass.data[DOMAIN][entry.entry_id]
    (await gw.stop())
    (await asyncio.gather(*[hass.config_entries.async_forward_entry_unload(entry, domain) for domain in DOMAINS]))
    return True