script cleanup
This commit is contained in:
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
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.21] - 2026-02-20
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Added automatic cleanup of duplicate/legacy OpenClaw Lovelace resources (`/local/...`, unversioned `/openclaw/...`, `/hacsfiles/...`) so only the current versioned resource is kept.
|
||||||
|
- Prevents loading multiple OpenClaw card generations (`v0.2.0` + `v0.2.1`) at the same time.
|
||||||
|
|
||||||
## [0.1.20] - 2026-02-20
|
## [0.1.20] - 2026-02-20
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from datetime import datetime, timezone
|
|||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from homeassistant.components import websocket_api
|
from homeassistant.components import websocket_api
|
||||||
@@ -291,6 +292,29 @@ async def _async_add_lovelace_resource(hass: HomeAssistant, url: str) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
existing_items = list(resource_collection.async_items())
|
||||||
|
|
||||||
|
desired_path = urlsplit(url).path
|
||||||
|
legacy_paths = {
|
||||||
|
"/openclaw/openclaw-chat-card.js",
|
||||||
|
"/local/openclaw-chat-card.js",
|
||||||
|
"/hacsfiles/openclaw/openclaw-chat-card.js",
|
||||||
|
}
|
||||||
|
|
||||||
|
to_remove: list[str] = []
|
||||||
|
for item in existing_items:
|
||||||
|
item_id = item.get("id")
|
||||||
|
item_url = item.get("url")
|
||||||
|
if not item_id or not item_url:
|
||||||
|
continue
|
||||||
|
item_path = urlsplit(item_url).path
|
||||||
|
if item_path in legacy_paths and item_url != url:
|
||||||
|
to_remove.append(item_id)
|
||||||
|
|
||||||
|
for item_id in to_remove:
|
||||||
|
await resource_collection.async_delete_item(item_id)
|
||||||
|
_LOGGER.info("Removed legacy/duplicate OpenClaw Lovelace resource id=%s", item_id)
|
||||||
|
|
||||||
existing_urls = {item["url"] for item in resource_collection.async_items()}
|
existing_urls = {item["url"] for item in resource_collection.async_items()}
|
||||||
if url in existing_urls:
|
if url in existing_urls:
|
||||||
_LOGGER.debug("Lovelace resource already registered: %s", url)
|
_LOGGER.debug("Lovelace resource already registered: %s", url)
|
||||||
|
|||||||
@@ -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.20",
|
"version": "0.1.21",
|
||||||
"dependencies": ["conversation"],
|
"dependencies": ["conversation"],
|
||||||
"after_dependencies": ["hassio", "lovelace"]
|
"after_dependencies": ["hassio", "lovelace"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user