Merge branch 'main' into feature/configurable-agent-id

This commit is contained in:
TechArtDev
2026-03-07 14:21:16 +02:00
committed by GitHub
5 changed files with 21 additions and 13 deletions
+4 -1
View File
@@ -140,6 +140,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: OpenClawConfigEntry) ->
use_ssl = entry.data.get(CONF_USE_SSL, False)
verify_ssl = entry.data.get(CONF_VERIFY_SSL, True)
session = async_get_clientsession(hass, verify_ssl=verify_ssl)
agent_id: str = entry.options.get(
CONF_AGENT_ID,
entry.data.get(CONF_AGENT_ID, DEFAULT_AGENT_ID),
)
# agent_id can come from options (user-changeable) or from initial config data
agent_id: str = entry.options.get(
@@ -395,7 +399,6 @@ def _async_register_services(hass: HomeAssistant) -> None:
"""Handle the openclaw.send_message service call."""
message: str = call.data[ATTR_MESSAGE]
session_id: str = call.data.get(ATTR_SESSION_ID) or "default"
# Per-call agent_id overrides the client-level default when provided.
call_agent_id: str | None = call.data.get(ATTR_AGENT_ID)
entry_data = _get_first_entry_data(hass)
+3 -10
View File
@@ -86,12 +86,7 @@ class OpenClawApiClient:
self._token = token
def _headers(self, agent_id: str | None = None) -> dict[str, str]:
"""Build request headers with auth token and agent ID.
Args:
agent_id: Per-call agent ID override. Falls back to the
client-level ``agent_id`` set in the constructor.
"""
"""Build request headers with auth token and agent ID."""
effective_agent = agent_id or self._agent_id or "main"
return {
"Authorization": f"Bearer {self._token}",
@@ -201,8 +196,7 @@ class OpenClawApiClient:
session_id: Optional session/conversation ID.
model: Optional model override.
stream: If True, raises ValueError (use async_stream_message).
agent_id: Optional per-call agent ID override (overrides the
client-level default set in the constructor).
agent_id: Optional per-call agent ID override.
Returns:
Complete chat completion response.
@@ -270,8 +264,7 @@ class OpenClawApiClient:
message: The user message text.
session_id: Optional session/conversation ID.
model: Optional model override.
agent_id: Optional per-call agent ID override (overrides the
client-level default set in the constructor).
agent_id: Optional per-call agent ID override.
Yields:
Content delta strings from the streaming response.
+3 -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
@@ -439,7 +441,7 @@ class OpenClawConfigFlow(ConfigFlow, domain=DOMAIN):
)
class OpenClawOptionsFlow(OptionsFlow):
class OpenClawOptionsFlow(OptionsFlowWithReload):
"""Handle OpenClaw options."""
def __init__(self, config_entry: ConfigEntry) -> None:
+1 -1
View File
@@ -8,7 +8,7 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/techartdev/OpenClawHomeAssistant/issues",
"requirements": [],
"version": "0.1.57",
"version": "0.1.58",
"dependencies": ["conversation"],
"after_dependencies": ["hassio", "lovelace"]
}