custom_components/bahmcloud_store/__init__.py aktualisiert
This commit is contained in:
@@ -18,16 +18,23 @@ CONF_STORE_URL = "store_url"
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||
"""Set up the Bahmcloud Store integration."""
|
||||
cfg = config.get(DOMAIN, {}) or {}
|
||||
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()
|
||||
# Avoid blocking IO during setup
|
||||
await core.async_initialize()
|
||||
|
||||
# Register HTTP views and panel
|
||||
from .views import StaticAssetsView, BCSApiView, BCSReadmeView, BCSCustomRepoView
|
||||
|
||||
hass.http.register_view(StaticAssetsView())
|
||||
hass.http.register_view(BCSApiView(core))
|
||||
hass.http.register_view(BCSReadmeView(core))
|
||||
hass.http.register_view(BCSCustomRepoView(core))
|
||||
|
||||
# Keep the exact module_url pattern that worked reliably (cache-busted via v=42)
|
||||
await async_register_panel(
|
||||
hass,
|
||||
frontend_url_path="bahmcloud-store",
|
||||
@@ -39,7 +46,7 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||
config={},
|
||||
)
|
||||
|
||||
# Initial load at startup
|
||||
# Initial refresh
|
||||
try:
|
||||
await core.full_refresh(source="startup")
|
||||
except BCSError as e:
|
||||
@@ -53,7 +60,6 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||
except Exception as e:
|
||||
_LOGGER.exception("Unexpected error during periodic refresh: %s", e)
|
||||
|
||||
# Start with the configured refresh interval (default: 300 seconds)
|
||||
interval_seconds = int(getattr(core, "refresh_seconds", 300) or 300)
|
||||
async_track_time_interval(hass, periodic, timedelta(seconds=interval_seconds))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user