|
@@ -66,12 +66,14 @@ async def _async_register_frontend(hass: HomeAssistant) -> None:
|
|
|
_LOGGER.debug("Static path %s already registered: %s", _CARD_URL, err)
|
|
_LOGGER.debug("Static path %s already registered: %s", _CARD_URL, err)
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
- from homeassistant.components.frontend import async_register_extra_module_url
|
|
|
|
|
- async_register_extra_module_url(hass, _CARD_URL)
|
|
|
|
|
- _LOGGER.debug("Registered Lovelace module: %s", _CARD_URL)
|
|
|
|
|
|
|
+ lovelace = hass.data["lovelace"]
|
|
|
|
|
+ resources = lovelace["resources"]
|
|
|
|
|
+ if not any(r.get("url") == _CARD_URL for r in resources.async_items()):
|
|
|
|
|
+ await resources.async_create_item({"res_type": "module", "url": _CARD_URL})
|
|
|
|
|
+ _LOGGER.debug("Registered Lovelace resource: %s", _CARD_URL)
|
|
|
except Exception as err:
|
|
except Exception as err:
|
|
|
_LOGGER.error(
|
|
_LOGGER.error(
|
|
|
- "Failed to register Lovelace card module %s: %s. "
|
|
|
|
|
|
|
+ "Failed to register Lovelace card resource %s: %s. "
|
|
|
"Add it manually: Settings → Dashboards → ⋮ → Resources → Add Resource, "
|
|
"Add it manually: Settings → Dashboards → ⋮ → Resources → Add Resource, "
|
|
|
"URL: %s, Resource type: JavaScript module.",
|
|
"URL: %s, Resource type: JavaScript module.",
|
|
|
_CARD_URL, err, _CARD_URL,
|
|
_CARD_URL, err, _CARD_URL,
|