diff --git a/custom_components/bahmcloud_store/update.py b/custom_components/bahmcloud_store/update.py index 371f3d7..17ac795 100644 --- a/custom_components/bahmcloud_store/update.py +++ b/custom_components/bahmcloud_store/update.py @@ -5,6 +5,7 @@ from dataclasses import dataclass from typing import Any from homeassistant.components.update import UpdateEntity, UpdateEntityFeature +from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -139,13 +140,8 @@ def _sync_entities(core: BCSCore, existing: dict[str, BCSRepoUpdateEntity], asyn ent.async_write_ha_state() -async def async_setup_platform( - hass: HomeAssistant, - config, - async_add_entities: AddEntitiesCallback, - discovery_info=None, -): - """Set up BCS update entities.""" +async def _async_setup(hass: HomeAssistant, async_add_entities: AddEntitiesCallback) -> None: + """Common update entity setup for both config entries and legacy YAML.""" core: BCSCore | None = hass.data.get(DOMAIN) if not core: _LOGGER.debug("BCS core not available, skipping update platform setup") @@ -159,4 +155,23 @@ async def async_setup_platform( def _handle_update() -> None: _sync_entities(core, entities, async_add_entities) - async_dispatcher_connect(hass, SIGNAL_UPDATED, _handle_update) \ No newline at end of file + async_dispatcher_connect(hass, SIGNAL_UPDATED, _handle_update) + + +async def async_setup_entry( + hass: HomeAssistant, + entry: ConfigEntry, + async_add_entities: AddEntitiesCallback, +) -> None: + """Set up update entities from a config entry.""" + await _async_setup(hass, async_add_entities) + + +async def async_setup_platform( + hass: HomeAssistant, + config, + async_add_entities: AddEntitiesCallback, + discovery_info=None, +): + """Legacy YAML setup (not supported, kept for safety).""" + await _async_setup(hass, async_add_entities) \ No newline at end of file