diff --git a/custom_components/bahmcloud_store/storage.py b/custom_components/bahmcloud_store/storage.py index ca99c1c..b1c88f0 100644 --- a/custom_components/bahmcloud_store/storage.py +++ b/custom_components/bahmcloud_store/storage.py @@ -37,6 +37,7 @@ class BCSStorage: - custom_repos: list of manually added repositories - 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) """ def __init__(self, hass: HomeAssistant) -> None: @@ -57,8 +58,30 @@ class BCSStorage: if "settings" not in data or not isinstance(data.get("settings"), dict): data["settings"] = {} + if "hacs_cache" not in data or not isinstance(data.get("hacs_cache"), dict): + data["hacs_cache"] = {} + return data + async def get_hacs_cache(self) -> dict[str, Any]: + """Return cached HACS metadata. + + Shape: + { + "fetched_at": , + "repos": {"owner/repo": {"name": "...", "description": "...", "domain": "..."}} + } + """ + data = await self._load() + cache = data.get("hacs_cache", {}) + return cache if isinstance(cache, dict) else {} + + async def set_hacs_cache(self, cache: dict[str, Any]) -> None: + """Persist cached HACS metadata.""" + data = await self._load() + data["hacs_cache"] = cache if isinstance(cache, dict) else {} + await self._save(data) + async def get_settings(self) -> dict[str, Any]: """Return persistent settings.