From 88c3233fd17b10394102efce38ec728dc7dadd8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Bachmann?= Date: Mon, 19 Jan 2026 07:14:58 +0000 Subject: [PATCH] 0.6.7 --- custom_components/bahmcloud_store/storage.py | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/custom_components/bahmcloud_store/storage.py b/custom_components/bahmcloud_store/storage.py index b1c88f0..ef31282 100644 --- a/custom_components/bahmcloud_store/storage.py +++ b/custom_components/bahmcloud_store/storage.py @@ -38,6 +38,7 @@ class BCSStorage: - installed_repos: mapping repo_id -> installed metadata - settings: persistent user settings (e.g. toggles in the UI) - hacs_cache: cached HACS metadata to improve UX (display names/descriptions) + - repo_cache: cached per-repo enrichment (names/descriptions/versions) to keep the UI populated after restart """ def __init__(self, hass: HomeAssistant) -> None: @@ -61,8 +62,46 @@ class BCSStorage: if "hacs_cache" not in data or not isinstance(data.get("hacs_cache"), dict): data["hacs_cache"] = {} + if "repo_cache" not in data or not isinstance(data.get("repo_cache"), dict): + data["repo_cache"] = {} + return data + async def get_repo_cache(self) -> dict[str, Any]: + """Return cached per-repo enrichment data. + + Shape: + { + "fetched_at": , + "repos": { + "": { + "ts": , + "url": "...", + "name": "...", + "provider_description": "...", + "meta_name": "...", + "meta_description": "...", + "meta_category": "...", + "meta_source": "...", + "latest_version": "...", + "latest_version_source": "...", + "default_branch": "...", + "owner": "...", + "provider_repo_name": "..." + } + } + } + """ + data = await self._load() + cache = data.get("repo_cache", {}) + return cache if isinstance(cache, dict) else {} + + async def set_repo_cache(self, cache: dict[str, Any]) -> None: + """Persist cached per-repo enrichment data.""" + data = await self._load() + data["repo_cache"] = cache if isinstance(cache, dict) else {} + await self._save(data) + async def get_hacs_cache(self) -> dict[str, Any]: """Return cached HACS metadata.