Add configurable agent_id support and update integration options

- Introduced configurable OpenClaw `agent_id` for manual setup and service overrides.
- Enhanced API client to support routing messages to specific agents.
- Updated integration options to reload automatically upon saving changes.
- Added service descriptions and translations for the new `agent_id` field.
- Updated version to 0.1.58 in manifest.
This commit is contained in:
techartdev
2026-03-07 14:20:24 +02:00
parent 9bcac79241
commit e0c0c7be8e
9 changed files with 76 additions and 8 deletions
+14 -1
View File
@@ -20,11 +20,13 @@ try:
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
OptionsFlowWithReload,
)
except ImportError:
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
ConfigFlowResult = dict[str, Any]
OptionsFlowWithReload = OptionsFlow
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@@ -34,6 +36,7 @@ from .const import (
ADDON_SLUG,
ADDON_SLUG_FRAGMENTS,
CONF_ADDON_CONFIG_PATH,
CONF_AGENT_ID,
CONF_GATEWAY_HOST,
CONF_GATEWAY_PORT,
CONF_GATEWAY_TOKEN,
@@ -52,6 +55,7 @@ from .const import (
BROWSER_VOICE_LANGUAGES,
CONTEXT_STRATEGY_CLEAR,
CONTEXT_STRATEGY_TRUNCATE,
DEFAULT_AGENT_ID,
DEFAULT_GATEWAY_HOST,
DEFAULT_GATEWAY_PORT,
DEFAULT_CONTEXT_MAX_CHARS,
@@ -411,6 +415,7 @@ class OpenClawConfigFlow(ConfigFlow, domain=DOMAIN):
CONF_GATEWAY_TOKEN: token,
CONF_USE_SSL: use_ssl,
CONF_VERIFY_SSL: verify_ssl,
CONF_AGENT_ID: user_input.get(CONF_AGENT_ID, DEFAULT_AGENT_ID),
},
)
if "base" not in errors:
@@ -429,13 +434,14 @@ class OpenClawConfigFlow(ConfigFlow, domain=DOMAIN):
vol.Required(CONF_GATEWAY_TOKEN): str,
vol.Optional(CONF_USE_SSL, default=False): bool,
vol.Optional(CONF_VERIFY_SSL, default=True): bool,
vol.Optional(CONF_AGENT_ID, default=DEFAULT_AGENT_ID): str,
}
),
errors=errors,
)
class OpenClawOptionsFlow(OptionsFlow):
class OpenClawOptionsFlow(OptionsFlowWithReload):
"""Handle OpenClaw options."""
def __init__(self, config_entry: ConfigEntry) -> None:
@@ -453,6 +459,13 @@ class OpenClawOptionsFlow(OptionsFlow):
selected_provider = options.get(CONF_VOICE_PROVIDER, DEFAULT_VOICE_PROVIDER)
schema: dict[Any, Any] = {
vol.Optional(
CONF_AGENT_ID,
default=options.get(
CONF_AGENT_ID,
self._config_entry.data.get(CONF_AGENT_ID, DEFAULT_AGENT_ID),
),
): str,
vol.Optional(
CONF_INCLUDE_EXPOSED_CONTEXT,
default=options.get(