custom_components/bahmcloud_store/__init__.py aktualisiert
This commit is contained in:
@@ -14,41 +14,12 @@ from .core import BCSCore, BCSConfig, BCSError
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "bahmcloud_store"
|
DOMAIN = "bahmcloud_store"
|
||||||
|
...
|
||||||
|
|
||||||
DEFAULT_STORE_URL = "https://git.bahmcloud.de/bahmcloud/ha_store/raw/branch/main/store.yaml"
|
|
||||||
CONF_STORE_URL = "store_url"
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
|
||||||
cfg = config.get(DOMAIN, {})
|
|
||||||
store_url = cfg.get(CONF_STORE_URL, DEFAULT_STORE_URL)
|
|
||||||
|
|
||||||
core = BCSCore(hass, BCSConfig(store_url=store_url))
|
|
||||||
hass.data[DOMAIN] = core
|
|
||||||
|
|
||||||
await core.register_http_views()
|
|
||||||
|
|
||||||
# RESTORE: keep the module_url pattern that worked for you
|
|
||||||
await async_register_panel(
|
|
||||||
hass,
|
|
||||||
frontend_url_path="bahmcloud-store",
|
|
||||||
webcomponent_name="bahmcloud-store-panel",
|
|
||||||
module_url="/api/bahmcloud_store_static/panel.js?v=42",
|
|
||||||
sidebar_title="Bahmcloud Store",
|
|
||||||
sidebar_icon="mdi:store",
|
|
||||||
require_admin=True,
|
|
||||||
config={},
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
await core.refresh()
|
|
||||||
except BCSError as e:
|
|
||||||
_LOGGER.error("Initial refresh failed: %s", e)
|
|
||||||
|
|
||||||
async def periodic(_now) -> None:
|
async def periodic(_now) -> None:
|
||||||
try:
|
try:
|
||||||
await core.refresh()
|
await core.full_refresh(source="timer")
|
||||||
core.signal_updated()
|
|
||||||
except BCSError as e:
|
except BCSError as e:
|
||||||
_LOGGER.warning("Periodic refresh failed: %s", e)
|
_LOGGER.warning("Periodic refresh failed: %s", e)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user