..
This commit is contained in:
@@ -24,11 +24,17 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
|||||||
core = BCSCore(hass, BCSConfig(store_url=store_url))
|
core = BCSCore(hass, BCSConfig(store_url=store_url))
|
||||||
hass.data[DOMAIN] = core
|
hass.data[DOMAIN] = core
|
||||||
|
|
||||||
# Avoid blocking IO during setup
|
|
||||||
await core.async_initialize()
|
await core.async_initialize()
|
||||||
|
|
||||||
# Register HTTP views and panel
|
from .views import (
|
||||||
from .views import StaticAssetsView, BCSApiView, BCSReadmeView, BCSCustomRepoView, BCSInstallView, BCSUpdateView, BCSRestartView
|
StaticAssetsView,
|
||||||
|
BCSApiView,
|
||||||
|
BCSReadmeView,
|
||||||
|
BCSCustomRepoView,
|
||||||
|
BCSInstallView,
|
||||||
|
BCSUpdateView,
|
||||||
|
BCSRestartView,
|
||||||
|
)
|
||||||
|
|
||||||
hass.http.register_view(StaticAssetsView())
|
hass.http.register_view(StaticAssetsView())
|
||||||
hass.http.register_view(BCSApiView(core))
|
hass.http.register_view(BCSApiView(core))
|
||||||
@@ -42,14 +48,14 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
|||||||
hass,
|
hass,
|
||||||
frontend_url_path="bahmcloud-store",
|
frontend_url_path="bahmcloud-store",
|
||||||
webcomponent_name="bahmcloud-store-panel",
|
webcomponent_name="bahmcloud-store-panel",
|
||||||
module_url="/api/bahmcloud_store_static/panel.js?v=99",
|
# IMPORTANT: bump v to avoid caching old JS
|
||||||
|
module_url="/api/bahmcloud_store_static/panel.js?v=101",
|
||||||
sidebar_title="Bahmcloud Store",
|
sidebar_title="Bahmcloud Store",
|
||||||
sidebar_icon="mdi:store",
|
sidebar_icon="mdi:store",
|
||||||
require_admin=True,
|
require_admin=True,
|
||||||
config={},
|
config={},
|
||||||
)
|
)
|
||||||
|
|
||||||
# Initial refresh
|
|
||||||
try:
|
try:
|
||||||
await core.full_refresh(source="startup")
|
await core.full_refresh(source="startup")
|
||||||
except BCSError as e:
|
except BCSError as e:
|
||||||
@@ -60,7 +66,7 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
|||||||
await core.full_refresh(source="timer")
|
await core.full_refresh(source="timer")
|
||||||
except BCSError as e:
|
except BCSError as e:
|
||||||
_LOGGER.warning("Periodic refresh failed: %s", e)
|
_LOGGER.warning("Periodic refresh failed: %s", e)
|
||||||
except Exception as e:
|
except Exception as e: # pylint: disable=broad-exception-caught
|
||||||
_LOGGER.exception("Unexpected error during periodic refresh: %s", e)
|
_LOGGER.exception("Unexpected error during periodic refresh: %s", e)
|
||||||
|
|
||||||
interval_seconds = int(getattr(core, "refresh_seconds", 300) or 300)
|
interval_seconds = int(getattr(core, "refresh_seconds", 300) or 300)
|
||||||
|
|||||||
Reference in New Issue
Block a user