custom_components/bahmcloud_store/__init__.py gelöscht
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.components import frontend
|
||||
|
||||
from .core import DOMAIN, BahmcloudStore, StoreConfig
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||
# Read configuration from configuration.yaml:
|
||||
# bahmcloud_store:
|
||||
# store_url: "https://....../store.yaml"
|
||||
domain_cfg = config.get(DOMAIN) or {}
|
||||
|
||||
store_url = None
|
||||
if isinstance(domain_cfg, dict):
|
||||
store_url = domain_cfg.get("store_url") or domain_cfg.get("store") or domain_cfg.get("url")
|
||||
|
||||
if not store_url or not isinstance(store_url, str):
|
||||
_LOGGER.error(
|
||||
"Missing configuration for %s. Please set %s: {store_url: 'https://.../store.yaml'}",
|
||||
DOMAIN,
|
||||
DOMAIN,
|
||||
)
|
||||
return False
|
||||
|
||||
store = BahmcloudStore(hass, StoreConfig(store_url=store_url))
|
||||
|
||||
# Register API + static panel assets (these are defined in core.py)
|
||||
await store.register_http_views()
|
||||
|
||||
# Store reference
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN]["store"] = store
|
||||
|
||||
# Register sidebar panel (compat layer for different HA versions)
|
||||
panel_js = "/api/bahmcloud_store_static/panel.js"
|
||||
try:
|
||||
# Some HA versions use module_url
|
||||
frontend.async_register_panel(
|
||||
hass,
|
||||
"custom",
|
||||
DOMAIN,
|
||||
sidebar_title="Bahmcloud Store",
|
||||
sidebar_icon="mdi:store",
|
||||
module_url=panel_js,
|
||||
config={},
|
||||
)
|
||||
except TypeError:
|
||||
# Fallback: some HA versions use js_url instead
|
||||
try:
|
||||
frontend.async_register_panel(
|
||||
hass,
|
||||
"custom",
|
||||
DOMAIN,
|
||||
sidebar_title="Bahmcloud Store",
|
||||
sidebar_icon="mdi:store",
|
||||
js_url=panel_js,
|
||||
config={},
|
||||
)
|
||||
except Exception as e:
|
||||
_LOGGER.warning("Panel registration failed (store will still work via API): %s", e)
|
||||
|
||||
return True
|
||||
Reference in New Issue
Block a user