0.6.9
This commit is contained in:
@@ -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")
|
||||
@@ -160,3 +156,22 @@ async def async_setup_platform(
|
||||
_sync_entities(core, entities, async_add_entities)
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user