custom_components/bahmcloud_store/update.py aktualisiert
This commit is contained in:
@@ -17,16 +17,26 @@ async def async_setup_platform(
|
||||
store: BahmcloudStore = hass.data[DOMAIN]
|
||||
entities: dict[str, BahmcloudPackageUpdate] = {}
|
||||
|
||||
def should_have_update_entity(pkg: Package) -> bool:
|
||||
# Store selbst immer als Update
|
||||
if pkg.type == "store":
|
||||
return True
|
||||
# Andere Pakete nur, wenn installiert
|
||||
return store.is_installed(pkg.domain)
|
||||
|
||||
def rebuild_entities() -> None:
|
||||
# create entities for any new package in store.yaml
|
||||
# Create entities for packages that qualify
|
||||
for pkg in store.packages.values():
|
||||
if not should_have_update_entity(pkg):
|
||||
continue
|
||||
|
||||
uid = f"{DOMAIN}:{pkg.id}"
|
||||
if uid not in entities:
|
||||
ent = BahmcloudPackageUpdate(store, pkg.id)
|
||||
entities[uid] = ent
|
||||
async_add_entities([ent], update_before_add=True)
|
||||
|
||||
# refresh states
|
||||
# Refresh states
|
||||
for ent in entities.values():
|
||||
ent.async_write_ha_state()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user