first push
This commit is contained in:
commit
2a81b4a502
845 files changed
+356635
No files matched your search
@@ -0,0 +1,36 @@
|
||||
// Entry point served by the IP-Symcon WebHook. It mounts the existing panel in the console designer and
|
||||
// the existing dashboard card inside the HTML-SDK tile iframe.
|
||||
|
||||
import "./main.ts";
|
||||
import { SymconBridge } from "./symcon-bridge.ts";
|
||||
import type { HomeAssistant } from "./types.ts";
|
||||
|
||||
type SymconPanel = HTMLElement & { hass: HomeAssistant; narrow: boolean };
|
||||
type SymconCard = HTMLElement & { hass: HomeAssistant; setConfig(config: Record<string, unknown>): void };
|
||||
|
||||
function pageMode(): "designer" | "tile" {
|
||||
return new URLSearchParams(window.location.search).get("mode") === "tile" ? "tile" : "designer";
|
||||
}
|
||||
|
||||
async function mount(): Promise<void> {
|
||||
const bridge = new SymconBridge();
|
||||
const hass = await bridge.start();
|
||||
const tile = pageMode() === "tile";
|
||||
const app = (tile ? document.createElement("nextfloor-card") : document.createElement("nextfloor-panel")) as SymconCard & SymconPanel;
|
||||
app.className = tile ? "nf-symcon-tile" : "nf-symcon-designer";
|
||||
app.hass = hass;
|
||||
if (tile) {
|
||||
(app as SymconCard).setConfig({ type: "custom:nextfloor-card", fill: true, room_buttons: true, controls: true, weather: false, announcements: false });
|
||||
} else {
|
||||
(app as SymconPanel).narrow = false;
|
||||
}
|
||||
document.body.replaceChildren(app);
|
||||
bridge.onChange(() => {
|
||||
app.hass = bridge.snapshot();
|
||||
});
|
||||
window.addEventListener("pagehide", () => bridge.stop(), { once: true });
|
||||
}
|
||||
|
||||
void mount().catch((error: unknown) => {
|
||||
document.body.textContent = `NextFloor konnte nicht geladen werden: ${error instanceof Error ? error.message : String(error)}`;
|
||||
});
|
||||
Reference in new issue
Block a user