Update changelog, enhance error handling, and improve user feedback for OpenClaw integration
- Documented changes in changelog for version 0.1.3. - Improved error handling in async_check_connection to propagate OpenClawApiError. - Added clear error messages for users regarding OpenAI API settings in config flow. - Updated translations to include new error messages related to OpenAI API status.
This commit is contained in:
@@ -2,6 +2,24 @@
|
|||||||
|
|
||||||
All notable changes to the OpenClaw Home Assistant Integration will be documented in this file.
|
All notable changes to the OpenClaw Home Assistant Integration will be documented in this file.
|
||||||
|
|
||||||
|
## [0.1.3] - 2026-02-20
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `async_check_connection()` no longer silently swallows `OpenClawApiError`.
|
||||||
|
Previously any API-level error (e.g. gateway returning HTML) was caught and
|
||||||
|
converted to a generic "Cannot connect" message with no indication of the
|
||||||
|
real cause. The error is now propagated to the config flow.
|
||||||
|
- Config flow now catches `OpenClawApiError` separately and shows a clear,
|
||||||
|
actionable error message: **"openai_api_disabled"** — pointing the user to
|
||||||
|
enable `enable_openai_api` in the addon settings and restart.
|
||||||
|
- Auto-discovery now logs a `WARNING` when `enable_openai_api` is `false` in
|
||||||
|
the addon options, making the issue visible in the HA log before setup fails.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- The `enable_openai_api` addon option (default `false`) must be `true` for the
|
||||||
|
integration to connect. The `/v1/models` probe endpoint requires the
|
||||||
|
OpenAI-compatible API layer to be active.
|
||||||
|
|
||||||
## [0.1.2] - 2026-02-20
|
## [0.1.2] - 2026-02-20
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -292,20 +292,22 @@ class OpenClawApiClient:
|
|||||||
Uses the /v1/models endpoint as a lightweight probe — the only
|
Uses the /v1/models endpoint as a lightweight probe — the only
|
||||||
consistently available GET endpoint on the OpenClaw gateway.
|
consistently available GET endpoint on the OpenClaw gateway.
|
||||||
|
|
||||||
|
The /v1/models endpoint requires 'enable_openai_api' to be enabled in
|
||||||
|
the addon configuration. If the gateway returns HTML instead of JSON,
|
||||||
|
the OpenAI-compatible API is likely disabled and an OpenClawApiError
|
||||||
|
is raised so the caller can surface a meaningful error.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
True if connected and authenticated.
|
True if connected and authenticated.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
OpenClawAuthError: If authentication fails (re-raised so callers
|
OpenClawAuthError: If authentication fails.
|
||||||
can distinguish bad tokens from unreachable gateways).
|
OpenClawApiError: If the gateway returns an unexpected response
|
||||||
|
(e.g. HTML when enable_openai_api is disabled).
|
||||||
|
OpenClawConnectionError: If the gateway is unreachable.
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
await self.async_get_models()
|
await self.async_get_models()
|
||||||
return True
|
return True
|
||||||
except OpenClawAuthError:
|
|
||||||
raise
|
|
||||||
except OpenClawApiError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
async def async_close(self) -> None:
|
async def async_close(self) -> None:
|
||||||
"""Close the HTTP session."""
|
"""Close the HTTP session."""
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .api import OpenClawApiClient, OpenClawAuthError, OpenClawConnectionError
|
from .api import OpenClawApiClient, OpenClawApiError, OpenClawAuthError, OpenClawConnectionError
|
||||||
from .const import (
|
from .const import (
|
||||||
ADDON_CONFIGS_ROOT,
|
ADDON_CONFIGS_ROOT,
|
||||||
ADDON_SLUG,
|
ADDON_SLUG,
|
||||||
@@ -163,6 +163,15 @@ async def _async_try_discover_addon(hass: HomeAssistant) -> dict[str, Any] | Non
|
|||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Warn early if the OpenAI-compatible API is disabled — /v1/models will return
|
||||||
|
# HTML and the connection probe will fail with a misleading error.
|
||||||
|
if not addon_options.get("enable_openai_api", False):
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Addon option 'enable_openai_api' is false. "
|
||||||
|
"The integration requires this to be enabled. "
|
||||||
|
"Enable it in the addon configuration and restart the addon."
|
||||||
|
)
|
||||||
|
|
||||||
# ── Step 2: Find the addon config directory on the filesystem ────
|
# ── Step 2: Find the addon config directory on the filesystem ────
|
||||||
config_dir = await hass.async_add_executor_job(_find_addon_config_dir)
|
config_dir = await hass.async_add_executor_job(_find_addon_config_dir)
|
||||||
if not config_dir:
|
if not config_dir:
|
||||||
@@ -270,6 +279,10 @@ class OpenClawConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
except OpenClawConnectionError:
|
except OpenClawConnectionError:
|
||||||
connected = False
|
connected = False
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
|
except OpenClawApiError as err:
|
||||||
|
connected = False
|
||||||
|
errors["base"] = "openai_api_disabled"
|
||||||
|
_LOGGER.warning("Gateway API error during connection check: %s", err)
|
||||||
|
|
||||||
if connected:
|
if connected:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
@@ -313,6 +326,10 @@ class OpenClawConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
except OpenClawConnectionError:
|
except OpenClawConnectionError:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
connected = False
|
connected = False
|
||||||
|
except OpenClawApiError as err:
|
||||||
|
errors["base"] = "openai_api_disabled"
|
||||||
|
connected = False
|
||||||
|
_LOGGER.warning("Gateway API error during connection check: %s", err)
|
||||||
|
|
||||||
if connected:
|
if connected:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"issue_tracker": "https://github.com/techartdev/OpenClawHomeAssistant/issues",
|
"issue_tracker": "https://github.com/techartdev/OpenClawHomeAssistant/issues",
|
||||||
"requirements": [],
|
"requirements": [],
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"dependencies": ["conversation"],
|
"dependencies": ["conversation"],
|
||||||
"after_dependencies": ["hassio"]
|
"after_dependencies": ["hassio"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"error": {
|
"error": {
|
||||||
"cannot_connect": "Cannot connect to the OpenClaw gateway. Ensure the addon is running.",
|
"cannot_connect": "Cannot connect to the OpenClaw gateway. Ensure the addon is running.",
|
||||||
"invalid_auth": "Invalid gateway token. Check your OpenClaw configuration.",
|
"invalid_auth": "Invalid gateway token. Check your OpenClaw configuration.",
|
||||||
|
"openai_api_disabled": "The gateway returned an unexpected response — the OpenAI-compatible API is likely disabled. In the OpenClaw addon settings enable 'enable_openai_api', restart the addon, and try again.",
|
||||||
"unknown": "An unexpected error occurred."
|
"unknown": "An unexpected error occurred."
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"error": {
|
"error": {
|
||||||
"cannot_connect": "Cannot connect to the OpenClaw gateway. Ensure the addon is running.",
|
"cannot_connect": "Cannot connect to the OpenClaw gateway. Ensure the addon is running.",
|
||||||
"invalid_auth": "Invalid gateway token. Check your OpenClaw configuration.",
|
"invalid_auth": "Invalid gateway token. Check your OpenClaw configuration.",
|
||||||
|
"openai_api_disabled": "The gateway returned an unexpected response — the OpenAI-compatible API is likely disabled. In the OpenClaw addon settings enable 'enable_openai_api', restart the addon, and try again.",
|
||||||
"unknown": "An unexpected error occurred."
|
"unknown": "An unexpected error occurred."
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
|
|||||||
Reference in New Issue
Block a user