Fix 0.5.4 to. 5

This commit is contained in:
2026-01-16 20:15:11 +00:00
parent 2c8ca490ea
commit 30258bd2c0

View File

@@ -26,7 +26,6 @@ def _pretty_repo_name(core: BCSCore, repo_id: str) -> str:
except Exception: except Exception:
pass pass
# Fallbacks
if repo_id.startswith("index:"): if repo_id.startswith("index:"):
return f"BCS Index {repo_id.split(':', 1)[1]}" return f"BCS Index {repo_id.split(':', 1)[1]}"
if repo_id.startswith("custom:"): if repo_id.startswith("custom:"):
@@ -53,11 +52,11 @@ class BCSRepoUpdateEntity(UpdateEntity):
# Stable unique id (do NOT change) # Stable unique id (do NOT change)
self._attr_unique_id = f"{DOMAIN}:{repo_id}" self._attr_unique_id = f"{DOMAIN}:{repo_id}"
# Human-friendly name in UI self._refresh_display_name()
pretty = _pretty_repo_name(core, repo_id)
self._attr_name = pretty
# 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 self._attr_title = pretty
@property @property
@@ -102,9 +101,7 @@ class BCSRepoUpdateEntity(UpdateEntity):
async def async_install(self, version: str | None, backup: bool, **kwargs: Any) -> None: async def async_install(self, version: str | None, backup: bool, **kwargs: Any) -> None:
if version is not None: if version is not None:
_LOGGER.debug( _LOGGER.debug("BCS update entity requested specific version=%s (ignored)", version)
"BCS update entity requested specific version=%s (ignored)", version
)
self._in_progress = True self._in_progress = True
self.async_write_ha_state() self.async_write_ha_state()
@@ -117,19 +114,18 @@ class BCSRepoUpdateEntity(UpdateEntity):
@callback @callback
def _sync_entities( def _sync_entities(core: BCSCore, existing: dict[str, BCSRepoUpdateEntity], async_add_entities: AddEntitiesCallback) -> None:
core: BCSCore, """Ensure there is one update entity per installed repo AND keep names in sync."""
existing: dict[str, BCSRepoUpdateEntity],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Ensure there is one update entity per installed repo."""
installed_map = getattr(core, "_installed_cache", {}) or {} installed_map = getattr(core, "_installed_cache", {}) or {}
new_entities: list[BCSRepoUpdateEntity] = [] new_entities: list[BCSRepoUpdateEntity] = []
for repo_id, data in installed_map.items(): for repo_id, data in installed_map.items():
if not isinstance(data, dict): if not isinstance(data, dict):
continue continue
if repo_id in existing: if repo_id in existing:
# IMPORTANT: Update display name after refresh, when repo.name becomes available.
existing[repo_id]._refresh_display_name()
continue continue
ent = BCSRepoUpdateEntity(core, repo_id) ent = BCSRepoUpdateEntity(core, repo_id)