diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4e299d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# Python bytecode and cache +__pycache__/ +*.py[cod] +*$py.class + +# Common virtual environments +.venv/ +venv/ +env/ + +# Tool caches +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ + +# OS/editor noise +.DS_Store +Thumbs.db diff --git a/CHANGELOG.md b/CHANGELOG.md index 5658a6d..0871bfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to the OpenClaw Home Assistant Integration will be documented in this file. +## [0.1.43] - 2026-02-21 + +### Fixed +- Improved Home Assistant Assist conversation continuity by using stable fallback session IDs when `conversation_id` is missing. +- Assist now falls back to per-user (`assist_user_*`) or per-device (`assist_device_*`) session keys instead of a single generic default. + ## [0.1.42] - 2026-02-21 ### Added diff --git a/custom_components/openclaw/__init__.py b/custom_components/openclaw/__init__.py index b207b15..a215c1d 100644 --- a/custom_components/openclaw/__init__.py +++ b/custom_components/openclaw/__init__.py @@ -92,7 +92,7 @@ _CARD_PATH = Path(__file__).parent / "www" / _CARD_FILENAME # URL at which the card JS is served (registered via register_static_path) _CARD_STATIC_URL = f"/openclaw/{_CARD_FILENAME}" # Versioned URL used for Lovelace resource registration to avoid stale browser cache -_CARD_URL = f"{_CARD_STATIC_URL}?v=0.1.42" +_CARD_URL = f"{_CARD_STATIC_URL}?v=0.1.43" OpenClawConfigEntry = ConfigEntry diff --git a/custom_components/openclaw/__pycache__/__init__.cpython-312.pyc b/custom_components/openclaw/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index a531c08..0000000 Binary files a/custom_components/openclaw/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/custom_components/openclaw/__pycache__/conversation.cpython-312.pyc b/custom_components/openclaw/__pycache__/conversation.cpython-312.pyc deleted file mode 100644 index b15cf4a..0000000 Binary files a/custom_components/openclaw/__pycache__/conversation.cpython-312.pyc and /dev/null differ diff --git a/custom_components/openclaw/conversation.py b/custom_components/openclaw/conversation.py index bc9394f..4d9dfd3 100644 --- a/custom_components/openclaw/conversation.py +++ b/custom_components/openclaw/conversation.py @@ -107,7 +107,7 @@ class OpenClawConversationAgent(conversation.AbstractConversationAgent): coordinator: OpenClawCoordinator = entry_data["coordinator"] message = user_input.text - conversation_id = user_input.conversation_id or "default" + conversation_id = self._resolve_conversation_id(user_input) assistant_id = "conversation" options = self.entry.options include_context = options.get( @@ -189,6 +189,22 @@ class OpenClawConversationAgent(conversation.AbstractConversationAgent): conversation_id=conversation_id, ) + def _resolve_conversation_id(self, user_input: conversation.ConversationInput) -> str: + """Return conversation id from HA or a stable Assist fallback session key.""" + if user_input.conversation_id: + return user_input.conversation_id + + context = getattr(user_input, "context", None) + user_id = getattr(context, "user_id", None) + if user_id: + return f"assist_user_{user_id}" + + device_id = getattr(user_input, "device_id", None) + if device_id: + return f"assist_device_{device_id}" + + return "assist_default" + async def _get_response( self, client: OpenClawApiClient, diff --git a/custom_components/openclaw/manifest.json b/custom_components/openclaw/manifest.json index 442652a..1119b4b 100644 --- a/custom_components/openclaw/manifest.json +++ b/custom_components/openclaw/manifest.json @@ -8,7 +8,7 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/techartdev/OpenClawHomeAssistant/issues", "requirements": [], - "version": "0.1.42", + "version": "0.1.43", "dependencies": ["conversation"], "after_dependencies": ["hassio", "lovelace"] } diff --git a/www/openclaw-chat-card.js b/www/openclaw-chat-card.js index 3685489..3b26fe1 100644 --- a/www/openclaw-chat-card.js +++ b/www/openclaw-chat-card.js @@ -1,7 +1,7 @@ (async () => { try { if (!customElements.get("openclaw-chat-card")) { - const src = "/openclaw/openclaw-chat-card.js?v=0.1.42"; + const src = "/openclaw/openclaw-chat-card.js?v=0.1.43"; console.info("OpenClaw loader importing", src); await import(src); }