diff --git a/custom_components/shade_engine/manifest.json b/custom_components/shade_engine/manifest.json index 204fe26..a97d2f4 100644 --- a/custom_components/shade_engine/manifest.json +++ b/custom_components/shade_engine/manifest.json @@ -10,5 +10,5 @@ "issue_tracker": "https://github.com/vfilby/shade-engine/issues", "requirements": [], "single_config_entry": true, - "version": "0.5.0" + "version": "0.5.1" } diff --git a/custom_components/shade_engine/www/shade-engine-card.js b/custom_components/shade_engine/www/shade-engine-card.js index e1e3c7b..2125831 100644 --- a/custom_components/shade_engine/www/shade-engine-card.js +++ b/custom_components/shade_engine/www/shade-engine-card.js @@ -15,7 +15,7 @@ * the history strip, graph_hours (default 24) sets its window. */ -const CARD_VERSION = "0.5.0"; +const CARD_VERSION = "0.5.1"; const RAD = Math.PI / 180; const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v)); @@ -473,7 +473,24 @@ class ShadeEngineCard extends HTMLElement { } } -customElements.define("shade-engine-card", ShadeEngineCard); +/* Register the element only once Home Assistant's app has booted. + * + * The integration loads this module via `extra_module_url`, which the index + * page imports concurrently with app.js. Since HA 2026.8 the frontend installs + * the scoped-custom-element-registry polyfill, which REPLACES + * window.customElements with a fresh registry; anything defined on the native + * registry before that swap is invisible to customElements.get() and the + * dashboard shows "Custom element doesn't exist". With a warm cache this + * module reliably wins that race and loses the registry, so wait for HA's root + * element and then define on whatever registry is current. */ +function registerCard() { + const registry = window.customElements; + if (registry.get("shade-engine-card")) return; + registry.define("shade-engine-card", ShadeEngineCard); +} +customElements + .whenDefined("home-assistant") + .then(registerCard, registerCard); window.customCards = window.customCards || []; window.customCards.push({