feat: release Symcon 0.2.2 with object tree selection and hook recovery
This commit is contained in:
1 parent
4a875aa8ea
commit
eff9eb83d7
19 files changed
+2273
-1064
No files matched your search
@@ -4,8 +4,17 @@ All notable changes to NextFloor, newest first. Every release lists what is **Ad
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- **IP-Symcon object-tree picker:** Data point fields open a modal dialog with the real Symcon hierarchy, including instances, links, hidden objects and empty categories, ordered as in the console. Search keeps matching objects in their original branches; confirmation, cancellation and keyboard navigation are supported.
|
||||
|
||||
### Changed
|
||||
|
||||
- **IP-Symcon picker main category:** Hidden categories and their variables always remain visible. I/O, splitter, core, configurator, discovery and visualization instances are grouped under a collapsed virtual “System” folder, with searchable/selectable descendants and no changes to the actual Symcon object tree.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **IP-Symcon “Hook not found”:** The module restores its internal WebHook after kernel startup and before opening the designer or tile, reports registration failures instead of showing “ready”, retries failed registrations and offers a “Repair WebHook” button without replacing the instance or its saved project.
|
||||
- **IP-Symcon module discovery:** NextFloor is registered as a regular device instance with complete module metadata, so it is available in “Add instance”. The independent HTML-SDK tile remains enabled. A package check now rejects invalid module types, missing manifest fields and an incorrect installation directory layout before building.
|
||||
- **IP-Symcon designer version check:** The frontend uses the Symcon library version rather than the Home Assistant integration version, preventing an incorrect Home Assistant restart prompt.
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -3278,7 +3278,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
|
||||
inset: auto 16px 16px;
|
||||
color: var(--nf-danger);
|
||||
}
|
||||
`]};customElements.get("nf-view3d")||customElements.define("nf-view3d",li);function se(r,e){return Math.abs(e)>=1e3?`${O(r,e/1e3,1)} kW`:`${Math.round(e)} W`}function ai(r){return r.type==="tv_board"?r.h+.9:r.type==="tv_wall"||r.type==="kitchen_wall"?r.h+.25:r.h+.35}function gm(r,e){let t=e.attributes.percentage;return e.state==="on"&&typeof t=="number"?`${Math.round(t)} %`:ee(r,e)}var Mu;function $u(){let r=new URL("./nextfloor-editor.js?v=85ae4159b3e8",new URL(import.meta.url)).href;return Mu??=import(r),Mu}var _m=.25,Au=r=>Math.round(r*1e3)/1e3,Eu=(r,e,t)=>r.rooms.find(n=>n.points.length>=3&&H([e,t],n.points));function ci(r,e,t,n,o){let i=Eu(r,e,t);if(!i)return[n,o];let s=(a,l)=>H([a,l],i.points);return s(n,o)?[n,o]:s(n,t)?[n,t]:s(e,o)?[e,o]:[e,t]}function bm(r,e,t,n){return r.rooms.some(o=>o.id!==e.id&&o.points.some((i,s)=>{let a=o.points[(s+1)%o.points.length];return Math.abs(oe(Z(i,t),n))<.02&&Math.abs(oe(Z(a,t),n))<.02}))}var ui=(r,e)=>Math.abs((r-e+540)%360-180);function zu(r,e,t,n=_m){let o=Eu(r,e.x,e.z);if(!o)return null;let i=o.points,s=et(i)>=0?1:-1,a=null;return i.forEach((l,u)=>{let c=i[(u+1)%i.length],d=Te(Z(c,l));if(d<.3)return;let p=[(c[0]-l[0])/d,(c[1]-l[1])/d],h=[-p[1]*s,p[0]*s],w=oe(Z([e.x,e.z],l),p);if(w<0||w>d)return;let b=bm(r,o,l,h)?t/2:0,g=oe(Z([e.x,e.z],l),h)-b,_=Math.atan2(-h[0],h[1])*180/Math.PI,$=[{rotation:_,extent:e.d/2},{rotation:_+90,extent:e.w/2},{rotation:_-90,extent:e.w/2}].reduce((y,F)=>ui(e.rotation,F.rotation)<ui(e.rotation,y.rotation)?F:y);if(ui(e.rotation,$.rotation)>50)return;let x=g-$.extent;Math.abs(x)>n||a&&Math.abs(x)>=Math.abs(a.gap)||(a={x:Au(e.x-h[0]*x),z:Au(e.z-h[1]*x),rotation:(Math.round($.rotation)%360+360)%360,gap:x})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}function Er(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.furniture.find(s=>s.id===e);i&&t(i,o)}return n}function zr(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.placements.find(s=>s.entity_id===e);i&&t(i,o)}return n}function Ru(r,e){let t=structuredClone(r);for(let n of t.floors)n.furniture=n.furniture.filter(o=>o.id!==e);return t}function Tu(r,e){let t=structuredClone(r);for(let n of t.floors)n.placements=n.placements.filter(o=>o.entity_id!==e);return t}function Fu(r,e,t,n){return zr(r,e,(o,i)=>{[o.x,o.z]=ci(i,o.x,o.z,t,n)})}function Du(r,e,t,n){let o=r.settings.wall_interior??.12;return Er(r,e,(i,s)=>{[i.x,i.z]=ci(s,i.x,i.z,t,n);let a=zu(s,i,o);a&&Object.assign(i,a)})}var di=(r,e)=>((r+e)%360+360)%360,Pu=r=>Number.parseFloat(r.replace(",",".")),wn=(r,e)=>Math.round(r*10**e)/10**e;function hi(r){let{min:e,max:t,accepts:n=()=>!0}=r,o=i=>{let s=Pu(i.target.value);!Number.isFinite(s)||!n(s)||r.apply(t===void 0?s:Math.min(t,Math.max(e,s)))};return m`<label class="nf-size" title=${r.title}
|
||||
`]};customElements.get("nf-view3d")||customElements.define("nf-view3d",li);function se(r,e){return Math.abs(e)>=1e3?`${O(r,e/1e3,1)} kW`:`${Math.round(e)} W`}function ai(r){return r.type==="tv_board"?r.h+.9:r.type==="tv_wall"||r.type==="kitchen_wall"?r.h+.25:r.h+.35}function gm(r,e){let t=e.attributes.percentage;return e.state==="on"&&typeof t=="number"?`${Math.round(t)} %`:ee(r,e)}var Mu;function $u(){let r=new URL("./nextfloor-editor.js?v=37bfd8f9f2b7",new URL(import.meta.url)).href;return Mu??=import(r),Mu}var _m=.25,Au=r=>Math.round(r*1e3)/1e3,Eu=(r,e,t)=>r.rooms.find(n=>n.points.length>=3&&H([e,t],n.points));function ci(r,e,t,n,o){let i=Eu(r,e,t);if(!i)return[n,o];let s=(a,l)=>H([a,l],i.points);return s(n,o)?[n,o]:s(n,t)?[n,t]:s(e,o)?[e,o]:[e,t]}function bm(r,e,t,n){return r.rooms.some(o=>o.id!==e.id&&o.points.some((i,s)=>{let a=o.points[(s+1)%o.points.length];return Math.abs(oe(Z(i,t),n))<.02&&Math.abs(oe(Z(a,t),n))<.02}))}var ui=(r,e)=>Math.abs((r-e+540)%360-180);function zu(r,e,t,n=_m){let o=Eu(r,e.x,e.z);if(!o)return null;let i=o.points,s=et(i)>=0?1:-1,a=null;return i.forEach((l,u)=>{let c=i[(u+1)%i.length],d=Te(Z(c,l));if(d<.3)return;let p=[(c[0]-l[0])/d,(c[1]-l[1])/d],h=[-p[1]*s,p[0]*s],w=oe(Z([e.x,e.z],l),p);if(w<0||w>d)return;let b=bm(r,o,l,h)?t/2:0,g=oe(Z([e.x,e.z],l),h)-b,_=Math.atan2(-h[0],h[1])*180/Math.PI,$=[{rotation:_,extent:e.d/2},{rotation:_+90,extent:e.w/2},{rotation:_-90,extent:e.w/2}].reduce((y,F)=>ui(e.rotation,F.rotation)<ui(e.rotation,y.rotation)?F:y);if(ui(e.rotation,$.rotation)>50)return;let x=g-$.extent;Math.abs(x)>n||a&&Math.abs(x)>=Math.abs(a.gap)||(a={x:Au(e.x-h[0]*x),z:Au(e.z-h[1]*x),rotation:(Math.round($.rotation)%360+360)%360,gap:x})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}function Er(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.furniture.find(s=>s.id===e);i&&t(i,o)}return n}function zr(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.placements.find(s=>s.entity_id===e);i&&t(i,o)}return n}function Ru(r,e){let t=structuredClone(r);for(let n of t.floors)n.furniture=n.furniture.filter(o=>o.id!==e);return t}function Tu(r,e){let t=structuredClone(r);for(let n of t.floors)n.placements=n.placements.filter(o=>o.entity_id!==e);return t}function Fu(r,e,t,n){return zr(r,e,(o,i)=>{[o.x,o.z]=ci(i,o.x,o.z,t,n)})}function Du(r,e,t,n){let o=r.settings.wall_interior??.12;return Er(r,e,(i,s)=>{[i.x,i.z]=ci(s,i.x,i.z,t,n);let a=zu(s,i,o);a&&Object.assign(i,a)})}var di=(r,e)=>((r+e)%360+360)%360,Pu=r=>Number.parseFloat(r.replace(",",".")),wn=(r,e)=>Math.round(r*10**e)/10**e;function hi(r){let{min:e,max:t,accepts:n=()=>!0}=r,o=i=>{let s=Pu(i.target.value);!Number.isFinite(s)||!n(s)||r.apply(t===void 0?s:Math.min(t,Math.max(e,s)))};return m`<label class="nf-size" title=${r.title}
|
||||
>${r.label}
|
||||
<input type="number" inputmode="decimal" step=${r.step} min=${e} max=${t??f} .value=${String(wn(r.value,2))} @change=${o} />
|
||||
</label>`}var Iu=(r,e)=>m`<button class="nf-chip" @click=${e}>${r.t("height_auto")}</button>`,Hu=(r,e)=>m`<button class="nf-chip" @click=${()=>e(-r)}>↺ ${r}°</button><button class="nf-chip" @click=${()=>e(r)}>↻ ${r}°</button>`;function wm(r,e){let t=r.building.floors.find(s=>s.furniture.some(a=>a.id===e)),n=t?.furniture.find(s=>s.id===e);if(!t||!n)return f;let o=(s,a)=>hi({label:r.t(a),title:r.t(`size_${s}`),value:n[s],step:.05,min:.05,accepts:l=>l>0,apply:l=>r.editFurniture(e,u=>u[s]=wn(l,3))}),i=hs(n)?m`${hi({label:"\u2195",title:r.t("mount_height"),value:n.mount_y??le(t,n),step:.05,min:0,accepts:s=>s>=0,apply:s=>r.editFurniture(e,a=>a.mount_y=wn(s,3))})}
|
||||
|
||||
@@ -96,6 +96,7 @@ export function entityField(host: EditorHost, label: string, value: string | nul
|
||||
>${label}
|
||||
<nf-entity-picker
|
||||
.options=${options}
|
||||
.objectTree=${host.hass?.symconObjects}
|
||||
.fixed=${fixed}
|
||||
.value=${current}
|
||||
.placeholder=${host.t("entity_search")}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { tokens } from "../styles.ts";
|
||||
import type { SymconObject } from "../types.ts";
|
||||
import "./symcon-object-picker.ts";
|
||||
|
||||
export interface PickerOption {
|
||||
id: string;
|
||||
@@ -17,6 +19,7 @@ const MAX_SHOWN = 40;
|
||||
export class EntityPicker extends LitElement {
|
||||
static properties = {
|
||||
options: { attribute: false },
|
||||
objectTree: { attribute: false },
|
||||
fixed: { attribute: false },
|
||||
value: { attribute: false },
|
||||
disabled: { type: Boolean },
|
||||
@@ -28,6 +31,7 @@ export class EntityPicker extends LitElement {
|
||||
|
||||
/** Entities to choose from. */
|
||||
declare options: PickerOption[];
|
||||
declare objectTree: readonly SymconObject[] | undefined;
|
||||
/** Choices shown before the entities (e.g. automatic, none); ids must not look like entity ids. */
|
||||
declare fixed: PickerOption[];
|
||||
/** The chosen id (an option's or a fixed choice's). */
|
||||
@@ -42,6 +46,7 @@ export class EntityPicker extends LitElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.options = [];
|
||||
this.objectTree = undefined;
|
||||
this.fixed = [];
|
||||
this.value = null;
|
||||
this.disabled = false;
|
||||
@@ -105,6 +110,11 @@ export class EntityPicker extends LitElement {
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (this.objectTree !== undefined) return html`<nf-symcon-object-picker
|
||||
.objects=${this.objectTree} .options=${this.options} .fixed=${this.fixed} .value=${this.value}
|
||||
.disabled=${this.disabled} .placeholder=${this.placeholder}
|
||||
@change=${(event: CustomEvent<{ value: string }>) => { this.value = event.detail.value; }}
|
||||
></nf-symcon-object-picker>`;
|
||||
const current = this.current;
|
||||
const hits = this._open ? this.hits : [];
|
||||
return html`<div class="wrap">
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
// Native modal dialog with the actual Symcon object hierarchy. Numeric IDs never become input fields.
|
||||
import { css, html, LitElement, nothing, svg, type PropertyValues } from "lit";
|
||||
import { repeat } from "lit/directives/repeat.js";
|
||||
import { tokens } from "../styles.ts";
|
||||
import type { SymconObject } from "../types.ts";
|
||||
import type { PickerOption } from "./entity-picker.ts";
|
||||
import { indexSymconTree, symconAncestors, symconTreeRows, type SymconTree, type SymconTreeRow } from "./symcon-tree.ts";
|
||||
|
||||
const TYPES = ["Kategorie", "Instanz", "Variable", "Skript", "Ereignis", "Medium", "Link"];
|
||||
|
||||
export class SymconObjectPicker extends LitElement {
|
||||
static properties = {
|
||||
objects: { attribute: false }, options: { attribute: false }, fixed: { attribute: false },
|
||||
value: { attribute: false }, disabled: { type: Boolean }, placeholder: { attribute: false },
|
||||
_query: { state: true }, _expanded: { state: true }, _pending: { state: true }, _active: { state: true }, _selected: { state: true },
|
||||
};
|
||||
|
||||
declare objects: readonly SymconObject[];
|
||||
declare options: PickerOption[];
|
||||
declare fixed: PickerOption[];
|
||||
declare value: string | null;
|
||||
declare disabled: boolean;
|
||||
declare placeholder: string;
|
||||
private declare _query: string;
|
||||
private declare _expanded: Set<number>;
|
||||
private declare _pending: string | null;
|
||||
private declare _active: number | null;
|
||||
private declare _selected: number | null;
|
||||
private tree: SymconTree = indexSymconTree([]);
|
||||
private allowed = new Map<string, PickerOption>();
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.objects = [];
|
||||
this.options = [];
|
||||
this.fixed = [];
|
||||
this.value = null;
|
||||
this.disabled = false;
|
||||
this.placeholder = "Datenpunkt auswählen";
|
||||
this._query = "";
|
||||
this._expanded = new Set();
|
||||
this._pending = null;
|
||||
this._active = null;
|
||||
this._selected = null;
|
||||
}
|
||||
|
||||
protected willUpdate(changed: PropertyValues): void {
|
||||
if (changed.has("objects")) this.tree = indexSymconTree(this.objects);
|
||||
if (changed.has("options") || changed.has("fixed")) this.allowed = new Map([...this.fixed, ...this.options].map((option) => [option.id, option]));
|
||||
}
|
||||
|
||||
private get dialog(): HTMLDialogElement | null { return this.renderRoot.querySelector("dialog"); }
|
||||
|
||||
private variableNode(entity: string | null): SymconObject | undefined {
|
||||
const native = this.objects.find((node) => node.entity_id === entity && node.object_type === 2);
|
||||
return native ? this.tree.nodes.get(native.object_id) : undefined;
|
||||
}
|
||||
|
||||
private async open(): Promise<void> {
|
||||
if (this.disabled) return;
|
||||
this._pending = this.allowed.has(this.value ?? "") ? this.value : null;
|
||||
this._query = "";
|
||||
const selected = this.variableNode(this.value)
|
||||
?? this.objects.find((node) => node.entity_id === this.value);
|
||||
this._active = selected?.object_id ?? null;
|
||||
this._selected = selected?.object_id ?? null;
|
||||
const expanded = new Set(this._expanded);
|
||||
if (selected) for (const id of symconAncestors(this.tree, selected.object_id)) expanded.add(id);
|
||||
this._expanded = expanded;
|
||||
await this.updateComplete;
|
||||
if (!this.isConnected) return;
|
||||
if (!this.dialog?.open) this.dialog?.showModal();
|
||||
this.renderRoot.querySelector<HTMLInputElement>(".search")?.focus();
|
||||
this.renderRoot.querySelector("[aria-selected=true]")?.scrollIntoView({ block: "nearest" });
|
||||
}
|
||||
|
||||
private close(): void { this.dialog?.close(); }
|
||||
|
||||
private commit(): void {
|
||||
if (this.disabled || !this._pending || !this.allowed.has(this._pending)) return;
|
||||
this.value = this._pending;
|
||||
this.close();
|
||||
this.dispatchEvent(new CustomEvent("change", { detail: { value: this.value }, bubbles: true, composed: true }));
|
||||
}
|
||||
|
||||
private toggle(id: number): void {
|
||||
const expanded = new Set(this._expanded);
|
||||
if (expanded.has(id)) expanded.delete(id); else expanded.add(id);
|
||||
this._expanded = expanded;
|
||||
}
|
||||
|
||||
private select(node: SymconObject): void {
|
||||
this._active = node.object_id;
|
||||
if (node.entity_id && this.allowed.has(node.entity_id)) {
|
||||
this._pending = node.entity_id;
|
||||
this._selected = node.object_id;
|
||||
}
|
||||
}
|
||||
|
||||
private async onTreeKey(event: KeyboardEvent): Promise<void> {
|
||||
const rows = symconTreeRows(this.tree, this._expanded, this._query);
|
||||
const i = Math.max(0, rows.findIndex((row) => row.node.object_id === this._active));
|
||||
const row = rows[i];
|
||||
if (!row) return;
|
||||
let next = i;
|
||||
if (event.key === "ArrowDown") next = Math.min(rows.length - 1, i + 1);
|
||||
else if (event.key === "ArrowUp") next = Math.max(0, i - 1);
|
||||
else if (event.key === "Home") next = 0;
|
||||
else if (event.key === "End") next = rows.length - 1;
|
||||
else if (event.key === "ArrowRight") {
|
||||
if (row.hasChildren && !row.expanded) this.toggle(row.node.object_id);
|
||||
else if (row.hasChildren) next = Math.min(rows.length - 1, i + 1);
|
||||
} else if (event.key === "ArrowLeft") {
|
||||
if (row.expanded && !this._query) this.toggle(row.node.object_id);
|
||||
else next = Math.max(0, rows.findIndex((item) => item.node.object_id === row.node.parent_id));
|
||||
} else if (event.key === " " || event.key === "Enter") {
|
||||
this.select(row.node);
|
||||
if (event.key === "Enter" && row.node.entity_id && this.allowed.has(row.node.entity_id)) this.commit();
|
||||
} else return;
|
||||
event.preventDefault();
|
||||
if (next !== i || this._active === null) this._active = rows[next].node.object_id;
|
||||
await this.updateComplete;
|
||||
this.renderRoot.querySelector(`#object-${this._active}`)?.scrollIntoView({ block: "nearest" });
|
||||
}
|
||||
|
||||
private icon(type: number) {
|
||||
const paths = [
|
||||
svg`<path d="M3 6h7l2 2h9v12H3z"/>`,
|
||||
svg`<path d="m12 3 9 5v9l-9 5-9-5V8zM3 8l9 5 9-5M12 13v9"/>`,
|
||||
svg`<circle cx="12" cy="12" r="8"/><path d="m9 9 6 6m0-6-6 6"/>`,
|
||||
svg`<path d="m8 7-5 5 5 5m8-10 5 5-5 5m-3-12-2 14"/>`,
|
||||
svg`<circle cx="12" cy="12" r="9"/><path d="M12 6v6l4 2"/>`,
|
||||
svg`<rect x="3" y="4" width="18" height="16" rx="2"/><path d="m4 17 5-5 4 4 3-3 5 4"/>`,
|
||||
svg`<path d="m10 14 4-4m-6 2-2 2a4 4 0 0 0 6 6l3-3m-6-9 3-3a4 4 0 0 1 6 6l-2 2"/>`,
|
||||
];
|
||||
return svg`<svg class="icon type-${type}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true">${paths[type] ?? paths[1]}</svg>`;
|
||||
}
|
||||
|
||||
private renderRow(row: SymconTreeRow) {
|
||||
const { node } = row;
|
||||
const selectable = !!node.entity_id && this.allowed.has(node.entity_id);
|
||||
return html`<div id="object-${node.object_id}" role="treeitem"
|
||||
aria-level=${row.depth + 1} aria-posinset=${row.index} aria-setsize=${row.siblings}
|
||||
aria-expanded=${row.hasChildren ? String(row.expanded) : nothing}
|
||||
aria-selected=${selectable ? String(node.object_id === this._selected && node.entity_id === this._pending) : nothing}
|
||||
aria-disabled=${node.entity_id && !selectable ? "true" : nothing}
|
||||
class="node ${selectable ? "selectable" : ""} ${node.hidden ? "hidden-object" : ""} ${this._active === node.object_id ? "active" : ""}"
|
||||
style=${`--depth:${row.depth}`} title=${node.path}
|
||||
@click=${() => { this.select(node); this.renderRoot.querySelector<HTMLElement>(".tree")?.focus(); }}
|
||||
@dblclick=${() => { if (selectable) { this.select(node); this.commit(); } else if (row.hasChildren) this.toggle(node.object_id); }}>
|
||||
<button class="twisty" type="button" tabindex="-1" aria-label=${row.expanded ? "Zuklappen" : "Aufklappen"}
|
||||
?disabled=${!row.hasChildren} @click=${(event: Event) => { event.stopPropagation(); this._active = node.object_id; this.toggle(node.object_id); }}>
|
||||
${row.hasChildren ? (row.expanded ? "▾" : "▸") : nothing}
|
||||
</button>
|
||||
${this.icon(node.object_type)}<span class="node-name">${node.name || "(Ohne Namen)"}</span>
|
||||
<small>${node.virtual ? "Systembereich" : (TYPES[node.object_type] ?? "Objekt")}${node.hidden ? " · ausgeblendet" : ""}</small>
|
||||
${selectable && node.object_id === this._selected && node.entity_id === this._pending ? html`<span class="selected-mark" aria-hidden="true">✓</span>` : nothing}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
const current = this.allowed.get(this.value ?? "");
|
||||
const selectedNode = this.variableNode(this.value);
|
||||
const pending = this.allowed.get(this._pending ?? "");
|
||||
const selectedObject = this._selected === null ? undefined : this.tree.nodes.get(this._selected);
|
||||
const pendingNode = (selectedObject?.entity_id === this._pending ? selectedObject : undefined) ?? this.variableNode(this._pending);
|
||||
const rows = symconTreeRows(this.tree, this._expanded, this._query);
|
||||
const active = rows.find((row) => row.node.object_id === this._active);
|
||||
return html`<button type="button" class="trigger" ?disabled=${this.disabled} aria-haspopup="dialog" @click=${this.open}>
|
||||
<span><strong>${selectedNode?.name ?? current?.label ?? "Datenpunkt auswählen"}</strong>
|
||||
${selectedNode ? html`<small>${selectedNode.path}</small>` : nothing}</span><span aria-hidden="true">⌘</span>
|
||||
</button>
|
||||
<dialog aria-labelledby="picker-title" @click=${(event: MouseEvent) => {
|
||||
event.stopPropagation();
|
||||
if (event.target === this.dialog) {
|
||||
const bounds = this.dialog!.getBoundingClientRect();
|
||||
if (event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom) this.close();
|
||||
}
|
||||
}} @keydown=${(event: KeyboardEvent) => event.stopPropagation()} @change=${(event: Event) => event.stopPropagation()}>
|
||||
<header><div><h2 id="picker-title">Datenpunkt auswählen</h2><p>IP-Symcon · Objektbaum</p></div>
|
||||
<button class="close" type="button" aria-label="Schließen" @click=${this.close}>×</button></header>
|
||||
<div class="search-bar"><input class="search" type="search" placeholder="Im Objektbaum suchen …" aria-label="Objektbaum durchsuchen"
|
||||
.value=${this._query} @input=${(event: Event) => { this._query = (event.target as HTMLInputElement).value; this._active = null; }}>
|
||||
<button class="text-button" type="button" @click=${() => { this._query = ""; this._expanded = new Set(); this._active = null; }}>Alles zuklappen</button>
|
||||
</div>
|
||||
${this.fixed.length ? html`<div class="fixed" aria-label="Weitere Auswahlmöglichkeiten">${this.fixed.map((option) => html`
|
||||
<button type="button" aria-pressed=${option.id === this._pending} @click=${() => { this._pending = option.id; this._active = null; this._selected = null; }}>${option.label}</button>`)}</div>` : nothing}
|
||||
<div class="tree" role="tree" tabindex="0" aria-label="Symcon-Objektbaum" aria-activedescendant=${active ? `object-${active.node.object_id}` : nothing}
|
||||
@keydown=${this.onTreeKey}>
|
||||
${repeat(rows, (row) => row.node.object_id, (row) => this.renderRow(row))}
|
||||
${!rows.length ? html`<p class="empty">${this.objects.length ? "Keine Objekte gefunden." : "Kein Objektbaum verfügbar. Bitte das Symcon-Modul aktualisieren und den Designer neu laden."}</p>` : nothing}
|
||||
</div>
|
||||
<footer><div class="selection"><strong>${pendingNode?.name ?? pending?.label ?? "Noch kein Datenpunkt ausgewählt"}</strong>
|
||||
<small>${pendingNode?.path ?? "Nur passende Variablen können ausgewählt werden."}</small></div>
|
||||
<div class="actions"><button type="button" @click=${this.close}>Abbrechen</button>
|
||||
<button class="apply" type="button" ?disabled=${this.disabled || !pending} @click=${this.commit}>Übernehmen</button></div>
|
||||
</footer>
|
||||
</dialog>`;
|
||||
}
|
||||
|
||||
static styles = [tokens, css`
|
||||
:host { display:block; min-width:0; font:inherit; color:var(--nf-text); }
|
||||
button,input { font:inherit; box-sizing:border-box; }
|
||||
button { cursor:pointer; color:var(--nf-text); border:1px solid var(--nf-line); background:var(--nf-chrome-solid); border-radius:9px; padding:8px 12px; }
|
||||
button:disabled { opacity:.45; cursor:default; }
|
||||
button:focus-visible,input:focus-visible { outline:2px solid var(--nf-accent); outline-offset:2px; }
|
||||
.trigger { width:100%; display:flex; align-items:center; justify-content:space-between; text-align:left; gap:12px; padding:9px 11px; }
|
||||
.trigger>span:first-child { min-width:0; }
|
||||
strong { font-weight:500; } small { display:block; color:var(--nf-muted); font-size:11px; }
|
||||
.trigger small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-top:3px; }
|
||||
dialog { width:min(780px,calc(100vw - 32px)); max-width:none; height:min(690px,calc(100dvh - 32px)); max-height:none; box-sizing:border-box; padding:0; border:1px solid var(--nf-line); border-radius:16px; color:var(--nf-text); background:var(--nf-chrome-solid); box-shadow:0 24px 80px #0008; font:14px system-ui,sans-serif; }
|
||||
dialog[open] { display:flex; flex-direction:column; }
|
||||
dialog::backdrop { background:#050b16a6; backdrop-filter:blur(3px); }
|
||||
header { display:flex; align-items:center; justify-content:space-between; padding:20px 22px 16px; border-bottom:1px solid var(--nf-line); }
|
||||
h2 { font-size:18px; font-weight:600; margin:0 0 4px; } header p { margin:0; color:var(--nf-muted); font-size:12px; }
|
||||
.close { font-size:25px; padding:0; width:32px; height:32px; border-color:transparent; }
|
||||
.search-bar { display:flex; align-items:center; gap:12px; padding:16px 20px 10px; }
|
||||
.search { flex:1; min-width:0; border:1px solid var(--nf-line); border-radius:9px; padding:10px 12px; background:var(--nf-bg); color:var(--nf-text); }
|
||||
.text-button { border:0; background:transparent; color:var(--nf-muted); font-size:12px; padding:6px 0; white-space:nowrap; }
|
||||
.fixed { display:flex; flex-wrap:wrap; gap:6px; padding:0 20px 10px; }
|
||||
.fixed button { padding:5px 10px; font-size:12px; }
|
||||
.fixed [aria-pressed=true] { color:var(--nf-accent); border-color:var(--nf-accent); }
|
||||
.tree { flex:1; min-height:80px; overflow:auto; overscroll-behavior:contain; margin:0 12px; padding:4px 0 12px; outline-offset:-2px; }
|
||||
.node { display:flex; align-items:center; gap:8px; min-height:34px; border-radius:6px; padding:2px 10px 2px calc(4px + var(--depth)*22px); box-sizing:border-box; width:max-content; min-width:100%; }
|
||||
.node:hover { background:color-mix(in srgb,var(--nf-accent) 8%,transparent); }
|
||||
.node.active { outline:1px solid color-mix(in srgb,var(--nf-accent) 40%,transparent); outline-offset:-1px; }
|
||||
.node[aria-selected=true] { background:color-mix(in srgb,var(--nf-accent) 16%,transparent); color:var(--nf-accent); }
|
||||
.node.selectable { cursor:pointer; }
|
||||
.node[aria-disabled=true] .node-name { color:var(--nf-muted); }
|
||||
.node.hidden-object .node-name { font-style:italic; }
|
||||
.node-name { flex:1; white-space:nowrap; }
|
||||
.node small { margin-left:20px; white-space:nowrap; }
|
||||
.twisty { border:0; background:transparent; border-radius:4px; padding:0; width:20px; height:26px; flex:none; font-size:18px; }
|
||||
.icon { flex:none; width:17px; height:17px; color:#8796a9; } .type-0 { color:#c69a42; } .type-1 { color:#8d9ac6; } .type-2 { color:#55a58c; }
|
||||
.selected-mark { margin-left:8px; }
|
||||
.empty { padding:20px; color:var(--nf-muted); }
|
||||
footer { display:flex; align-items:center; justify-content:space-between; gap:16px; border-top:1px solid var(--nf-line); padding:15px 20px; }
|
||||
.selection { min-width:0; } .selection small { margin-top:4px; overflow-wrap:anywhere; }
|
||||
.actions { display:flex; gap:8px; flex-shrink:0; }
|
||||
.apply { color:white; background:var(--nf-accent); border-color:transparent; }
|
||||
@media(max-width:580px) {
|
||||
dialog { width:calc(100vw - 16px); height:calc(100dvh - 32px); border-radius:12px; }
|
||||
header { padding:16px; } .search-bar { padding:12px; gap:8px; } .fixed { padding:0 12px 8px; }
|
||||
.tree { margin:0 8px; } .node { gap:6px; padding-left:calc(2px + var(--depth)*18px); }
|
||||
.node small { display:none; } footer { padding:12px; flex-direction:column; align-items:stretch; } .actions { justify-content:flex-end; }
|
||||
}
|
||||
`];
|
||||
}
|
||||
|
||||
if (!customElements.get("nf-symcon-object-picker")) customElements.define("nf-symcon-object-picker", SymconObjectPicker);
|
||||
@@ -0,0 +1,69 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import type { SymconObject } from "../types.ts";
|
||||
import { indexSymconTree, symconAncestors, symconTreeRows, SYMCON_SYSTEM_ROOT } from "./symcon-tree.ts";
|
||||
|
||||
const node = (object_id: number, parent_id: number, name: string, object_type = 0, position = 0): SymconObject =>
|
||||
({ object_id, parent_id, name, object_type, position, path: name, hidden: false, icon: "" });
|
||||
|
||||
test("native position, type and name order are kept, including empty categories and non-variable objects", () => {
|
||||
const tree = indexSymconTree([node(4, 0, "Variable", 2), node(2, 0, "Zentrale", 1), node(3, 0, "Zweiter Ordner"), node(1, 0, "Erster Ordner"), node(5, 0, "Skript", 3, -1)]);
|
||||
assert.deepEqual(symconTreeRows(tree, new Set()).map((row) => row.node.object_id), [5, 1, 3, 2, 4]);
|
||||
});
|
||||
|
||||
test("equal names and a slash inside a name remain distinct native branches", () => {
|
||||
const tree = indexSymconTree([node(1, 0, "Haus / Altbau"), node(2, 1, "Heizung", 1), node(3, 0, "Heizung", 1), node(4, 2, "Temperatur", 2), node(5, 3, "Temperatur", 2)]);
|
||||
assert.deepEqual(symconAncestors(tree, 4), [2, 1]);
|
||||
assert.deepEqual(symconAncestors(tree, 5), [3]);
|
||||
assert.deepEqual(symconTreeRows(tree, new Set([1, 2])).map((row) => [row.node.object_id, row.depth]), [[1, 0], [2, 1], [4, 2], [3, 0]]);
|
||||
});
|
||||
|
||||
test("search opens the original ancestors and never searches internal IDs", () => {
|
||||
const tree = indexSymconTree([node(1, 0, "Haus"), node(2, 1, "Küche", 1), node(3, 2, "Temperatur", 2), node(4, 1, "Garten")]);
|
||||
const expanded = new Set<number>();
|
||||
assert.deepEqual(symconTreeRows(tree, expanded, "temperatur").map((row) => row.node.object_id), [1, 2, 3]);
|
||||
assert.equal(expanded.size, 0, "search must not change manual expansion state");
|
||||
assert.deepEqual(symconTreeRows(tree, expanded, "3"), []);
|
||||
});
|
||||
|
||||
test("hidden categories and their variables stay in the main category without a visibility filter", () => {
|
||||
const objects = [{ ...node(1, 0, "Versteckt"), hidden: true }, { ...node(2, 1, "Technik"), hidden: true }, { ...node(3, 2, "Temperatur", 2), entity_id: "sensor.3" }];
|
||||
const tree = indexSymconTree(objects);
|
||||
const rows = symconTreeRows(tree, new Set([1, 2]));
|
||||
assert.deepEqual(rows.map((row) => row.node.object_id), [1, 2, 3]);
|
||||
assert.equal(rows[0].node.hidden, true);
|
||||
assert.equal(rows[1].node.hidden, true);
|
||||
assert.equal(rows[2].node.entity_id, "sensor.3");
|
||||
});
|
||||
|
||||
test("all six system module types move into virtual groups while devices stay in the main category", () => {
|
||||
const objects = [node(1, 0, "Haus"), { ...node(2, 1, "Heizung", 1), module_type: 3 }, node(3, 2, "Temperatur", 2)];
|
||||
const types = [1, 2, 0, 4, 5, 6];
|
||||
for (const type of types) {
|
||||
objects.push({ ...node(20 + type, 0, `Modul ${type}`, 1), module_type: type });
|
||||
objects.push({ ...node(40 + type, 20 + type, "Wert", 2), entity_id: `sensor.${40 + type}` });
|
||||
}
|
||||
const original = structuredClone(objects);
|
||||
const tree = indexSymconTree(objects);
|
||||
assert.deepEqual(symconTreeRows(tree, new Set()).map((row) => row.node.name), ["Haus", "System"]);
|
||||
assert.deepEqual((tree.children.get(SYMCON_SYSTEM_ROOT) ?? []).map((entry) => entry.name), ["I/O", "Splitter", "Kerninstanzen", "Konfiguratoren", "Discovery", "Visualisierungen"]);
|
||||
assert.equal(tree.nodes.get(2)?.parent_id, 1);
|
||||
for (const type of types) {
|
||||
assert.equal(tree.nodes.get(20 + type)?.parent_id, -10 - type);
|
||||
assert.deepEqual(symconAncestors(tree, 40 + type), [20 + type, -10 - type, SYMCON_SYSTEM_ROOT]);
|
||||
assert.equal(tree.nodes.get(40 + type)?.entity_id, `sensor.${40 + type}`);
|
||||
}
|
||||
assert.deepEqual(objects, original, "grouping must never mutate native parents or object data");
|
||||
assert.ok([...tree.nodes.values()].filter((entry) => entry.virtual).every((entry) => !entry.entity_id && entry.object_id < 0));
|
||||
});
|
||||
|
||||
test("system subtrees remain intact and searchable, including native folders already named System", () => {
|
||||
const objects = [node(1, 0, "System"), { ...node(2, 1, "LAN", 1), module_type: 1 }, { ...node(3, 2, "Splitter", 1), module_type: 2 },
|
||||
{ ...node(4, 3, "Betriebsstunden", 2), hidden: true, entity_id: "sensor.4" }];
|
||||
const tree = indexSymconTree(objects);
|
||||
assert.equal(tree.nodes.get(1)?.parent_id, 0, "an actual user category named System must not be merged or moved");
|
||||
assert.equal(tree.nodes.get(3)?.parent_id, 2, "nested instances stay with their original parent");
|
||||
assert.deepEqual(symconTreeRows(tree, new Set(), "System I/O Betriebsstunden").map((row) => row.node.object_id), [SYMCON_SYSTEM_ROOT, -11, 2, 3, 4]);
|
||||
assert.equal(tree.nodes.get(4)?.hidden, true);
|
||||
assert.equal(tree.nodes.get(4)?.path, "System / I/O / LAN / Splitter / Betriebsstunden");
|
||||
});
|
||||
@@ -0,0 +1,131 @@
|
||||
import type { SymconObject } from "../types.ts";
|
||||
|
||||
export interface SymconTree {
|
||||
nodes: Map<number, SymconObject>;
|
||||
children: Map<number, SymconObject[]>;
|
||||
}
|
||||
|
||||
export interface SymconTreeRow {
|
||||
node: SymconObject;
|
||||
depth: number;
|
||||
hasChildren: boolean;
|
||||
expanded: boolean;
|
||||
index: number;
|
||||
siblings: number;
|
||||
}
|
||||
|
||||
// Symcon orders siblings by position, then object type, then name (IPS_SetPosition).
|
||||
const collator = new Intl.Collator("de", { numeric: true, sensitivity: "base" });
|
||||
export const SYMCON_SYSTEM_ROOT = -1;
|
||||
const SYSTEM_GROUPS = [
|
||||
{ type: 1, name: "I/O" },
|
||||
{ type: 2, name: "Splitter" },
|
||||
{ type: 0, name: "Kerninstanzen" },
|
||||
{ type: 4, name: "Konfiguratoren" },
|
||||
{ type: 5, name: "Discovery" },
|
||||
{ type: 6, name: "Visualisierungen" },
|
||||
] as const;
|
||||
const isSystemInstance = (node: SymconObject): boolean => node.object_type === 1 && SYSTEM_GROUPS.some((group) => group.type === node.module_type);
|
||||
|
||||
/** Show the main category's objects first and tuck the logical console's system branches away.
|
||||
* Hidden categories are never filtered; only this display copy is regrouped, never the native tree. */
|
||||
function projectSymconObjects(objects: readonly SymconObject[]): readonly SymconObject[] {
|
||||
const native = new Map(objects.map((node) => [node.object_id, node]));
|
||||
const roots = objects.filter((node) => {
|
||||
if (!isSystemInstance(node)) return false;
|
||||
const seen = new Set([node.object_id]);
|
||||
let parent = native.get(node.parent_id);
|
||||
while (parent && !seen.has(parent.object_id)) {
|
||||
if (isSystemInstance(parent)) return false; // Keep its entire native subtree together.
|
||||
seen.add(parent.object_id);
|
||||
parent = native.get(parent.parent_id);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (!roots.length) return objects;
|
||||
|
||||
const projected = new Map(native);
|
||||
const children = new Map<number, SymconObject[]>();
|
||||
for (const node of objects) {
|
||||
const siblings = children.get(node.parent_id) ?? [];
|
||||
siblings.push(node);
|
||||
children.set(node.parent_id, siblings);
|
||||
}
|
||||
const virtualCategory = (id: number, parent: number, name: string, path: string, position: number): SymconObject => ({
|
||||
object_id: id, parent_id: parent, name, path, position, object_type: 0, hidden: false, icon: "", virtual: true,
|
||||
});
|
||||
projected.set(SYMCON_SYSTEM_ROOT, virtualCategory(SYMCON_SYSTEM_ROOT, 0, "System", "System", Number.MAX_SAFE_INTEGER));
|
||||
const moved = new Set<number>();
|
||||
const moveBranch = (node: SymconObject, parent: number, parentPath: string): void => {
|
||||
if (moved.has(node.object_id)) return;
|
||||
moved.add(node.object_id);
|
||||
const copy = { ...node, parent_id: parent, path: `${parentPath} / ${node.name}` };
|
||||
projected.set(node.object_id, copy);
|
||||
for (const child of children.get(node.object_id) ?? []) moveBranch(child, node.object_id, copy.path);
|
||||
};
|
||||
SYSTEM_GROUPS.forEach((group, index) => {
|
||||
const instances = roots.filter((node) => node.module_type === group.type);
|
||||
if (!instances.length) return;
|
||||
const id = -10 - group.type;
|
||||
const path = `System / ${group.name}`;
|
||||
projected.set(id, virtualCategory(id, SYMCON_SYSTEM_ROOT, group.name, path, index));
|
||||
for (const instance of instances) moveBranch(instance, id, path);
|
||||
});
|
||||
return [...projected.values()];
|
||||
}
|
||||
|
||||
export function indexSymconTree(objects: readonly SymconObject[]): SymconTree {
|
||||
const projected = projectSymconObjects(objects);
|
||||
const nodes = new Map(projected.map((node) => [node.object_id, node]));
|
||||
const children = new Map<number, SymconObject[]>();
|
||||
for (const node of projected) {
|
||||
const parent = nodes.has(node.parent_id) ? node.parent_id : 0;
|
||||
const siblings = children.get(parent) ?? [];
|
||||
siblings.push(node);
|
||||
children.set(parent, siblings);
|
||||
}
|
||||
for (const siblings of children.values()) siblings.sort((a, b) => a.position - b.position || a.object_type - b.object_type || collator.compare(a.name, b.name));
|
||||
return { nodes, children };
|
||||
}
|
||||
|
||||
/** Display ancestor IDs, including virtual system groups, without splitting names into paths. */
|
||||
export function symconAncestors(tree: SymconTree, objectId: number): number[] {
|
||||
const result: number[] = [];
|
||||
const seen = new Set([objectId]);
|
||||
let parent = tree.nodes.get(objectId)?.parent_id;
|
||||
while (parent && !seen.has(parent) && tree.nodes.has(parent)) {
|
||||
result.push(parent);
|
||||
seen.add(parent);
|
||||
parent = tree.nodes.get(parent)?.parent_id;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Search retains each match's displayed ancestors and opens that path without changing manual expansion. */
|
||||
export function symconTreeRows(tree: SymconTree, expanded: ReadonlySet<number>, query = ""): SymconTreeRow[] {
|
||||
const words = query.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean);
|
||||
const matches = words.length ? new Set<number>() : null;
|
||||
if (matches) {
|
||||
for (const node of tree.nodes.values()) {
|
||||
if (words.every((word) => `${node.name} ${node.path}`.toLocaleLowerCase("de").includes(word))) {
|
||||
matches.add(node.object_id);
|
||||
for (const id of symconAncestors(tree, node.object_id)) matches.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
const rows: SymconTreeRow[] = [];
|
||||
const visited = new Set<number>();
|
||||
const visit = (parent: number, depth: number) => {
|
||||
const siblings = (tree.children.get(parent) ?? []).filter((node) => !matches || matches.has(node.object_id));
|
||||
siblings.forEach((node, i) => {
|
||||
if (visited.has(node.object_id)) return;
|
||||
visited.add(node.object_id);
|
||||
const hasChildren = (tree.children.get(node.object_id)?.length ?? 0) > 0;
|
||||
const open = hasChildren && (!!matches || expanded.has(node.object_id));
|
||||
rows.push({ node, depth, hasChildren, expanded: open, index: i + 1, siblings: siblings.length });
|
||||
if (open) visit(node.object_id, depth + 1);
|
||||
});
|
||||
};
|
||||
visit(0, 0);
|
||||
return rows;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Symcon variables are exposed as named synthetic entities (for example `light.12345`), while the browser
|
||||
// only ever shows and selects their object-tree path. The numeric object id stays an implementation detail.
|
||||
|
||||
import type { HassArea, HassEntity, HassEntityEntry, HomeAssistant } from "./types.ts";
|
||||
import type { HassArea, HassEntity, HassEntityEntry, HomeAssistant, SymconObject } from "./types.ts";
|
||||
|
||||
interface SymconConfig {
|
||||
endpoint: string;
|
||||
@@ -28,6 +28,7 @@ interface Bootstrap {
|
||||
building_revision: number;
|
||||
variables: SymconVariable[];
|
||||
areas: HassArea[];
|
||||
objects?: SymconObject[];
|
||||
}
|
||||
|
||||
interface VariableSnapshot {
|
||||
@@ -35,6 +36,7 @@ interface VariableSnapshot {
|
||||
building_revision: number;
|
||||
variables?: SymconVariable[];
|
||||
areas?: HassArea[];
|
||||
objects?: SymconObject[];
|
||||
}
|
||||
|
||||
type Listener = () => void;
|
||||
@@ -80,6 +82,7 @@ export class SymconBridge {
|
||||
private timer: ReturnType<typeof setInterval> | undefined;
|
||||
private stateRevision = -1;
|
||||
private buildingRevision = -1;
|
||||
private objectsSignature = "";
|
||||
private states: Record<string, HassEntity> = {};
|
||||
private entities: Record<string, HassEntityEntry> = {};
|
||||
private areas: Record<string, HassArea> = {};
|
||||
@@ -90,6 +93,7 @@ export class SymconBridge {
|
||||
states: this.states,
|
||||
entities: this.entities,
|
||||
areas: this.areas,
|
||||
symconObjects: [],
|
||||
config: { unit_system: { temperature: "°C" } },
|
||||
themes: { darkMode: window.matchMedia?.("(prefers-color-scheme: dark)").matches ?? true },
|
||||
services: {},
|
||||
@@ -140,7 +144,7 @@ export class SymconBridge {
|
||||
const next = await call<VariableSnapshot>(this.settings, "variables/snapshot", { revision: this.stateRevision });
|
||||
if (next.state_revision !== this.stateRevision && next.variables) {
|
||||
this.stateRevision = next.state_revision;
|
||||
this.apply({ variables: next.variables, areas: next.areas });
|
||||
this.apply({ variables: next.variables, areas: next.areas, objects: next.objects });
|
||||
for (const listener of this.changeListeners) listener();
|
||||
}
|
||||
if (next.building_revision !== this.buildingRevision) {
|
||||
@@ -152,7 +156,7 @@ export class SymconBridge {
|
||||
}
|
||||
}
|
||||
|
||||
private apply(data: { variables: SymconVariable[]; areas?: HassArea[] }): void {
|
||||
private apply(data: { variables: SymconVariable[]; areas?: HassArea[]; objects?: SymconObject[] }): void {
|
||||
this.states = Object.fromEntries(
|
||||
data.variables.map((variable) => [
|
||||
variable.entity_id,
|
||||
@@ -178,6 +182,13 @@ export class SymconBridge {
|
||||
this.facade.states = this.states;
|
||||
this.facade.entities = this.entities;
|
||||
this.facade.areas = this.areas;
|
||||
if (data.objects) {
|
||||
const signature = JSON.stringify(data.objects);
|
||||
if (signature !== this.objectsSignature) {
|
||||
this.facade.symconObjects = data.objects;
|
||||
this.objectsSignature = signature;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async callWS<T>(message: Record<string, unknown>): Promise<T> {
|
||||
|
||||
@@ -49,6 +49,24 @@ export interface HassConnection {
|
||||
subscribeMessage<T>(callback: (msg: T) => void, msg: Record<string, unknown>): Promise<() => Promise<void>>;
|
||||
}
|
||||
|
||||
/** An actual node of Symcon's object tree; names/paths are display text, IDs are internal keys. */
|
||||
export interface SymconObject {
|
||||
object_id: number;
|
||||
parent_id: number;
|
||||
name: string;
|
||||
path: string;
|
||||
object_type: number;
|
||||
position: number;
|
||||
hidden: boolean;
|
||||
icon: string;
|
||||
/** Native module type of an instance (0 core, 1 IO, 2 splitter, 3 device, 4–6 system). */
|
||||
module_type?: number;
|
||||
/** Display-only grouping node; never an actual Symcon object. */
|
||||
virtual?: boolean;
|
||||
/** Present on variables and links to variables. */
|
||||
entity_id?: string;
|
||||
}
|
||||
|
||||
export interface HomeAssistant {
|
||||
language: string;
|
||||
user?: { is_admin: boolean; name: string };
|
||||
@@ -56,6 +74,8 @@ export interface HomeAssistant {
|
||||
floors?: Record<string, HassFloor>;
|
||||
entities?: Record<string, HassEntityEntry>;
|
||||
devices?: Record<string, HassDevice>;
|
||||
/** Present only in the Symcon host. The full native hierarchy, including non-variable nodes. */
|
||||
symconObjects?: readonly SymconObject[];
|
||||
states: Record<string, HassEntity>;
|
||||
config?: { unit_system?: { temperature?: string }; latitude?: number; longitude?: number; time_zone?: string };
|
||||
/** Home Assistant's theme state: `darkMode` is false in a light theme. */
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
// Browser checks for the actual picker component, with invented Symcon objects.
|
||||
// Run from frontend/: node symcon-picker-smoke.mjs
|
||||
import assert from "node:assert/strict";
|
||||
import { build } from "esbuild";
|
||||
import { existsSync, mkdirSync } from "node:fs";
|
||||
import { join, resolve } from "node:path";
|
||||
import puppeteer from "puppeteer-core";
|
||||
|
||||
const root = resolve(import.meta.dirname, "..");
|
||||
const bundle = await build({ entryPoints: [join(root, "frontend/src/components/entity-picker.ts")], bundle: true, write: false, format: "iife", target: "chrome100", logLevel: "silent" });
|
||||
const executablePath = [process.env.CHROME_PATH, "C:/Program Files/Google/Chrome/Application/chrome.exe", "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe", "/usr/bin/google-chrome", "/usr/bin/chromium"].find((path) => path && existsSync(path));
|
||||
assert.ok(executablePath, "A local Chrome or Edge is required for the picker browser check");
|
||||
const browser = await puppeteer.launch({ executablePath, headless: true });
|
||||
const out = join(root, "preview/screenshots");
|
||||
mkdirSync(out, { recursive: true });
|
||||
|
||||
try {
|
||||
const page = await browser.newPage();
|
||||
const errors = [];
|
||||
page.on("pageerror", (error) => errors.push(String(error)));
|
||||
await page.setViewport({ width: 1200, height: 860, deviceScaleFactor: 1 });
|
||||
await page.setContent(`<style>body{background:#13171e;color:#e7eaf0;font:14px system-ui;padding:32px}main{max-width:470px;background:#1c222c;padding:24px;border:1px solid #343c4b;border-radius:14px}h1{font-size:20px}label{display:block;margin:20px 0}nf-entity-picker{margin-top:8px;--primary-background-color:#141a23;--ha-card-background:#202733;--primary-text-color:#e7eaf0;--secondary-text-color:#a3afc0;--primary-color:#47a5ef;--divider-color:#3b4555}</style><main><h1>NextFloor · Designer</h1><p>Raum: Küche · Erdgeschoss</p><label>Temperatur-Datenpunkt<nf-entity-picker id="symcon"></nf-entity-picker></label><label>Vorhandene Home-Assistant-Auswahl<nf-entity-picker id="ha"></nf-entity-picker></label></main>`);
|
||||
await page.addScriptTag({ content: bundle.outputFiles[0].text });
|
||||
await page.evaluate(async () => {
|
||||
const object = (object_id, parent_id, name, object_type, position, path, entity_id, module_type = 3) => ({ object_id, parent_id, name, object_type, position, path, entity_id, module_type: object_type === 1 ? module_type : undefined, hidden: [100, 303].includes(object_id), icon: "" });
|
||||
const picker = document.querySelector("#symcon");
|
||||
picker.objectTree = [
|
||||
object(100, 0, "Haus", 0, 1, "Haus"),
|
||||
object(110, 100, "Erdgeschoss", 0, 0, "Haus / Erdgeschoss"),
|
||||
object(120, 110, "Küche", 0, 0, "Haus / Erdgeschoss / Küche"),
|
||||
object(200, 120, "Heizungsaktor", 1, 0, "Haus / Erdgeschoss / Küche / Heizungsaktor"),
|
||||
object(301, 200, "Temperatur", 2, 0, "Haus / Erdgeschoss / Küche / Heizungsaktor / Temperatur", "sensor.301"),
|
||||
object(302, 200, "Solltemperatur", 2, 1, "Haus / Erdgeschoss / Küche / Heizungsaktor / Solltemperatur", "climate.302"),
|
||||
object(303, 200, "Leistung", 2, 2, "Haus / Erdgeschoss / Küche / Heizungsaktor / Leistung", "sensor.303"),
|
||||
object(305, 301, "Bei Änderung", 4, 0, "Haus / Erdgeschoss / Küche / Heizungsaktor / Temperatur / Bei Änderung"),
|
||||
object(150, 120, "Temperatur oben", 6, 1, "Haus / Erdgeschoss / Küche / Temperatur oben", "sensor.430"),
|
||||
object(160, 120, "Lichtsteuerung", 3, 2, "Haus / Erdgeschoss / Küche / Lichtsteuerung"),
|
||||
object(400, 100, "Obergeschoss", 0, 1, "Haus / Obergeschoss"),
|
||||
object(410, 400, "Küche", 0, 0, "Haus / Obergeschoss / Küche"),
|
||||
object(420, 410, "Heizungsaktor", 1, 0, "Haus / Obergeschoss / Küche / Heizungsaktor"),
|
||||
object(430, 420, "Temperatur", 2, 0, "Haus / Obergeschoss / Küche / Heizungsaktor / Temperatur", "sensor.430"),
|
||||
object(500, 0, "Leerer Ordner", 0, 2, "Leerer Ordner"),
|
||||
object(900, 0, "Verwaltung", 0, 0, "Verwaltung"),
|
||||
object(910, 900, "NextFloor", 1, 0, "Verwaltung / NextFloor"),
|
||||
object(600, 0, "LAN-Schnittstelle", 1, 0, "LAN-Schnittstelle", undefined, 1),
|
||||
object(601, 600, "Betriebsstunden", 2, 0, "LAN-Schnittstelle / Betriebsstunden", "sensor.601"),
|
||||
object(610, 0, "Gateway", 1, 0, "Gateway", undefined, 2),
|
||||
object(620, 0, "WebHook Control", 1, 0, "WebHook Control", undefined, 0),
|
||||
object(630, 0, "Geräte-Konfigurator", 1, 0, "Geräte-Konfigurator", undefined, 4),
|
||||
object(640, 0, "Gerätesuche", 1, 0, "Gerätesuche", undefined, 5),
|
||||
object(650, 0, "Kachel-Visualisierung", 1, 0, "Kachel-Visualisierung", undefined, 6),
|
||||
];
|
||||
picker.options = [{ id: "sensor.301", label: "Temperatur Küche EG" }, { id: "sensor.303", label: "Leistung Küche EG" }, { id: "sensor.430", label: "Temperatur Küche OG" }, { id: "sensor.601", label: "Betriebsstunden" }];
|
||||
picker.fixed = [{ id: "none", label: "Keine Variable" }];
|
||||
picker.value = "sensor.301";
|
||||
window.pickerChanges = [];
|
||||
picker.addEventListener("change", (event) => window.pickerChanges.push(event.detail?.value ?? "NATIVE"));
|
||||
const ha = document.querySelector("#ha");
|
||||
ha.options = [{ id: "sensor.demo", label: "Demo" }];
|
||||
await picker.updateComplete;
|
||||
await picker.shadowRoot.querySelector("nf-symcon-object-picker").updateComplete;
|
||||
});
|
||||
const click = (selector) => page.evaluate((selector) => document.querySelector("#symcon").shadowRoot.querySelector("nf-symcon-object-picker").shadowRoot.querySelector(selector).click(), selector);
|
||||
const state = () => page.evaluate(() => {
|
||||
const picker = document.querySelector("#symcon");
|
||||
const shadow = picker.shadowRoot.querySelector("nf-symcon-object-picker").shadowRoot;
|
||||
return { open: shadow.querySelector("dialog").open, value: picker.value, changes: window.pickerChanges, text: shadow.querySelector("dialog").textContent,
|
||||
rows: [...shadow.querySelectorAll("[role=treeitem]")].map((row) => ({ id: row.id, name: row.querySelector(".node-name").textContent, disabled: row.getAttribute("aria-disabled"), selected: row.getAttribute("aria-selected"), hidden: row.classList.contains("hidden-object") })) };
|
||||
});
|
||||
const settle = () => page.evaluate(async () => { const picker = document.querySelector("#symcon"); await picker.updateComplete; await picker.shadowRoot.querySelector("nf-symcon-object-picker").updateComplete; });
|
||||
const open = async () => {
|
||||
await click(".trigger");
|
||||
await page.waitForFunction(() => document.querySelector("#symcon").shadowRoot.querySelector("nf-symcon-object-picker").shadowRoot.querySelector("dialog").open);
|
||||
};
|
||||
await open();
|
||||
let result = await state();
|
||||
assert.equal(result.rows[0].name, "Verwaltung", "console position must win over alphabetical order");
|
||||
assert.equal(result.rows.at(-1).name, "System", "virtual system category goes after the main objects");
|
||||
assert.ok(!result.rows.some((row) => row.id === "object-600"), "system instances are initially tucked away");
|
||||
assert.ok(result.rows.some((row) => row.id === "object-100" && row.hidden), "a hidden category remains visible and can contain the selected variable");
|
||||
assert.ok(result.rows.some((row) => row.id === "object-301" && row.selected === "true"), "selected variable's ancestors open automatically");
|
||||
assert.ok(result.rows.some((row) => row.id === "object-302" && row.disabled === "true"), "incompatible variables remain visible");
|
||||
assert.ok(result.rows.some((row) => row.name === "Leerer Ordner"), "empty categories must stay visible");
|
||||
assert.ok(!result.text.includes("sensor.301"), "internal IDs must not appear in picker text");
|
||||
await page.screenshot({ path: join(out, "symcon-picker-desktop.png") });
|
||||
await page.keyboard.press("Escape");
|
||||
assert.equal((await state()).open, false, "Escape closes the native modal");
|
||||
assert.deepEqual((await state()).changes, []);
|
||||
|
||||
await open();
|
||||
await page.evaluate(() => {
|
||||
const input = document.querySelector("#symcon").shadowRoot.querySelector("nf-symcon-object-picker").shadowRoot.querySelector(".search");
|
||||
input.value = "Obergeschoss Temperatur";
|
||||
input.dispatchEvent(new Event("input", { bubbles: true, composed: true }));
|
||||
input.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
|
||||
});
|
||||
await settle();
|
||||
result = await state();
|
||||
assert.ok(result.rows.some((row) => row.id === "object-430"), "search opens the actual matching branch");
|
||||
assert.ok(!result.rows.some((row) => row.id === "object-301"), "same-named variable in another branch must not match");
|
||||
await click("#object-430");
|
||||
await settle();
|
||||
assert.deepEqual((await state()).changes, [], "selection/search alone never changes the saved mapping");
|
||||
await click(".apply");
|
||||
await settle();
|
||||
assert.equal((await state()).value, "sensor.430");
|
||||
assert.deepEqual((await state()).changes, ["sensor.430"], "confirm emits exactly one real selection event");
|
||||
|
||||
await page.setViewport({ width: 390, height: 844, deviceScaleFactor: 1 });
|
||||
await open();
|
||||
assert.ok((await state()).rows.some((row) => row.id === "object-430" && row.selected === "true"), "reopening finds the original variable rather than an earlier link to it");
|
||||
await page.screenshot({ path: join(out, "symcon-picker-mobile.png") });
|
||||
assert.ok(await page.evaluate(() => {
|
||||
const bounds = document.querySelector("#symcon").shadowRoot.querySelector("nf-symcon-object-picker").shadowRoot.querySelector("dialog").getBoundingClientRect();
|
||||
return bounds.left >= 0 && bounds.right <= innerWidth && bounds.top >= 0 && bounds.bottom <= innerHeight;
|
||||
}), "modal fits the mobile viewport");
|
||||
await click(".fixed button");
|
||||
await click(".actions button:first-child");
|
||||
assert.equal((await state()).value, "sensor.430", "cancel preserves the existing mapping");
|
||||
await open();
|
||||
await click(".fixed button");
|
||||
await click(".apply");
|
||||
assert.equal((await state()).value, "none", "fixed choices remain available in the popup");
|
||||
await open();
|
||||
await click("#object-150");
|
||||
await click(".apply");
|
||||
assert.equal((await state()).value, "sensor.430", "a variable link selects its actual target");
|
||||
await open();
|
||||
await page.evaluate(() => document.querySelector("#symcon").shadowRoot.querySelector("nf-symcon-object-picker").shadowRoot.querySelector(".tree").focus());
|
||||
await page.keyboard.press("Home");
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await settle();
|
||||
assert.ok((await state()).rows.some((row) => row.id === "object-910"), "keyboard navigation can expand a native branch");
|
||||
await page.keyboard.press("Escape");
|
||||
await page.setViewport({ width: 1200, height: 860, deviceScaleFactor: 1 });
|
||||
await open();
|
||||
await click("#object--1 .twisty");
|
||||
await settle();
|
||||
result = await state();
|
||||
for (const name of ["I/O", "Splitter", "Kerninstanzen", "Konfiguratoren", "Discovery", "Visualisierungen"]) {
|
||||
assert.ok(result.rows.some((row) => row.name === name), `system group ${name} is available`);
|
||||
}
|
||||
await page.evaluate(() => {
|
||||
const input = document.querySelector("#symcon").shadowRoot.querySelector("nf-symcon-object-picker").shadowRoot.querySelector(".search");
|
||||
input.value = "System I/O Betriebsstunden";
|
||||
input.dispatchEvent(new Event("input", { bubbles: true, composed: true }));
|
||||
});
|
||||
await settle();
|
||||
assert.ok((await state()).rows.some((row) => row.id === "object-601"), "search also opens a matching system variable through its virtual ancestors");
|
||||
await click("#object-601");
|
||||
await click(".apply");
|
||||
assert.equal((await state()).value, "sensor.601", "system variables remain selectable");
|
||||
await open();
|
||||
assert.ok((await state()).rows.some((row) => row.id === "object-601" && row.selected === "true"), "a selected system variable reopens its virtual path");
|
||||
await page.screenshot({ path: join(out, "symcon-picker-system.png") });
|
||||
await page.keyboard.press("Escape");
|
||||
assert.ok(await page.evaluate(() => !!document.querySelector("#ha").shadowRoot.querySelector("input[role=combobox]")), "HA picker remains unchanged");
|
||||
assert.deepEqual(errors, [], "no browser errors");
|
||||
console.log("OK: hidden categories, virtual system groups, system-variable search/selection, modal, confirm/cancel, Escape, mobile layout and HA compatibility");
|
||||
console.log(`Screenshots: ${out}`);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*! NextFloor, MIT licence. Includes three.js (MIT) and Lit (BSD-3-Clause); see LICENSE and THIRD_PARTY_NOTICES.md */
|
||||
var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",fr:"6312d0f61ebf",hu:"27ba348531dc",it:"1b705e76dd00",nb:"c5ea24fb9ef6",nl:"b64142c67c2e",pl:"8527a4930402",pt:"31857a2d2277",ro:"e3cb5f449f0f",sk:"320611594db0",sl:"8071691ceda3",sv:"711b911ec8da",tr:"7c83ce1c3372",zh:"50518d9f494e"};Array.prototype.at||Object.defineProperty(Array.prototype,"at",{configurable:!0,writable:!0,value:function(e){let t=Math.trunc(e)||0;return this[t<0?this.length+t:t]}});typeof globalThis.structuredClone!="function"&&(globalThis.structuredClone=r=>r===void 0?r:JSON.parse(JSON.stringify(r)));var yn=globalThis,xn=yn.ShadowRoot&&(yn.ShadyCSS===void 0||yn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Hr=Symbol(),wi=new WeakMap,Pt=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==Hr)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(xn&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=wi.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&wi.set(t,e))}return e}toString(){return this.cssText}},vi=r=>new Pt(typeof r=="string"?r:r+"",void 0,Hr),te=(r,...e)=>{let t=r.length===1?r[0]:e.reduce((n,o,i)=>n+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+r[i+1],r[0]);return new Pt(t,r,Hr)},yi=(r,e)=>{if(xn)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let n=document.createElement("style"),o=yn.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=t.cssText,r.appendChild(n)}},Ir=xn?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let n of e.cssRules)t+=n.cssText;return vi(t)})(r):r;var{is:Zc,defineProperty:Yc,getOwnPropertyDescriptor:Jc,getOwnPropertyNames:Qc,getOwnPropertySymbols:Xc,getPrototypeOf:eu}=Object,kn=globalThis,xi=kn.trustedTypes,tu=xi?xi.emptyScript:"",nu=kn.reactiveElementPolyfillSupport,Ht=(r,e)=>r,Cr={toAttribute(r,e){switch(e){case Boolean:r=r?tu:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},Si=(r,e)=>!Zc(r,e),ki={attribute:!0,type:String,converter:Cr,reflect:!1,useDefault:!1,hasChanged:Si};Symbol.metadata??=Symbol("metadata"),kn.litPropertyMetadata??=new WeakMap;var $e=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=ki){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),o=this.getPropertyDescriptor(e,n,t);o!==void 0&&Yc(this.prototype,e,o)}}static getPropertyDescriptor(e,t,n){let{get:o,set:i}=Jc(this.prototype,e)??{get(){return this[t]},set(s){this[t]=s}};return{get:o,set(s){let a=o?.call(this);i?.call(this,s),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??ki}static _$Ei(){if(this.hasOwnProperty(Ht("elementProperties")))return;let e=eu(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Ht("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ht("properties"))){let t=this.properties,n=[...Qc(t),...Xc(t)];for(let o of n)this.createProperty(o,t[o])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[n,o]of t)this.elementProperties.set(n,o)}this._$Eh=new Map;for(let[t,n]of this.elementProperties){let o=this._$Eu(t,n);o!==void 0&&this._$Eh.set(o,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let o of n)t.unshift(Ir(o))}else e!==void 0&&t.push(Ir(e));return t}static _$Eu(e,t){let n=t.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shaLine truncated
|
||||
\f\r]`,It=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ai=/-->/g,Ei=/>/g,qe=RegExp(`>|${Nr}(?:([^\\s"'>=/]+)(${Nr}*=${Nr}*(?:[^
|
||||
\f\r"'\`<>=]|("|')|))|$)`,"g"),Ri=/'/g,zi=/"/g,Pi=/^(?:script|style|textarea|title)$/i,Ur=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),m=Ur(1),J=Ur(2),Hm=Ur(3),Je=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),Ti=new WeakMap,Ze=Ye.createTreeWalker(Ye,129);function Hi(r,e){if(!Gr(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return $i!==void 0?$i.createHTML(e):e}var iu=(r,e)=>{let t=r.length-1,n=[],o,i=e===2?"<svg>":e===3?"<math>":"",s=It;for(let a=0;a<t;a++){let l=r[a],c,u,d=-1,p=0;for(;p<l.length&&(s.lastIndex=p,u=s.exec(l),u!==null);)p=s.lastIndex,s===It?u[1]==="!--"?s=Ai:u[1]!==void 0?s=Ei:u[2]!==void 0?(Pi.test(u[2])&&(o=RegExp("</"+u[2],"g")),s=qe):u[3]!==void 0&&(s=qe):s===qe?u[0]===">"?(s=o??It,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?qe:u[3]==='"'?zi:Ri):s===zi||s===Ri?s=qe:s===Ai||s===Ei?s=It:(s=qe,o=void 0);let h=s===qe&&r[a+1].startsWith("/>")?" ":"";i+=s===It?l+ru:d>=0?(n.push(c),l.slice(0,d)+Fi+l.slice(d)+Oe+h):l+Oe+(d===-2?a:h)}return[Hi(r,i+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]},Ot=class r{constructor({strings:e,_$litType$:t},n){let o;this.parts=[];let i=0,s=0,a=e.length-1,l=this.parts,[c,u]=iu(e,t);if(this.el=r.createElement(c,n),Ze.currentNode=this.el.content,t===2||t===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(o=Ze.nextNode())!==null&&l.length<a;){if(o.nodeType===1){if(o.hasAttributes())for(let d of o.getAttributeNames())if(d.endsWith(Fi)){let p=u[s++],h=o.getAttribute(d).split(Oe),w=/([.?@])?(.*)/.exec(p);l.push({type:1,index:i,name:w[2],strings:h,ctor:w[1]==="."?Wr:w[1]==="?"?Lr:w[1]==="@"?Br:ut}),o.removeAttribute(d)}else d.startsWith(Oe)&&(l.push({type:6,index:i}),o.removeAttribute(d));if(Pi.test(o.tagName)){let d=o.textContent.split(Oe),p=d.length-1;if(p>0){o.textContent=Sn?Sn.emptyScript:"";for(let h=0;h<p;h++)o.append(d[h],Ct()),Ze.nextNode(),l.push({type:2,index:++i});o.append(d[p],Ct())}}}else if(o.nodeType===8)if(o.data===Di)l.push({type:2,index:i});else{let d=-1;for(;(d=o.data.indexOf(Oe,d+1))!==-1;)l.push({type:7,index:i}),d+=Oe.length-1}i++}}static createElement(e,t){let n=Ye.createElement("template");return n.innerHTML=e,n}};function ct(r,e,t=r,n){if(e===Je)return e;let o=n!==void 0?t._$Co?.[n]:t._$Cl,i=Nt(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),i===void 0?o=void 0:(o=new i(r),o._$AT(r,t,n)),n!==void 0?(t._$Co??=[])[n]=o:t._$Cl=o),o!==void 0&&(e=ct(r,o._$AS(r,e.values),o,n)),e}var Or=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,o=(e?.creationScope??Ye).importNode(t,!0);Ze.currentNode=o;let i=Ze.nextNode(),s=0,a=0,l=n[0];for(;l!==void 0;){if(s===l.index){let c;l.type===2?c=new Wt(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new Vr(i,this,e)),this._$AV.push(c),l=n[++a]}s!==l?.index&&(i=Ze.nextNode(),s++)}return Ze.currentNode=Ye,o}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}},Wt=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,o){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ct(this,e,t),Nt(e)?e===f||e==null||e===""?(this._$AH!==f&&this._$AR(),this._$AH=f):e!==this._$AH&&e!==Je&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):ou(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==f&&Nt(this._$AH)?this._$AA.nextSibling.data=e:this.T(Ye.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,o=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=Ot.createElement(Hi(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(t);else{let i=new Or(o,this),s=i.u(this.options);i.p(t),this.T(s),this._$AH=i}}_$AC(e){let t=Ti.get(e.strings);return t===void 0&&Ti.set(e.strings,t=new Ot(e)),t}k(e){Gr(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,n,o=0;for(let i of e)o===t.length?t.push(n=new r(this.O(Ct()),this.O(Ct()),this,this.options)):n=t[o],n._$AI(i),o++;o<t.length&&(this._$AR(n&&n._$AB.nextSibling,o),t.length=o)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let n=Mi(e).nextSibling;Mi(e).remove(),e=n}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},ut=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,o,i){this.type=1,this._$AH=f,this._$AN=void 0,this.element=e,this.name=t,this._$AM=o,this.options=i,n.length>2||n[0]!==""||n[1]!==""?(this._Line truncated
|
||||
\f\r"'\`<>=]|("|')|))|$)`,"g"),Ri=/'/g,zi=/"/g,Pi=/^(?:script|style|textarea|title)$/i,Ur=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),m=Ur(1),J=Ur(2),Hm=Ur(3),Je=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),Ti=new WeakMap,Ze=Ye.createTreeWalker(Ye,129);function Hi(r,e){if(!Gr(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return $i!==void 0?$i.createHTML(e):e}var iu=(r,e)=>{let t=r.length-1,n=[],o,i=e===2?"<svg>":e===3?"<math>":"",s=It;for(let a=0;a<t;a++){let l=r[a],c,u,d=-1,p=0;for(;p<l.length&&(s.lastIndex=p,u=s.exec(l),u!==null);)p=s.lastIndex,s===It?u[1]==="!--"?s=Ai:u[1]!==void 0?s=Ei:u[2]!==void 0?(Pi.test(u[2])&&(o=RegExp("</"+u[2],"g")),s=qe):u[3]!==void 0&&(s=qe):s===qe?u[0]===">"?(s=o??It,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?qe:u[3]==='"'?zi:Ri):s===zi||s===Ri?s=qe:s===Ai||s===Ei?s=It:(s=qe,o=void 0);let h=s===qe&&r[a+1].startsWith("/>")?" ":"";i+=s===It?l+ru:d>=0?(n.push(c),l.slice(0,d)+Fi+l.slice(d)+Oe+h):l+Oe+(d===-2?a:h)}return[Hi(r,i+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]},Ot=class r{constructor({strings:e,_$litType$:t},n){let o;this.parts=[];let i=0,s=0,a=e.length-1,l=this.parts,[c,u]=iu(e,t);if(this.el=r.createElement(c,n),Ze.currentNode=this.el.content,t===2||t===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(o=Ze.nextNode())!==null&&l.length<a;){if(o.nodeType===1){if(o.hasAttributes())for(let d of o.getAttributeNames())if(d.endsWith(Fi)){let p=u[s++],h=o.getAttribute(d).split(Oe),w=/([.?@])?(.*)/.exec(p);l.push({type:1,index:i,name:w[2],strings:h,ctor:w[1]==="."?Wr:w[1]==="?"?Lr:w[1]==="@"?Br:ut}),o.removeAttribute(d)}else d.startsWith(Oe)&&(l.push({type:6,index:i}),o.removeAttribute(d));if(Pi.test(o.tagName)){let d=o.textContent.split(Oe),p=d.length-1;if(p>0){o.textContent=Sn?Sn.emptyScript:"";for(let h=0;h<p;h++)o.append(d[h],Ct()),Ze.nextNode(),l.push({type:2,index:++i});o.append(d[p],Ct())}}}else if(o.nodeType===8)if(o.data===Di)l.push({type:2,index:i});else{let d=-1;for(;(d=o.data.indexOf(Oe,d+1))!==-1;)l.push({type:7,index:i}),d+=Oe.length-1}i++}}static createElement(e,t){let n=Ye.createElement("template");return n.innerHTML=e,n}};function ct(r,e,t=r,n){if(e===Je)return e;let o=n!==void 0?t._$Co?.[n]:t._$Cl,i=Nt(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),i===void 0?o=void 0:(o=new i(r),o._$AT(r,t,n)),n!==void 0?(t._$Co??=[])[n]=o:t._$Cl=o),o!==void 0&&(e=ct(r,o._$AS(r,e.values),o,n)),e}var Or=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,o=(e?.creationScope??Ye).importNode(t,!0);Ze.currentNode=o;let i=Ze.nextNode(),s=0,a=0,l=n[0];for(;l!==void 0;){if(s===l.index){let c;l.type===2?c=new Wt(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new Vr(i,this,e)),this._$AV.push(c),l=n[++a]}s!==l?.index&&(i=Ze.nextNode(),s++)}return Ze.currentNode=Ye,o}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}},Wt=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,o){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ct(this,e,t),Nt(e)?e===f||e==null||e===""?(this._$AH!==f&&this._$AR(),this._$AH=f):e!==this._$AH&&e!==Je&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):ou(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==f&&Nt(this._$AH)?this._$AA.nextSibling.data=e:this.T(Ye.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,o=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=Ot.createElement(Hi(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(t);else{let i=new Or(o,this),s=i.u(this.options);i.p(t),this.T(s),this._$AH=i}}_$AC(e){let t=Ti.get(e.strings);return t===void 0&&Ti.set(e.strings,t=new Ot(e)),t}k(e){Gr(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,n,o=0;for(let i of e)o===t.length?t.push(n=new r(this.O(Ct()),this.O(Ct()),this,this.options)):n=t[o],n._$AI(i),o++;o<t.length&&(this._$AR(n&&n._$AB.nextSibling,o),t.length=o)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let n=Mi(e).nextSibling;Mi(e).remove(),e=n}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},ut=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,o,i){this.type=1,this._$AH=f,this._$AN=void 0,this.element=e,this.name=t,this._$AM=o,this.options=i,n.length>2||n[0]!==""||n[1]!==""?(this._Line truncated
|
||||
|
||||
Ein Plugin l\xE4uft mit denselben Rechten wie NextFloor in deinem Browser. Die Datei wurde gepr\xFCft, ihr Inhalt ist festgelegt:
|
||||
{url}`,manual:"Anleitung",manual_more:"Mehr erfahren",feature_text_energy:"Energieteilchen fliegen in B\xF6gen von den Solarfeldern zum Wechselrichter, zwischen Haus, Akku, Netz und Verbrauchern \u2013 schneller und dichter, je mehr Strom flie\xDFt. Die Module funkeln mit ihrer Produktion, eine Glaskarte \xFCber dem Dach zeigt die Bilanz und wie autark das Haus gerade ist.",live_autarky:"autark",live_fold:"Karte verkleinern",live_unfold:"Karte aufklappen",live_day_hint:"Die letzten 24 Stunden: Solar (Fl\xE4che) und Verbrauch (Linie)",live_week_hint:"Die letzten 7 Tage: Sonne {solar} kWh, Verbrauch {use} kWh (gelb: Sonne, hell: Verbrauch)",live_days:"Tage",live_car_away:"Unterwegs",live_car_charging:"L\xE4dt",live_car_plugged:"Eingesteckt",live_car_lock:"Verriegeln",live_car_unlock:"Entriegeln",live_car_unlock_confirm:"{name} wirklich entriegeln?",live_car_climate:"Klimatisierung",live_car_charge:"Laden starten/stoppen",live_media_prev:"Zur\xFCck",live_media_playpause:"Abspielen/Pause",live_media_next:"Weiter",live_media_volume:"Lautst\xE4rke",live_car_device:"Auto (eine Entit\xE4t des Autos)",live_car_device_hint:"Ladestand, Reichweite, Laden, Stecker, Schloss und Klima findet NextFloor selbst am Ger\xE4t des Autos. Ohne Angabe nimmt es den Anwesenheitssensor des Stellplatzes.",live_car_departure_entity:"Abfahrtszeit (optional)",live_car_departure:"Abfahrt {time}",live_car_open:"Offen: {parts}",printer_printing:"druckt",printer_done:"fertig",printer_paused:"pausiert",printer_error:"Fehler",printer_idle:"bereit",printer_done_at:"fertig um {time}",printer_layer:"Schicht",printer_nozzle:"D\xFCse",printer_bed:"Bett",heatpump_heating:"heizt",heatpump_water:"macht Warmwasser",heatpump_cooling:"k\xFChlt",heatpump_defrost:"taut ab",heatpump_idle:"in Ruhe",heatpump_flow_return:"Vor- \u2192 R\xFCcklauf",heatpump_heat:"W\xE4rme",heatpump_power:"Strom",heatpump_outside:"au\xDFen",pack_missing_item:"M\xF6bel aus entferntem Pack",back_to_room:"Zur\xFCck zu {room}",back_to_floor:"Zur\xFCck zur Etage",hint_furniture:"Raum antippen, dann rechts ein M\xF6belst\xFCck w\xE4hlen \xB7 M\xF6bel ziehen, an den Ecken die Gr\xF6\xDFe \xE4ndern",furniture_into:"Neue M\xF6bel kommen in die Mitte von \u201E{room}\u201C.",furniture_pick_room:"Tipp: Erst einen Raum antippen \u2013 dann landen neue M\xF6bel in seiner Mitte.",flows:"Stromfluss",flows_hint:"Energieb\xF6gen zwischen Solarfeldern, Wechselrichter, Akku, Netz und Verbrauchern ein- oder ausblenden",chk_title:"Einrichtung",chk_hint:"Was der Energiefluss braucht. Antippen springt an die Stelle.",chk_solar:"Solarfeld angelegt",chk_solar_add:"Ein Solarfeld aufs Dach legen",chk_meter:"Stromz\xE4hler mit Netzsensor",chk_meter_sensor:"Stromz\xE4hler: Netzsensor (W) fehlt",chk_meter_add:"Stromz\xE4hler anlegen",chk_inverter:"Wechselrichter mit Leistungssensor",chk_inverter_sensor:"Wechselrichter: Leistungssensor fehlt",chk_inverter_add:"Wechselrichter anlegen",chk_battery:"Stromspeicher mit Leistung und Ladestand",chk_battery_sensor:"Stromspeicher: Leistung oder Ladestand fehlt",chk_battery_opt:"Stromspeicher (optional)",chk_grid:"Netzanschluss gesetzt",chk_grid_opt:"Netzanschluss (optional, sonst automatisch)",energy_sign_grid:"Das Haus zeigt Einspeisung, obwohl die Sonne nichts liefert. Der Netzsensor hat wahrscheinlich das umgekehrte Vorzeichen.",energy_sign_battery:"Der Speicher l\xE4dt ohne Sonne und ohne Netzbezug. Sein Sensor hat wahrscheinlich das umgekehrte Vorzeichen.",energy_sign_flip:"Vorzeichen umkehren",help_title:"Hilfe und R\xFCckmeldung",help_hint:"Fehler bitte als Issue auf GitHub, W\xFCnsche als Diskussion \u2013 so geht nichts verloren, und alle sehen den Stand.",help_issue:"Problem melden",help_idea:"Idee vorschlagen",furn_name:"Name (optional)",furn_mirror:"Spiegeln",furn_mirror_hint:"Links und rechts vertauschen \u2013 das L-Sofa andersherum, der Schrank mit der T\xFCr auf der anderen Seite, die K\xFCchenzeile gespiegelt.",hint_opening:"Auf eine Wand tippen, um eine T\xFCr oder ein Fenster einzusetzen \u2013 die Art w\xE4hlst du danach rechts",preset_door:"T\xFCr",preset_door_double:"Doppelt\xFCr",preset_window:"Fenster",preset_window_double:"Fenster 2-fl\xFCgelig",preset_terrace:"Terrassent\xFCr",preset_terrace_double:"Terrassent\xFCr 2-fl\xFCgelig",preset_lift_slide:"Hebe-Schiebet\xFCr",preset_garage:"Garagentor",preset_front:"Haust\xFCr",opening_style:"Stil",sidelight_auto:"automatisch",sidelight_hinge:"Seitenteil an der Anschlagseite",sidelight_hinge_hint:"Das Seitenteil sitzt sonst gegen\xFCber dem Anschlag; mit Haken neben den B\xE4ndern.",sidelight_width:"Breite Seitenteil (m)",sidelight_width_left:"Seitenteil links (m)",sidelight_width_right:"Seitenteil rechts (m)",style_auto:"Automatisch ({style})",style_interior:"Zimmert\xFCr",style_front:"Haust\xFCr",style_front_glass:"Haust\xFCr mit Glasausschnitt",style_sidelight:"Haust\xFCr mit Seitenteil",style_sidelights:"Haust\xFCr mit 2 Seitenteilen",style_glass:"Glast\xFCr",style_sliding:"Schiebet\xFCr",style_p
Line truncated
|
||||
@@ -3278,7 +3278,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
|
||||
inset: auto 16px 16px;
|
||||
color: var(--nf-danger);
|
||||
}
|
||||
`]};customElements.get("nf-view3d")||customElements.define("nf-view3d",ui);function se(r,e){return Math.abs(e)>=1e3?`${O(r,e/1e3,1)} kW`:`${Math.round(e)} W`}function ci(r){return r.type==="tv_board"?r.h+.9:r.type==="tv_wall"||r.type==="kitchen_wall"?r.h+.25:r.h+.35}function bm(r,e){let t=e.attributes.percentage;return e.state==="on"&&typeof t=="number"?`${Math.round(t)} %`:ee(r,e)}var Ac;function Ec(){let r=new URL("./nextfloor-editor.js?v=85ae4159b3e8",new URL(import.meta.url)).href;return Ac??=import(r),Ac}var wm=.25,Rc=r=>Math.round(r*1e3)/1e3,zc=(r,e,t)=>r.rooms.find(n=>n.points.length>=3&&H([e,t],n.points));function hi(r,e,t,n,o){let i=zc(r,e,t);if(!i)return[n,o];let s=(a,l)=>H([a,l],i.points);return s(n,o)?[n,o]:s(n,t)?[n,t]:s(e,o)?[e,o]:[e,t]}function vm(r,e,t,n){return r.rooms.some(o=>o.id!==e.id&&o.points.some((i,s)=>{let a=o.points[(s+1)%o.points.length];return Math.abs(oe(Z(i,t),n))<.02&&Math.abs(oe(Z(a,t),n))<.02}))}var di=(r,e)=>Math.abs((r-e+540)%360-180);function Tc(r,e,t,n=wm){let o=zc(r,e.x,e.z);if(!o)return null;let i=o.points,s=et(i)>=0?1:-1,a=null;return i.forEach((l,c)=>{let u=i[(c+1)%i.length],d=Te(Z(u,l));if(d<.3)return;let p=[(u[0]-l[0])/d,(u[1]-l[1])/d],h=[-p[1]*s,p[0]*s],w=oe(Z([e.x,e.z],l),p);if(w<0||w>d)return;let b=vm(r,o,l,h)?t/2:0,g=oe(Z([e.x,e.z],l),h)-b,_=Math.atan2(-h[0],h[1])*180/Math.PI,$=[{rotation:_,extent:e.d/2},{rotation:_+90,extent:e.w/2},{rotation:_-90,extent:e.w/2}].reduce((y,F)=>di(e.rotation,F.rotation)<di(e.rotation,y.rotation)?F:y);if(di(e.rotation,$.rotation)>50)return;let x=g-$.extent;Math.abs(x)>n||a&&Math.abs(x)>=Math.abs(a.gap)||(a={x:Rc(e.x-h[0]*x),z:Rc(e.z-h[1]*x),rotation:(Math.round($.rotation)%360+360)%360,gap:x})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}function Er(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.furniture.find(s=>s.id===e);i&&t(i,o)}return n}function Rr(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.placements.find(s=>s.entity_id===e);i&&t(i,o)}return n}function Fc(r,e){let t=structuredClone(r);for(let n of t.floors)n.furniture=n.furniture.filter(o=>o.id!==e);return t}function Dc(r,e){let t=structuredClone(r);for(let n of t.floors)n.placements=n.placements.filter(o=>o.entity_id!==e);return t}function Pc(r,e,t,n){return Rr(r,e,(o,i)=>{[o.x,o.z]=hi(i,o.x,o.z,t,n)})}function Hc(r,e,t,n){let o=r.settings.wall_interior??.12;return Er(r,e,(i,s)=>{[i.x,i.z]=hi(s,i.x,i.z,t,n);let a=Tc(s,i,o);a&&Object.assign(i,a)})}var pi=(r,e)=>((r+e)%360+360)%360,Ic=r=>Number.parseFloat(r.replace(",",".")),wn=(r,e)=>Math.round(r*10**e)/10**e;function mi(r){let{min:e,max:t,accepts:n=()=>!0}=r,o=i=>{let s=Ic(i.target.value);!Number.isFinite(s)||!n(s)||r.apply(t===void 0?s:Math.min(t,Math.max(e,s)))};return m`<label class="nf-size" title=${r.title}
|
||||
`]};customElements.get("nf-view3d")||customElements.define("nf-view3d",ui);function se(r,e){return Math.abs(e)>=1e3?`${O(r,e/1e3,1)} kW`:`${Math.round(e)} W`}function ci(r){return r.type==="tv_board"?r.h+.9:r.type==="tv_wall"||r.type==="kitchen_wall"?r.h+.25:r.h+.35}function bm(r,e){let t=e.attributes.percentage;return e.state==="on"&&typeof t=="number"?`${Math.round(t)} %`:ee(r,e)}var Ac;function Ec(){let r=new URL("./nextfloor-editor.js?v=37bfd8f9f2b7",new URL(import.meta.url)).href;return Ac??=import(r),Ac}var wm=.25,Rc=r=>Math.round(r*1e3)/1e3,zc=(r,e,t)=>r.rooms.find(n=>n.points.length>=3&&H([e,t],n.points));function hi(r,e,t,n,o){let i=zc(r,e,t);if(!i)return[n,o];let s=(a,l)=>H([a,l],i.points);return s(n,o)?[n,o]:s(n,t)?[n,t]:s(e,o)?[e,o]:[e,t]}function vm(r,e,t,n){return r.rooms.some(o=>o.id!==e.id&&o.points.some((i,s)=>{let a=o.points[(s+1)%o.points.length];return Math.abs(oe(Z(i,t),n))<.02&&Math.abs(oe(Z(a,t),n))<.02}))}var di=(r,e)=>Math.abs((r-e+540)%360-180);function Tc(r,e,t,n=wm){let o=zc(r,e.x,e.z);if(!o)return null;let i=o.points,s=et(i)>=0?1:-1,a=null;return i.forEach((l,c)=>{let u=i[(c+1)%i.length],d=Te(Z(u,l));if(d<.3)return;let p=[(u[0]-l[0])/d,(u[1]-l[1])/d],h=[-p[1]*s,p[0]*s],w=oe(Z([e.x,e.z],l),p);if(w<0||w>d)return;let b=vm(r,o,l,h)?t/2:0,g=oe(Z([e.x,e.z],l),h)-b,_=Math.atan2(-h[0],h[1])*180/Math.PI,$=[{rotation:_,extent:e.d/2},{rotation:_+90,extent:e.w/2},{rotation:_-90,extent:e.w/2}].reduce((y,F)=>di(e.rotation,F.rotation)<di(e.rotation,y.rotation)?F:y);if(di(e.rotation,$.rotation)>50)return;let x=g-$.extent;Math.abs(x)>n||a&&Math.abs(x)>=Math.abs(a.gap)||(a={x:Rc(e.x-h[0]*x),z:Rc(e.z-h[1]*x),rotation:(Math.round($.rotation)%360+360)%360,gap:x})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}function Er(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.furniture.find(s=>s.id===e);i&&t(i,o)}return n}function Rr(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.placements.find(s=>s.entity_id===e);i&&t(i,o)}return n}function Fc(r,e){let t=structuredClone(r);for(let n of t.floors)n.furniture=n.furniture.filter(o=>o.id!==e);return t}function Dc(r,e){let t=structuredClone(r);for(let n of t.floors)n.placements=n.placements.filter(o=>o.entity_id!==e);return t}function Pc(r,e,t,n){return Rr(r,e,(o,i)=>{[o.x,o.z]=hi(i,o.x,o.z,t,n)})}function Hc(r,e,t,n){let o=r.settings.wall_interior??.12;return Er(r,e,(i,s)=>{[i.x,i.z]=hi(s,i.x,i.z,t,n);let a=Tc(s,i,o);a&&Object.assign(i,a)})}var pi=(r,e)=>((r+e)%360+360)%360,Ic=r=>Number.parseFloat(r.replace(",",".")),wn=(r,e)=>Math.round(r*10**e)/10**e;function mi(r){let{min:e,max:t,accepts:n=()=>!0}=r,o=i=>{let s=Ic(i.target.value);!Number.isFinite(s)||!n(s)||r.apply(t===void 0?s:Math.min(t,Math.max(e,s)))};return m`<label class="nf-size" title=${r.title}
|
||||
>${r.label}
|
||||
<input type="number" inputmode="decimal" step=${r.step} min=${e} max=${t??f} .value=${String(wn(r.value,2))} @change=${o} />
|
||||
</label>`}var Nc=(r,e)=>m`<button class="nf-chip" @click=${e}>${r.t("height_auto")}</button>`,Cc=(r,e)=>m`<button class="nf-chip" @click=${()=>e(-r)}>↺ ${r}°</button><button class="nf-chip" @click=${()=>e(r)}>↻ ${r}°</button>`;function ym(r,e){let t=r.building.floors.find(s=>s.furniture.some(a=>a.id===e)),n=t?.furniture.find(s=>s.id===e);if(!t||!n)return f;let o=(s,a)=>mi({label:r.t(a),title:r.t(`size_${s}`),value:n[s],step:.05,min:.05,accepts:l=>l>0,apply:l=>r.editFurniture(e,c=>c[s]=wn(l,3))}),i=ms(n)?m`${mi({label:"\u2195",title:r.t("mount_height"),value:n.mount_y??le(t,n),step:.05,min:0,accepts:s=>s>=0,apply:s=>r.editFurniture(e,a=>a.mount_y=wn(s,3))})}
|
||||
@@ -4192,7 +4192,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
|
||||
${n.showBar&&e?this.renderBar(n):f}
|
||||
${this.renderCorners()}
|
||||
</div>
|
||||
</ha-card>`}static styles=[Se,Ve,Uc,ur]};if(!customElements.get("nextfloor-card")){customElements.define("nextfloor-card",bi);let r=window;r.customCards=r.customCards??[],r.customCards.push({type:"nextfloor-card",name:R(void 0,"card_name"),description:R(void 0,"card_description"),preview:!1})}Xr();function Sm(){let r=window.__NEXTFLOOR_SYMCON__;if(!r?.endpoint||!r.token)throw new Error("NextFloor Symcon host configuration is missing");return r}async function Dr(r,e,t={}){let n=await fetch(`${r.endpoint}/api?token=${encodeURIComponent(r.token)}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},credentials:"same-origin",body:JSON.stringify({action:e,...t})}),o=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok||!o||typeof o!="object"||"error"in o){let i=o&&typeof o=="object"&&"error"in o?o.error:`HTTP ${n.status}`;throw new Error(String(i))}return o}var Pr=class{settings=Sm();changeListeners=new Set;buildingListeners=new Set;timer;stateRevision=-1;buildingRevision=-1;states={};entities={};areas={};facade={language:this.settings.language||navigator.language||"de",user:{is_admin:!0,name:this.settings.title||"IP-Symcon"},states:this.states,entities:this.entities,areas:this.areas,config:{unit_system:{temperature:"\xB0C"}},themes:{darkMode:window.matchMedia?.("(prefers-color-scheme: dark)").matches??!0},services:{},connection:{subscribeMessage:async(e,t)=>{if(t.type==="nextfloor/building/subscribe"){let n=o=>e({revision:o});return this.buildingListeners.add(n),async()=>{this.buildingListeners.delete(n)}}return async()=>{}}},callWS:e=>this.callWS(e),callService:(e,t,n)=>this.callService(e,t,n),fetchWithAuth:(e,t)=>this.fetchWithToken(e,t),hassUrl:(e="")=>new URL(e,window.location.origin).href};async start(){let e=await Dr(this.settings,"bootstrap");return this.apply(e),this.stateRevision=e.state_revision,this.buildingRevision=e.building_revision,this.timer=setInterval(()=>{this.refresh()},800),this.snapshot()}stop(){this.timer&&clearInterval(this.timer),this.timer=void 0}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}snapshot(){return{...this.facade,states:{...this.states},entities:{...this.entities},areas:{...this.areas}}}async refresh(){try{let e=await Dr(this.settings,"variables/snapshot",{revision:this.stateRevision});if(e.state_revision!==this.stateRevision&&e.variables){this.stateRevision=e.state_revision,this.apply({variables:e.variables,areas:e.areas});for(let t of this.changeListeners)t()}if(e.building_revision!==this.buildingRevision){this.buildingRevision=e.building_revision;for(let t of this.buildingListeners)t(e.building_revision)}}catch{}}apply(e){this.states=Object.fromEntries(e.variables.map(t=>[t.entity_id,{entity_id:t.entity_id,state:t.state,attributes:{...t.attributes,friendly_name:t.name,symcon_path:t.path}}])),this.entities=Object.fromEntries(e.variables.map(t=>[t.entity_id,{entity_id:t.entity_id,name:t.name,area_id:t.area_id??null,device_id:t.device_id??null}])),e.areas&&(this.areas=Object.fromEntries(e.areas.map(t=>[t.area_id,t]))),this.facade.states=this.states,this.facade.entities=this.entities,this.facade.areas=this.areas}async callWS(e){let t=String(e.type??"");if(!t.startsWith("nextfloor/"))throw new Error(`Unsupported Symcon websocket command: ${t}`);let{type:n,...o}=e;return Dr(this.settings,t.slice(10),o)}async callService(e,t,n={}){return Dr(this.settings,"variables/action",{domain:e,service:t,data:n})}fetchWithToken(e,t={}){let n=new URL(e,window.location.origin);return n.searchParams.set("token",this.settings.token),fetch(n,{...t,credentials:"same-origin"})}};function Mm(){return new URLSearchParams(window.location.search).get("mode")==="tile"?"tile":"designer"}async function $m(){let r=new Pr,e=await r.start(),t=Mm()==="tile",n=t?document.createElement("nextfloor-card"):document.createElement("nextfloor-panel");n.className=t?"nf-symcon-tile":"nf-symcon-designer",n.hass=e,t?n.setConfig({type:"custom:nextfloor-card",fill:!0,room_buttons:!0,controls:!0,weather:!1,announcements:!1}):n.narrow=!1,document.body.replaceChildren(n),r.onChange(()=>{n.hass=r.snapshot()}),window.addEventListener("pagehide",()=>r.stop(),{once:!0})}$m().catch(r=>{document.body.textContent=`NextFloor konnte nicht geladen werden: ${r instanceof Error?r.message:String(r)}`});
|
||||
</ha-card>`}static styles=[Se,Ve,Uc,ur]};if(!customElements.get("nextfloor-card")){customElements.define("nextfloor-card",bi);let r=window;r.customCards=r.customCards??[],r.customCards.push({type:"nextfloor-card",name:R(void 0,"card_name"),description:R(void 0,"card_description"),preview:!1})}Xr();function Sm(){let r=window.__NEXTFLOOR_SYMCON__;if(!r?.endpoint||!r.token)throw new Error("NextFloor Symcon host configuration is missing");return r}async function Dr(r,e,t={}){let n=await fetch(`${r.endpoint}/api?token=${encodeURIComponent(r.token)}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},credentials:"same-origin",body:JSON.stringify({action:e,...t})}),o=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok||!o||typeof o!="object"||"error"in o){let i=o&&typeof o=="object"&&"error"in o?o.error:`HTTP ${n.status}`;throw new Error(String(i))}return o}var Pr=class{settings=Sm();changeListeners=new Set;buildingListeners=new Set;timer;stateRevision=-1;buildingRevision=-1;objectsSignature="";states={};entities={};areas={};facade={language:this.settings.language||navigator.language||"de",user:{is_admin:!0,name:this.settings.title||"IP-Symcon"},states:this.states,entities:this.entities,areas:this.areas,symconObjects:[],config:{unit_system:{temperature:"\xB0C"}},themes:{darkMode:window.matchMedia?.("(prefers-color-scheme: dark)").matches??!0},services:{},connection:{subscribeMessage:async(e,t)=>{if(t.type==="nextfloor/building/subscribe"){let n=o=>e({revision:o});return this.buildingListeners.add(n),async()=>{this.buildingListeners.delete(n)}}return async()=>{}}},callWS:e=>this.callWS(e),callService:(e,t,n)=>this.callService(e,t,n),fetchWithAuth:(e,t)=>this.fetchWithToken(e,t),hassUrl:(e="")=>new URL(e,window.location.origin).href};async start(){let e=await Dr(this.settings,"bootstrap");return this.apply(e),this.stateRevision=e.state_revision,this.buildingRevision=e.building_revision,this.timer=setInterval(()=>{this.refresh()},800),this.snapshot()}stop(){this.timer&&clearInterval(this.timer),this.timer=void 0}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}snapshot(){return{...this.facade,states:{...this.states},entities:{...this.entities},areas:{...this.areas}}}async refresh(){try{let e=await Dr(this.settings,"variables/snapshot",{revision:this.stateRevision});if(e.state_revision!==this.stateRevision&&e.variables){this.stateRevision=e.state_revision,this.apply({variables:e.variables,areas:e.areas,objects:e.objects});for(let t of this.changeListeners)t()}if(e.building_revision!==this.buildingRevision){this.buildingRevision=e.building_revision;for(let t of this.buildingListeners)t(e.building_revision)}}catch{}}apply(e){if(this.states=Object.fromEntries(e.variables.map(t=>[t.entity_id,{entity_id:t.entity_id,state:t.state,attributes:{...t.attributes,friendly_name:t.name,symcon_path:t.path}}])),this.entities=Object.fromEntries(e.variables.map(t=>[t.entity_id,{entity_id:t.entity_id,name:t.name,area_id:t.area_id??null,device_id:t.device_id??null}])),e.areas&&(this.areas=Object.fromEntries(e.areas.map(t=>[t.area_id,t]))),this.facade.states=this.states,this.facade.entities=this.entities,this.facade.areas=this.areas,e.objects){let t=JSON.stringify(e.objects);t!==this.objectsSignature&&(this.facade.symconObjects=e.objects,this.objectsSignature=t)}}async callWS(e){let t=String(e.type??"");if(!t.startsWith("nextfloor/"))throw new Error(`Unsupported Symcon websocket command: ${t}`);let{type:n,...o}=e;return Dr(this.settings,t.slice(10),o)}async callService(e,t,n={}){return Dr(this.settings,"variables/action",{domain:e,service:t,data:n})}fetchWithToken(e,t={}){let n=new URL(e,window.location.origin);return n.searchParams.set("token",this.settings.token),fetch(n,{...t,credentials:"same-origin"})}};function Mm(){return new URLSearchParams(window.location.search).get("mode")==="tile"?"tile":"designer"}async function $m(){let r=new Pr,e=await r.start(),t=Mm()==="tile",n=t?document.createElement("nextfloor-card"):document.createElement("nextfloor-panel");n.className=t?"nf-symcon-tile":"nf-symcon-designer",n.hass=e,t?n.setConfig({type:"custom:nextfloor-card",fill:!0,room_buttons:!0,controls:!0,weather:!1,announcements:!1}):n.narrow=!1,document.body.replaceChildren(n),r.onChange(()=>{n.hass=r.snapshot()}),window.addEventListener("pagehide",()=>r.stop(),{once:!0})}$m().catch(r=>{document.body.textContent=`NextFloor konnte nicht geladen werden: ${r instanceof Error?r.message:String(r)}`});
|
||||
/*! Bundled license information:
|
||||
|
||||
@lit/reactive-element/css-tag.js:
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -12,6 +12,12 @@
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "Button",
|
||||
"caption": "WebHook reparieren",
|
||||
"onClick": "echo NFSC_RepairWebHook($id);",
|
||||
"link": false
|
||||
},
|
||||
{
|
||||
"type": "Button",
|
||||
"caption": "Designer in der Konsole öffnen",
|
||||
@@ -27,6 +33,16 @@
|
||||
}
|
||||
],
|
||||
"status": [
|
||||
{
|
||||
"code": 104,
|
||||
"icon": "inactive",
|
||||
"caption": "Warte auf den Symcon-Start; WebHook wird automatisch registriert"
|
||||
},
|
||||
{
|
||||
"code": 200,
|
||||
"icon": "error",
|
||||
"caption": "WebHook-Registrierung fehlgeschlagen – WebHook reparieren oder Log prüfen"
|
||||
},
|
||||
{
|
||||
"code": 102,
|
||||
"icon": "active",
|
||||
|
||||
+128
-12
@@ -26,25 +26,51 @@ class NextFloor extends IPSModuleStrict
|
||||
$this->RegisterAttributeString('History', '[]');
|
||||
$this->RegisterAttributeString('AccessToken', '');
|
||||
$this->RegisterAttributeString('StateHash', '');
|
||||
$this->RegisterAttributeString('HookError', '');
|
||||
$this->RegisterAttributeInteger('BuildingRevision', 0);
|
||||
$this->RegisterAttributeInteger('StateRevision', 0);
|
||||
$this->RegisterMessage(0, IPS_KERNELSTARTED);
|
||||
$this->RegisterTimer('WebHookRetry', 0, 'NFSC_RetryWebHook($_IPS[\'TARGET\']);');
|
||||
|
||||
$this->ensureAccessToken();
|
||||
$this->SetVisualizationType(1);
|
||||
$this->RegisterHook($this->hookPath());
|
||||
$this->ensureWebHook();
|
||||
}
|
||||
|
||||
public function ApplyChanges(): void
|
||||
{
|
||||
parent::ApplyChanges();
|
||||
$this->SetVisualizationType(1);
|
||||
$this->RegisterHook($this->hookPath());
|
||||
$this->SetStatus(102);
|
||||
$this->ensureWebHook();
|
||||
}
|
||||
|
||||
public function MessageSink(int $TimeStamp, int $SenderID, int $Message, array $Data): void
|
||||
{
|
||||
parent::MessageSink($TimeStamp, $SenderID, $Message, $Data);
|
||||
if ($SenderID === 0 && $Message === IPS_KERNELSTARTED) {
|
||||
$this->ensureWebHook();
|
||||
}
|
||||
}
|
||||
|
||||
/** Timer callback; stops itself as soon as the volatile hook has been restored. */
|
||||
public function RetryWebHook(): void
|
||||
{
|
||||
$this->ensureWebHook();
|
||||
}
|
||||
|
||||
/** Explicit recovery from the console without recreating the instance or changing its project. */
|
||||
public function RepairWebHook(): string
|
||||
{
|
||||
if (!$this->ensureWebHook()) {
|
||||
return $this->hookErrorMessage();
|
||||
}
|
||||
return 'WebHook registriert: /hook/' . $this->hookPath() . '. Jetzt den Designer öffnen.';
|
||||
}
|
||||
|
||||
/** URL returned to the console form. It opens in a console tab, as IPSView does. */
|
||||
public function OpenDesigner(): string
|
||||
{
|
||||
$this->requireWebHook();
|
||||
// `link:` is the documented Form-Button marker for a relative Symcon WebHook URL.
|
||||
return 'link:' . $this->designerUrl('designer');
|
||||
}
|
||||
@@ -52,6 +78,7 @@ class NextFloor extends IPSModuleStrict
|
||||
/** Invalidates links from copied browser history and returns a fresh designer URL. */
|
||||
public function RotateAccessToken(): string
|
||||
{
|
||||
$this->requireWebHook();
|
||||
$this->WriteAttributeString('AccessToken', $this->newToken());
|
||||
return 'link:' . $this->designerUrl('designer');
|
||||
}
|
||||
@@ -59,6 +86,10 @@ class NextFloor extends IPSModuleStrict
|
||||
/** The custom tile is deliberately an iframe: the full 3D viewer can lazy-load its assets via the same protected hook. */
|
||||
public function GetVisualizationTile(): string
|
||||
{
|
||||
if (!$this->ensureWebHook()) {
|
||||
return '<div style="padding:16px;font-family:system-ui">'
|
||||
. htmlspecialchars($this->hookErrorMessage(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . '</div>';
|
||||
}
|
||||
$src = htmlspecialchars($this->designerUrl('tile'), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
return '<style>html,body{margin:0;width:100%;height:100%;overflow:hidden}iframe{display:block;width:100%;height:100%;min-height:260px;border:0;background:#111}</style>'
|
||||
. '<iframe title="NextFloor" src="' . $src . '" loading="eager" allow="fullscreen"></iframe>';
|
||||
@@ -67,7 +98,11 @@ class NextFloor extends IPSModuleStrict
|
||||
/** IP-Symcon calls this for /hook/nextfloor/<instance id>/... */
|
||||
protected function ProcessHookData(): void
|
||||
{
|
||||
$path = (string) (parse_url((string) ($_SERVER['REQUEST_URI'] ?? ''), PHP_URL_PATH) ?? '');
|
||||
$requestPath = (string) ($_SERVER['REQUEST_URI'] ?? '');
|
||||
if ($requestPath === '') {
|
||||
$requestPath = (string) ($_SERVER['SCRIPT_NAME'] ?? '');
|
||||
}
|
||||
$path = (string) (parse_url($requestPath, PHP_URL_PATH) ?? '');
|
||||
$prefix = '/hook/' . $this->hookPath();
|
||||
if (!str_starts_with($path, $prefix)) {
|
||||
$this->sendError(404, 'not_found');
|
||||
@@ -101,6 +136,53 @@ class NextFloor extends IPSModuleStrict
|
||||
|
||||
// --------------------------------------------------------------------- WebHook pages
|
||||
|
||||
private function ensureWebHook(): bool
|
||||
{
|
||||
// Native hooks are volatile. Create/ApplyChanges can run before WebHook Control is ready;
|
||||
// register again after the kernel has started and whenever a designer/tile link is requested.
|
||||
if (IPS_GetKernelRunlevel() !== KR_READY) {
|
||||
$this->SetStatus(104);
|
||||
$this->SetTimerInterval('WebHookRetry', 5000);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$registered = $this->RegisterHook($this->hookPath());
|
||||
// Older native implementations return void; an explicit false reports rejection.
|
||||
if ($registered === false) {
|
||||
throw new RuntimeException('Symcon hat die Registrierung von /hook/' . $this->hookPath() . ' abgelehnt.');
|
||||
}
|
||||
} catch (Throwable $error) {
|
||||
$message = $error->getMessage();
|
||||
if ($message !== $this->ReadAttributeString('HookError')) {
|
||||
$this->LogMessage('WebHook-Registrierung fehlgeschlagen: ' . $message, KL_ERROR);
|
||||
}
|
||||
$this->WriteAttributeString('HookError', $message);
|
||||
$this->SetStatus(200);
|
||||
$this->SetTimerInterval('WebHookRetry', 5000);
|
||||
return false;
|
||||
}
|
||||
$this->WriteAttributeString('HookError', '');
|
||||
$this->SetTimerInterval('WebHookRetry', 0);
|
||||
$this->SetStatus(102);
|
||||
return true;
|
||||
}
|
||||
|
||||
private function requireWebHook(): void
|
||||
{
|
||||
if (!$this->ensureWebHook()) {
|
||||
throw new RuntimeException($this->hookErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function hookErrorMessage(): string
|
||||
{
|
||||
if (IPS_GetKernelRunlevel() !== KR_READY) {
|
||||
return 'IP-Symcon startet noch. Der NextFloor-WebHook wird nach dem Start automatisch registriert.';
|
||||
}
|
||||
return 'NextFloor-WebHook nicht verfügbar: ' . $this->ReadAttributeString('HookError')
|
||||
. ' Bitte in der NextFloor-Instanz „WebHook reparieren“ ausführen.';
|
||||
}
|
||||
|
||||
private function hookPath(): string
|
||||
{
|
||||
return 'nextfloor/' . $this->InstanceID;
|
||||
@@ -159,7 +241,8 @@ class NextFloor extends IPSModuleStrict
|
||||
'language' => 'de',
|
||||
'title' => $this->ReadPropertyString('Title') ?: 'NextFloor'
|
||||
];
|
||||
$asset = '/hook/' . $this->hookPath() . '/assets/nextfloor-designer.js?token=' . rawurlencode($this->ensureAccessToken());
|
||||
$asset = '/hook/' . $this->hookPath() . '/assets/nextfloor-designer.js?v=' . rawurlencode($this->moduleVersion())
|
||||
. '&token=' . rawurlencode($this->ensureAccessToken());
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
header('Cache-Control: no-store');
|
||||
echo '<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">'
|
||||
@@ -239,7 +322,8 @@ class NextFloor extends IPSModuleStrict
|
||||
'state_revision' => $stateRevision,
|
||||
'building_revision' => $this->ReadAttributeInteger('BuildingRevision'),
|
||||
'variables' => $objects['variables'],
|
||||
'areas' => $objects['areas']
|
||||
'areas' => $objects['areas'],
|
||||
'objects' => $objects['objects']
|
||||
];
|
||||
}
|
||||
|
||||
@@ -254,24 +338,40 @@ class NextFloor extends IPSModuleStrict
|
||||
if ($stateRevision !== $knownRevision) {
|
||||
$result['variables'] = $objects['variables'];
|
||||
$result['areas'] = $objects['areas'];
|
||||
$result['objects'] = $objects['objects'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** Returns every selectable variable and every category that can serve as a room area. */
|
||||
/** Export real object nodes, not paths reconstructed from variable names. */
|
||||
private function objectTree(): array
|
||||
{
|
||||
$variables = [];
|
||||
$areas = [];
|
||||
$nodes = [];
|
||||
foreach (IPS_GetChildrenIDs(0) as $child) {
|
||||
$this->collectObjects($child, [], null, $variables, $areas);
|
||||
$this->collectObjects($child, [], null, $variables, $areas, $nodes);
|
||||
}
|
||||
$byVariable = [];
|
||||
foreach ($variables as $variable) {
|
||||
$byVariable[$variable['attributes']['symcon_id']] = $variable['entity_id'];
|
||||
}
|
||||
// A link stays at its original position in the tree and selects its target variable.
|
||||
foreach ($nodes as &$node) {
|
||||
if ($node['object_type'] === 6) {
|
||||
$target = (int) IPS_GetLink($node['object_id'])['TargetID'];
|
||||
if (isset($byVariable[$target])) {
|
||||
$node['entity_id'] = $byVariable[$target];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($node);
|
||||
usort($variables, static fn(array $a, array $b): int => strnatcasecmp($a['path'], $b['path']));
|
||||
usort($areas, static fn(array $a, array $b): int => strnatcasecmp($a['name'], $b['name']));
|
||||
return ['variables' => $variables, 'areas' => $areas];
|
||||
return ['variables' => $variables, 'areas' => $areas, 'objects' => $nodes];
|
||||
}
|
||||
|
||||
private function collectObjects(int $objectID, array $parents, ?int $nearestCategory, array &$variables, array &$areas): void
|
||||
private function collectObjects(int $objectID, array $parents, ?int $nearestCategory, array &$variables, array &$areas, array &$nodes): void
|
||||
{
|
||||
if (!IPS_ObjectExists($objectID)) {
|
||||
return;
|
||||
@@ -280,15 +380,31 @@ class NextFloor extends IPSModuleStrict
|
||||
$name = IPS_GetName($objectID);
|
||||
$path = [...$parents, $name];
|
||||
$type = (int) $object['ObjectType'];
|
||||
$node = [
|
||||
'object_id' => $objectID,
|
||||
'parent_id' => (int) $object['ParentID'],
|
||||
'name' => $name,
|
||||
'path' => implode(' / ', $path),
|
||||
'object_type' => $type,
|
||||
'position' => (int) $object['ObjectPosition'],
|
||||
'hidden' => (bool) $object['ObjectIsHidden'],
|
||||
'icon' => (string) $object['ObjectIcon']
|
||||
];
|
||||
if ($type === 1) { // OBJECTTYPE_INSTANCE: the logical console view separates system modules.
|
||||
$node['module_type'] = (int) IPS_GetInstance($objectID)['ModuleInfo']['ModuleType'];
|
||||
}
|
||||
if ($type === 0) { // OBJECTTYPE_CATEGORY
|
||||
$nearestCategory = $objectID;
|
||||
$areas[] = ['area_id' => 'symcon-category-' . $objectID, 'name' => implode(' / ', $path)];
|
||||
}
|
||||
if ($type === 2) { // OBJECTTYPE_VARIABLE
|
||||
$variables[] = $this->describeVariable($objectID, $name, implode(' / ', $path), $nearestCategory);
|
||||
$variable = $this->describeVariable($objectID, $name, implode(' / ', $path), $nearestCategory);
|
||||
$variables[] = $variable;
|
||||
$node['entity_id'] = $variable['entity_id'];
|
||||
}
|
||||
$nodes[] = $node;
|
||||
foreach (IPS_GetChildrenIDs($objectID) as $child) {
|
||||
$this->collectObjects($child, $path, $nearestCategory, $variables, $areas);
|
||||
$this->collectObjects($child, $path, $nearestCategory, $variables, $areas, $nodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+50
-5
@@ -16,7 +16,7 @@ In **Kerninstanzen → Modules** wird dieses Repository verwendet:
|
||||
|
||||
Im Zahnrad des Eintrags den Branch **`symcon`** wählen und auf Aktualisierungen prüfen.
|
||||
`main` enthält die Quellen für die Entwicklung, `symcon` die installierbare Bibliothek.
|
||||
Nach der Aktualisierung auf **0.1.1 / Build 2** die Konsole neu laden. Unter
|
||||
Nach der Aktualisierung auf **0.2.2 / Build 5** die Konsole neu laden. Unter
|
||||
**Instanz hinzufügen → Hersteller NextFloor** erscheint **„NextFloor Designer und 3D-Kachel“**.
|
||||
|
||||
### Für die Entwicklung
|
||||
@@ -32,8 +32,8 @@ cd frontend
|
||||
npm run build
|
||||
cd ..
|
||||
node --test symcon/tests/package.test.mjs
|
||||
git add symcon frontend/build.mjs CHANGELOG.md
|
||||
git commit -m "fix: correct Symcon module registration"
|
||||
git add symcon frontend custom_components/nextfloor/frontend CHANGELOG.md
|
||||
git commit -m "feat: add Symcon object tree picker"
|
||||
git subtree push --prefix=symcon origin symcon
|
||||
```
|
||||
|
||||
@@ -46,6 +46,48 @@ Die Dateien unter `NextFloor/assets/` und `NextFloor/packs/` werden durch
|
||||
Der Build prüft anschließend die Modulmetadaten und die installierbare Verzeichnisstruktur.
|
||||
Dieselbe Prüfung lässt sich separat mit `node symcon/tests/validate-package.mjs` ausführen.
|
||||
|
||||
## Änderungen in 0.2.2
|
||||
|
||||
- Die Datenpunktauswahl zeigt in der Hauptansicht die Objekte der Hauptkategorie.
|
||||
Ausgeblendete Kategorien bleiben inklusive aller Unterkategorien und Variablen sichtbar
|
||||
und werden als „ausgeblendet“ gekennzeichnet.
|
||||
- I/O, Splitter, Kerninstanzen, Konfiguratoren, Discovery und Visualisierungen sind unter
|
||||
einem anfangs zugeklappten virtuellen **„System“**-Ordner zusammengefasst. Die Zuordnung
|
||||
richtet sich nach dem tatsächlichen Symcon-Modultyp, nicht nach dem Namen.
|
||||
- Unterobjekte bleiben bei ihrer Systeminstanz. Suche, Vorauswahl und Bestätigung
|
||||
funktionieren auch für Systemvariablen; die echten Symcon-Objekte werden nicht verschoben.
|
||||
|
||||
## Änderungen in 0.2.1
|
||||
|
||||
- Fehlende interne WebHooks werden nach dem Symcon-Start, beim Übernehmen der
|
||||
Instanzkonfiguration und beim Öffnen von Designer oder Kachel erneut registriert.
|
||||
- Fehlgeschlagene Registrierungen erhalten einen Fehlerstatus und werden automatisch
|
||||
erneut versucht. Die Instanz meldet dann nicht mehr fälschlich „bereit“.
|
||||
- Der Button **„WebHook reparieren“** registriert den Hook direkt und zeigt das Ergebnis.
|
||||
Die bestehende Instanz, der Grundriss und der Zugangsschlüssel bleiben dabei erhalten.
|
||||
- Nach einem Update lädt der Designer seine neue JavaScript-Version statt einer
|
||||
möglicherweise noch im Browser zwischengespeicherten Vorgängerversion.
|
||||
|
||||
### Update bei „Hook not found“
|
||||
|
||||
Das vollständige Modul auf 0.2.1 aktualisieren und die NextFloor-Instanzkonfiguration
|
||||
neu öffnen. Einmal **„WebHook reparieren“**, anschließend **„Designer in der Konsole öffnen“**
|
||||
anklicken. Der Eintrag gehört unter **WebHook Control → Hooks (Intern)**; ein eigener
|
||||
PHP-Skript-Hook unter „Benutzerdefiniert“ ist nicht erforderlich. Die bestehende Instanz
|
||||
nicht neu anlegen, da ihr Plan in ihren Attributen gespeichert ist.
|
||||
|
||||
## Änderungen in 0.2.0
|
||||
|
||||
- Die Datenpunktauswahl öffnet ein Popup mit dem vollständigen Symcon-Objektbaum.
|
||||
Kategorien, Instanzen, Variablen, Skripte, Ereignisse, Medien und Links behalten
|
||||
ihre Elternobjekte, Namen und Reihenfolge (Position, Typ, Name).
|
||||
- Äste lassen sich auf- und zuklappen. Die Suche zeigt Fundstellen in ihrer Hierarchie;
|
||||
beim erneuten Öffnen ist der bisherige Datenpunkt bereits aufgeklappt und markiert.
|
||||
- Ein Klick markiert eine Variable, „Übernehmen“ bestätigt sie. Doppelklick übernimmt
|
||||
direkt; „Abbrechen“ und Escape lassen die bisherige Zuordnung unverändert.
|
||||
- Auch Variablenlinks sind auswählbar. Für das jeweilige Feld ungeeignete Objekte
|
||||
bleiben zur Orientierung im Baum sichtbar und können nicht übernommen werden.
|
||||
|
||||
## Änderungen in 0.1.1
|
||||
|
||||
- NextFloor wird als Geräteinstanz (Modultyp 3) registriert und ist damit im Dialog
|
||||
@@ -67,8 +109,11 @@ Jede Instanz besitzt einen eigenen Plan, Bilder, Möbelpakete und Versionsverlau
|
||||
|
||||
## Objektbaum statt Objekt-ID
|
||||
|
||||
Alle Variablen werden beim Öffnen des Designers aus dem Symcon-Objektbaum gelesen. In jeder
|
||||
Auswahl erscheint der vollständige Pfad, etwa `Haus / Erdgeschoss / Küche / Temperatur`.
|
||||
Alle Objekte werden beim Öffnen des Designers aus dem Symcon-Objektbaum gelesen. Ein Klick
|
||||
auf ein Datenpunktfeld öffnet ein Popup mit diesem Baum. In jeder Auswahl erscheint zusätzlich
|
||||
der vollständige Pfad, etwa `Haus / Erdgeschoss / Küche / Temperatur`.
|
||||
Die Hauptansicht enthält die Objekte der Hauptkategorie einschließlich ausgeblendeter
|
||||
Kategorien. Selten benötigte Systeminstanzen stehen im virtuellen Ordner **„System“**.
|
||||
Die Suche durchsucht Name und Pfad; eine Objekt-ID wird weder angezeigt noch als Eingabe
|
||||
akzeptiert. Kategorien stehen zusätzlich als Bereiche zur Raumzuordnung bereit.
|
||||
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
"compatibility": {
|
||||
"version": "9.0"
|
||||
},
|
||||
"version": "0.1.1",
|
||||
"build": 2,
|
||||
"version": "0.2.2",
|
||||
"build": 5,
|
||||
"date": 1794211200
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// A small native-API fixture exercises the actual module export without a running Symcon server.
|
||||
class IPSModuleStrict {}
|
||||
|
||||
$objects = [
|
||||
10 => ['ParentID' => 0, 'ObjectName' => 'Haus / Altbau', 'ObjectType' => 0, 'ObjectPosition' => 2],
|
||||
11 => ['ParentID' => 10, 'ObjectName' => 'Heizung', 'ObjectType' => 1, 'ObjectPosition' => 0],
|
||||
12 => ['ParentID' => 11, 'ObjectName' => 'Temperatur', 'ObjectType' => 2, 'ObjectPosition' => 5],
|
||||
13 => ['ParentID' => 12, 'ObjectName' => 'Bei Änderung', 'ObjectType' => 4, 'ObjectPosition' => 0],
|
||||
14 => ['ParentID' => 10, 'ObjectName' => 'Temperatur-Link', 'ObjectType' => 6, 'ObjectPosition' => 1],
|
||||
15 => ['ParentID' => 0, 'ObjectName' => 'Leer', 'ObjectType' => 0, 'ObjectPosition' => 9],
|
||||
16 => ['ParentID' => 10, 'ObjectName' => 'Skript', 'ObjectType' => 3, 'ObjectPosition' => 0],
|
||||
17 => ['ParentID' => 10, 'ObjectName' => 'Bild', 'ObjectType' => 5, 'ObjectPosition' => 0],
|
||||
18 => ['ParentID' => 0, 'ObjectName' => 'I/O', 'ObjectType' => 1, 'ObjectPosition' => 0],
|
||||
19 => ['ParentID' => 18, 'ObjectName' => 'I/O-Wert', 'ObjectType' => 2, 'ObjectPosition' => 0],
|
||||
20 => ['ParentID' => 0, 'ObjectName' => 'Kern', 'ObjectType' => 1, 'ObjectPosition' => 0],
|
||||
21 => ['ParentID' => 0, 'ObjectName' => 'Splitter', 'ObjectType' => 1, 'ObjectPosition' => 0],
|
||||
22 => ['ParentID' => 0, 'ObjectName' => 'Konfigurator', 'ObjectType' => 1, 'ObjectPosition' => 0],
|
||||
23 => ['ParentID' => 0, 'ObjectName' => 'Discovery', 'ObjectType' => 1, 'ObjectPosition' => 0],
|
||||
24 => ['ParentID' => 0, 'ObjectName' => 'Visualisierung', 'ObjectType' => 1, 'ObjectPosition' => 0]
|
||||
];
|
||||
function IPS_GetChildrenIDs(int $id): array { global $objects; return array_keys(array_filter($objects, static fn(array $object): bool => $object['ParentID'] === $id)); }
|
||||
function IPS_ObjectExists(int $id): bool { global $objects; return isset($objects[$id]); }
|
||||
function IPS_GetObject(int $id): array { global $objects; return [...$objects[$id], 'ObjectIsHidden' => in_array($id, [10, 12], true), 'ObjectIcon' => 'Temperature']; }
|
||||
function IPS_GetInstance(int $id): array { return ['ModuleInfo' => ['ModuleType' => [18 => 1, 20 => 0, 21 => 2, 22 => 4, 23 => 5, 24 => 6][$id] ?? 3]]; }
|
||||
function IPS_GetName(int $id): string { global $objects; return $objects[$id]['ObjectName']; }
|
||||
function IPS_GetLink(int $id): array { return ['TargetID' => 12]; }
|
||||
function IPS_GetVariable(int $id): array { return ['VariableType' => 2, 'VariableProfile' => '', 'VariableCustomProfile' => '', 'VariableCustomAction' => 0, 'VariableAction' => 0]; }
|
||||
function GetValue(int $id): float { return 21.5; }
|
||||
function GetValueFormatted(int $id): string { return '21,5 °C'; }
|
||||
function IPS_VariableProfileExists(string $profile): bool { return false; }
|
||||
|
||||
require __DIR__ . '/../NextFloor/module.php';
|
||||
$module = new NextFloor();
|
||||
$result = (new ReflectionMethod($module, 'objectTree'))->invoke($module);
|
||||
$nodes = array_column($result['objects'], null, 'object_id');
|
||||
function check(bool $condition, string $message): void { if (!$condition) throw new RuntimeException($message); }
|
||||
check(count($nodes) === count($objects), 'Every native object must remain visible, including empty and non-variable objects');
|
||||
check($nodes[12]['parent_id'] === 11 && $nodes[13]['parent_id'] === 12, 'Real parent IDs must be preserved');
|
||||
check($nodes[10]['name'] === 'Haus / Altbau', 'Do not split object names into artificial branches');
|
||||
check($nodes[12]['hidden'] === true && $nodes[12]['position'] === 5, 'Preserve hidden objects and console position');
|
||||
check($nodes[14]['entity_id'] === $nodes[12]['entity_id'], 'A variable link selects its original target');
|
||||
check(!isset($nodes[16]['entity_id']), 'Scripts are visible but are not variable selections');
|
||||
check($nodes[10]['hidden'] === true && $nodes[11]['parent_id'] === 10, 'Hidden categories and all their children must be exported');
|
||||
check(array_column(array_intersect_key($nodes, array_flip([18, 20, 21, 22, 23, 24])), 'module_type') === [1, 0, 2, 4, 5, 6], 'Export real module types for logical system grouping');
|
||||
check($nodes[11]['module_type'] === 3 && $nodes[19]['parent_id'] === 18, 'Keep devices and system-variable parents unchanged in native export');
|
||||
echo "OK: full native object hierarchy, positions, hidden nodes and variable links\n";
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// Exercise the actual module against a volatile, in-memory hook registry. This intentionally
|
||||
// models startup/reload losing registrations; it is not a test against a running Symcon kernel.
|
||||
const KR_READY = 10103;
|
||||
const KR_INIT = 10102;
|
||||
const IPS_KERNELSTARTED = 10001;
|
||||
const KL_ERROR = 10205;
|
||||
$kernelRunlevel = KR_INIT;
|
||||
$nativeHooks = [];
|
||||
|
||||
function IPS_GetKernelRunlevel(): int { global $kernelRunlevel; return $kernelRunlevel; }
|
||||
function check(bool $condition, string $message): void { if (!$condition) throw new RuntimeException($message); }
|
||||
|
||||
class IPSModuleStrict
|
||||
{
|
||||
protected int $InstanceID;
|
||||
public array $attributes = [];
|
||||
public array $properties = [];
|
||||
public array $messages = [];
|
||||
public array $timers = [];
|
||||
public array $logs = [];
|
||||
public int $status = 101;
|
||||
public ?bool $registrationResult = true;
|
||||
public bool $registrationThrows = false;
|
||||
|
||||
public function __construct(int $id) { $this->InstanceID = $id; }
|
||||
public function Create(): void {}
|
||||
public function ApplyChanges(): void
|
||||
{
|
||||
global $nativeHooks;
|
||||
$nativeHooks = array_filter($nativeHooks, fn(int $owner): bool => $owner !== $this->InstanceID);
|
||||
}
|
||||
public function MessageSink(int $time, int $sender, int $message, array $data): void {}
|
||||
protected function RegisterPropertyString(string $name, string $value): void { $this->properties[$name] ??= $value; }
|
||||
protected function RegisterAttributeString(string $name, string $value): void { $this->attributes[$name] ??= $value; }
|
||||
protected function RegisterAttributeInteger(string $name, int $value): void { $this->attributes[$name] ??= $value; }
|
||||
protected function ReadAttributeString(string $name): string { return $this->attributes[$name]; }
|
||||
protected function WriteAttributeString(string $name, string $value): void { $this->attributes[$name] = $value; }
|
||||
protected function ReadPropertyString(string $name): string { return $this->properties[$name]; }
|
||||
protected function RegisterMessage(int $sender, int $message): void { $this->messages[] = [$sender, $message]; }
|
||||
protected function RegisterTimer(string $name, int $interval, string $script): void { $this->timers[$name] = ['interval' => $interval, 'script' => $script]; }
|
||||
protected function SetTimerInterval(string $name, int $interval): void
|
||||
{
|
||||
check(isset($this->timers[$name]), 'Timer must have been registered in Create');
|
||||
$this->timers[$name]['interval'] = $interval;
|
||||
}
|
||||
protected function SetVisualizationType(int $type): void {}
|
||||
protected function SetStatus(int $status): void { $this->status = $status; }
|
||||
protected function LogMessage(string $message, int $type): void { $this->logs[] = [$message, $type]; }
|
||||
protected function RegisterHook(string $path): ?bool
|
||||
{
|
||||
global $nativeHooks;
|
||||
check(IPS_GetKernelRunlevel() === KR_READY, 'Do not depend on WebHook Control before the kernel is ready');
|
||||
if ($this->registrationThrows) throw new RuntimeException('WebHook Control unavailable');
|
||||
if ($this->registrationResult !== false) $nativeHooks['/hook/' . $path] = $this->InstanceID;
|
||||
return $this->registrationResult;
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../NextFloor/module.php';
|
||||
$module = new NextFloor(12345);
|
||||
$module->Create();
|
||||
check($nativeHooks === [] && $module->status === 104, 'Startup must wait instead of reporting a nonexistent hook as ready');
|
||||
check(in_array([0, IPS_KERNELSTARTED], $module->messages, true), 'Module must listen for the completed kernel startup');
|
||||
check($module->timers['WebHookRetry']['interval'] === 5000, 'Startup recovery must be scheduled');
|
||||
|
||||
$kernelRunlevel = KR_READY;
|
||||
$module->MessageSink(1, 0, IPS_KERNELSTARTED, []);
|
||||
$hook = '/hook/nextfloor/12345';
|
||||
check(($nativeHooks[$hook] ?? null) === 12345 && $module->status === 102, 'Kernel startup must restore the instance hook');
|
||||
check($module->timers['WebHookRetry']['interval'] === 0, 'Successful registration stops the retry timer');
|
||||
$token = $module->attributes['AccessToken'];
|
||||
$module->attributes['Building'] = '{"preserved_project":true}';
|
||||
|
||||
$nativeHooks = [];
|
||||
$link = $module->OpenDesigner();
|
||||
check(isset($nativeHooks[$hook]) && str_starts_with($link, 'link:' . $hook . '/designer?'), 'Opening the designer repairs a lost route before returning its URL');
|
||||
$nativeHooks = [];
|
||||
check(str_contains($module->GetVisualizationTile(), '<iframe') && isset($nativeHooks[$hook]), 'Opening a tile also repairs its route');
|
||||
$module->ApplyChanges();
|
||||
check(isset($nativeHooks[$hook]), 'ApplyChanges restores hooks after module reload');
|
||||
|
||||
$module->registrationResult = false;
|
||||
$module->ApplyChanges();
|
||||
check($module->status === 200 && !isset($nativeHooks[$hook]), 'A rejected registration must not report ready');
|
||||
check($module->timers['WebHookRetry']['interval'] === 5000, 'Rejected registration must be retried');
|
||||
$logCount = count($module->logs);
|
||||
try {
|
||||
$module->OpenDesigner();
|
||||
throw new LogicException('Must not return a dead designer URL');
|
||||
} catch (RuntimeException $error) {
|
||||
check(str_contains($error->getMessage(), 'WebHook nicht verfügbar'), 'Designer must show a useful registration error');
|
||||
}
|
||||
check(count($module->logs) === $logCount, 'Identical retry errors must not flood the log');
|
||||
check(!str_contains($module->GetVisualizationTile(), '<iframe'), 'Failure produces an explanatory tile, not a broken iframe');
|
||||
|
||||
$module->registrationResult = true;
|
||||
$module->RetryWebHook();
|
||||
check(isset($nativeHooks[$hook]) && $module->status === 102, 'Retry must recover after WebHook Control becomes available');
|
||||
$module->registrationThrows = true;
|
||||
check(str_contains($module->RepairWebHook(), 'WebHook Control unavailable'), 'Repair button reports the native registration exception');
|
||||
$module->registrationThrows = false;
|
||||
$module->registrationResult = null; // compatibility with older native return-void implementations
|
||||
check(str_contains($module->RepairWebHook(), 'WebHook registriert:'), 'A native void return is not an explicit rejection');
|
||||
check($module->attributes['AccessToken'] === $token && $module->attributes['Building'] === '{"preserved_project":true}', 'Repair must preserve project and access token');
|
||||
|
||||
$other = new NextFloor(54321);
|
||||
$other->Create();
|
||||
check(isset($nativeHooks[$hook]) && isset($nativeHooks['/hook/nextfloor/54321']), 'Instances must keep independent routes');
|
||||
|
||||
// Verify that returned URLs reach the real dispatcher, including Symcon's SCRIPT_NAME fallback.
|
||||
parse_str((string) parse_url(substr($link, 5), PHP_URL_QUERY), $_GET);
|
||||
$_SERVER['REQUEST_URI'] = $hook . '/designer';
|
||||
$process = new ReflectionMethod($module, 'ProcessHookData');
|
||||
ob_start();
|
||||
$process->invoke($module);
|
||||
$html = ob_get_clean();
|
||||
check(str_contains($html, 'window.__NEXTFLOOR_SYMCON__=') && str_contains($html, 'assets/nextfloor-designer.js'), 'Designer route must serve its host page');
|
||||
$version = json_decode((string) file_get_contents(__DIR__ . '/../library.json'), true)['version'];
|
||||
check(str_contains($html, 'nextfloor-designer.js?v=' . $version), 'A module update must invalidate the cached designer entry bundle');
|
||||
unset($_SERVER['REQUEST_URI']);
|
||||
$_SERVER['SCRIPT_NAME'] = $hook . '/designer';
|
||||
ob_start();
|
||||
$process->invoke($module);
|
||||
$fallback = ob_get_clean();
|
||||
check(str_contains($fallback, 'window.__NEXTFLOOR_SYMCON__='), 'Dispatcher must accept SCRIPT_NAME when REQUEST_URI is absent');
|
||||
$_GET['token'] = 'wrong-token';
|
||||
ob_start();
|
||||
$process->invoke($module);
|
||||
$unauthorized = ob_get_clean();
|
||||
check(http_response_code() === 403 && str_contains($unauthorized, 'forbidden'), 'Recovery must not bypass hook authentication');
|
||||
|
||||
echo "OK: kernel startup, reload, designer/tile recovery, failed registration, retry, repair, data preservation, routing and authentication\n";
|
||||
Reference in new issue
Block a user