fix: retain Symcon webhook registration and show configured view title

This commit is contained in:
jhartworks committed 2026-11-10 12:39:30 +01:00
1 parent 8845efdc23
commit 510aece983
14 files changed
+145 -44

No files matched your search

+2 -1
View File
@@ -372,13 +372,14 @@ export class NextFloorPanel extends LitElement {
}
private renderHeader(building: Building | null) {
const title = this.hass?.symconTitle?.trim() || "NextFloor";
const saveState = this.data.saveState;
const tab = (mode: Mode, label: string, extra = "") =>
html`<button role="tab" class=${extra} aria-pressed=${this._mode === mode} @click=${() => this.setMode(mode)}>${label}</button>`;
const saveLabel: Key = saveState === "saving" ? "saving" : saveState === "saved" ? "saved" : "save_error";
return html`<header class="nf-header">
<ha-menu-button .hass=${this.hass} .narrow=${this.narrow}></ha-menu-button>
<h1>${NEXTFLOOR_MARK}NextFloor</h1>
<h1 title=${title}>${NEXTFLOOR_MARK}<span class="nf-view-title">${title}</span></h1>
${this.isAdmin ? html`<div class="nf-seg" role="tablist">${tab("view", this.t("view"))}${tab("editor", this.t("editor"))}${tab("extensions", `✦ ${this.t("ext_tab")}`, "nf-tab-ext")}</div>` : nothing}
<span class="nf-grow"></span>
${this._mode === "view" && building?.floors.some((f) => f.rooms.length) ? html`<button class="nf-chip nf-room-names-toggle" aria-pressed=${this._prefs.roomNames} title=${this.t("room_names_toggle_hint")} @click=${() => this.setPref("roomNames", !this._prefs.roomNames)}>${this.t("room_names_short")}</button>` : nothing}
+7
View File
@@ -52,10 +52,17 @@ export const panelStyles = css`
white-space: nowrap;
}
.nf-mark {
flex: none;
width: 26px;
height: 28px;
color: var(--nf-accent);
}
.nf-view-title {
min-width: 0;
max-width: min(340px, 45vw);
overflow: hidden;
text-overflow: ellipsis;
}
.nf-notices {
display: grid;
gap: 6px;
+9 -2
View File
@@ -4,15 +4,22 @@ import { SymconBridge } from "./symcon-bridge.ts";
import { entityOptions } from "./components/editor/entities.ts";
import { areaEntities } from "./entities/registry.ts";
function mockWindow(context: TestContext): void {
function mockWindow(context: TestContext, title?: string): void {
const previous = Object.getOwnPropertyDescriptor(globalThis, "window");
Object.defineProperty(globalThis, "window", { configurable: true, value: { __NEXTFLOOR_SYMCON__: { endpoint: "/hook/test", token: "fixture" } } });
Object.defineProperty(globalThis, "window", { configurable: true, value: { __NEXTFLOOR_SYMCON__: { endpoint: "/hook/test", token: "fixture", title } } });
context.after(() => {
if (previous) Object.defineProperty(globalThis, "window", previous);
else Reflect.deleteProperty(globalThis, "window");
});
}
test("configured view names are exposed to the header with a safe empty-name fallback", (context) => {
mockWindow(context, " Haus & Büro <West> ");
assert.equal(new SymconBridge().snapshot().symconTitle, "Haus & Büro <West>");
window.__NEXTFLOOR_SYMCON__!.title = " ";
assert.equal(new SymconBridge().snapshot().symconTitle, "NextFloor");
});
test("numeric control roles stay selectable in the real tree without duplicating automatic device lists", async (context) => {
mockWindow(context);
context.mock.method(globalThis, "fetch", async () => new Response(JSON.stringify({ state_revision: 1, building_revision: 1, areas: [{ area_id: "room", name: "Raum" }],
+1
View File
@@ -81,6 +81,7 @@ export class SymconBridge {
entities: this.entities,
areas: this.areas,
symconObjects: [],
symconTitle: this.settings.title?.trim() || "NextFloor",
symconRefresh: () => this.refresh(true),
config: { unit_system: { temperature: "°C" } },
themes: { darkMode: window.matchMedia?.("(prefers-color-scheme: dark)").matches ?? true },
+2
View File
@@ -76,6 +76,8 @@ export interface HomeAssistant {
devices?: Record<string, HassDevice>;
/** Present only in the Symcon host. The full native hierarchy, including non-variable nodes. */
symconObjects?: readonly SymconObject[];
/** Configured visualization name of this Symcon instance. */
symconTitle?: string;
/** Reload variables, effective presentations and the native object tree without reloading the plan. */
symconRefresh?: () => Promise<void>;
states: Record<string, HassEntity>;