From 30258bd2c055a84ad4cf80ca2d680b6ee19bc5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Bachmann?= Date: Fri, 16 Jan 2026 20:15:11 +0000 Subject: [PATCH] Fix 0.5.4 to. 5 --- custom_components/bahmcloud_store/update.py | 24 +++++++++------------ 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/custom_components/bahmcloud_store/update.py b/custom_components/bahmcloud_store/update.py index efbff00..371f3d7 100644 --- a/custom_components/bahmcloud_store/update.py +++ b/custom_components/bahmcloud_store/update.py @@ -26,7 +26,6 @@ def _pretty_repo_name(core: BCSCore, repo_id: str) -> str: except Exception: pass - # Fallbacks if repo_id.startswith("index:"): return f"BCS Index {repo_id.split(':', 1)[1]}" if repo_id.startswith("custom:"): @@ -53,11 +52,11 @@ class BCSRepoUpdateEntity(UpdateEntity): # Stable unique id (do NOT change) self._attr_unique_id = f"{DOMAIN}:{repo_id}" - # Human-friendly name in UI - pretty = _pretty_repo_name(core, repo_id) - self._attr_name = pretty + self._refresh_display_name() - # Title shown in the entity dialog + def _refresh_display_name(self) -> None: + pretty = _pretty_repo_name(self._core, self._repo_id) + self._attr_name = pretty self._attr_title = pretty @property @@ -102,9 +101,7 @@ class BCSRepoUpdateEntity(UpdateEntity): async def async_install(self, version: str | None, backup: bool, **kwargs: Any) -> None: if version is not None: - _LOGGER.debug( - "BCS update entity requested specific version=%s (ignored)", version - ) + _LOGGER.debug("BCS update entity requested specific version=%s (ignored)", version) self._in_progress = True self.async_write_ha_state() @@ -117,19 +114,18 @@ class BCSRepoUpdateEntity(UpdateEntity): @callback -def _sync_entities( - core: BCSCore, - existing: dict[str, BCSRepoUpdateEntity], - async_add_entities: AddEntitiesCallback, -) -> None: - """Ensure there is one update entity per installed repo.""" +def _sync_entities(core: BCSCore, existing: dict[str, BCSRepoUpdateEntity], async_add_entities: AddEntitiesCallback) -> None: + """Ensure there is one update entity per installed repo AND keep names in sync.""" installed_map = getattr(core, "_installed_cache", {}) or {} new_entities: list[BCSRepoUpdateEntity] = [] for repo_id, data in installed_map.items(): if not isinstance(data, dict): continue + if repo_id in existing: + # IMPORTANT: Update display name after refresh, when repo.name becomes available. + existing[repo_id]._refresh_display_name() continue ent = BCSRepoUpdateEntity(core, repo_id)