mirror of
https://github.com/smkrv/ha-text-ai.git
synced 2026-07-22 07:03:58 +08:00
fix: HA 2024.11+ compatibility and deprecation fixes
CRITICAL: - Remove OptionsFlowHandler.__init__ (deprecated HA 2024.11+) - Replace FlowResult with ConfigFlowResult (deprecated HA 2024.4+) Compatibility: - Reorder async_unload_entry: unload platforms before coordinator cleanup - Clean up hass.data[DOMAIN] when last entry removed - Remove aiohttp from manifest requirements (provided by HA core) - Replace blocking file I/O in const.py with hardcoded VERSION - Remove unused os, json, logging imports from const.py - Fix f-string logger calls in api_client.py to use %s formatting
This commit is contained in:
@@ -343,16 +343,19 @@ async def async_update_options(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
try:
|
||||
if entry.entry_id in hass.data[DOMAIN]:
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if unload_ok and entry.entry_id in hass.data[DOMAIN]:
|
||||
coordinator = hass.data[DOMAIN].pop(entry.entry_id)
|
||||
|
||||
if hasattr(coordinator.client, 'shutdown'):
|
||||
await coordinator.client.shutdown()
|
||||
|
||||
await coordinator.async_shutdown()
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if not hass.data.get(DOMAIN):
|
||||
hass.data.pop(DOMAIN, None)
|
||||
|
||||
return unload_ok
|
||||
|
||||
except Exception as ex:
|
||||
_LOGGER.exception("Error unloading entry: %s", str(ex))
|
||||
|
||||
Reference in New Issue
Block a user