feat: release Symcon 0.2.2 with object tree selection and hook recovery

This commit is contained in:
jhartworks committed 2026-11-09 12:50:45 +01:00
1 parent 4a875aa8ea
commit eff9eb83d7
19 files changed
+2273 -1064

No files matched your search

+14 -3
View File
@@ -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> {