diff --git a/custom_components/bahmcloud_store/update.py b/custom_components/bahmcloud_store/update.py index 1c07482..3ff058b 100644 --- a/custom_components/bahmcloud_store/update.py +++ b/custom_components/bahmcloud_store/update.py @@ -1,17 +1,38 @@ from __future__ import annotations -# NOTE: -# Update entities will be implemented once installation/provider resolution is in place. -# This stub prevents platform load errors and keeps the integration stable in 0.3.0. - from homeassistant.core import HomeAssistant -from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.entity import Entity +from homeassistant.const import Platform + +from .core import DOMAIN -async def async_setup_platform( - hass: HomeAssistant, - config, - async_add_entities: AddEntitiesCallback, - discovery_info=None, -): - return +async def async_setup_platform(hass: HomeAssistant, config, async_add_entities, discovery_info=None): + core = hass.data.get(DOMAIN) + if not core: + return + async_add_entities([BCSUpdateEntity(core)], True) + + +class BCSUpdateEntity(Entity): + _attr_should_poll = False + + def __init__(self, core) -> None: + self.core = core + self._attr_name = "Bahmcloud Store" + self._attr_unique_id = "bahmcloud_store_update" + self._attr_icon = "mdi:store" + + self._attr_installed_version = core.version + self._attr_latest_version = core.version # store updates remain manual via replacing files + + core.add_listener(self._handle_update) + + def _handle_update(self) -> None: + self._attr_installed_version = self.core.version + self._attr_latest_version = self.core.version + self.schedule_update_ha_state() + + @property + def entity_category(self): + return None