Release v2.0.0

This commit is contained in:
SMKRV
2024-11-22 11:36:34 +03:00
parent bb8195c0d1
commit 30d69e7ed1
2 changed files with 27 additions and 17 deletions
+8 -10
View File
@@ -189,15 +189,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
else: # OpenAI
headers["Authorization"] = f"Bearer {api_key}"
# Проверка API с повторами
for attempt in range(API_RETRY_COUNT):
if await async_check_api(session, endpoint, headers, api_provider):
break
if attempt < API_RETRY_COUNT - 1:
delay = 1.5 * (2 ** attempt)
await asyncio.sleep(delay)
else:
raise ConfigEntryNotReady("Failed to connect to API")
# Проверка API
try:
check_result = await async_check_api(session, endpoint, headers, api_provider)
if not check_result:
raise ConfigEntryNotReady("API connection failed")
except Exception as ex:
_LOGGER.error(f"API check failed: {ex}")
raise ConfigEntryNotReady("Failed to connect to API")
try:
# Create coordinator
@@ -235,7 +234,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
_LOGGER.exception("Setup error: %s", str(ex))
raise ConfigEntryNotReady(f"Setup error: {str(ex)}") from ex
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
try: