feat: Add configurable API timeout setting

- Add CONF_API_TIMEOUT configuration option (5-600 seconds, default 30)
- Update config_flow.py with api_timeout field in provider form and options flow
- Update api_client.py to use configurable timeout instead of hardcoded value
- Update coordinator.py to use api_timeout for async_process_message
- Update __init__.py to read and pass api_timeout from config
- Merge entry.data with entry.options for proper options flow support
- Add translations for api_timeout in all 8 language files (en, ru, de, es, it, hi, sr, zh)
- Bump version to 2.2.0

Closes #8
This commit is contained in:
SMKRV
2025-12-22 00:07:17 +03:00
parent 35073960b8
commit 3097106e93
14 changed files with 90 additions and 20 deletions
+5 -3
View File
@@ -16,7 +16,7 @@ from datetime import datetime, timedelta
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from .const import (
API_TIMEOUT,
DEFAULT_API_TIMEOUT,
API_RETRY_COUNT,
API_PROVIDER_ANTHROPIC,
API_PROVIDER_DEEPSEEK,
@@ -41,6 +41,7 @@ class APIClient:
headers: Dict[str, str],
api_provider: str,
model: str,
api_timeout: int = DEFAULT_API_TIMEOUT,
) -> None:
"""Initialize API client."""
self.session = session
@@ -48,7 +49,8 @@ class APIClient:
self.headers = headers
self.api_provider = api_provider
self.model = model
self.timeout = ClientTimeout(total=API_TIMEOUT)
self.api_timeout = api_timeout
self.timeout = ClientTimeout(total=api_timeout)
self._closed = False
async def __aenter__(self):
@@ -93,7 +95,7 @@ class APIClient:
for attempt in range(API_RETRY_COUNT):
try:
async with timeout(API_TIMEOUT):
async with timeout(self.api_timeout):
async with self.session.post(
url,
json=payload,