feat: show metered devices below rooms in utility overview

This commit is contained in:
jhartworks committed 2026-11-12 14:44:02 +01:00
1 parent 173d02e3cc
commit df4a6f36a3
14 files changed
+1791 -1577

No files matched your search

+2
View File
@@ -6,6 +6,8 @@ All notable changes to NextFloor, newest first. Every release lists what is **Ad
### Added
- **Metered device hierarchy (Symcon 0.2.24):** Show placed devices and furniture with linked power below their plan room and native area in the right overview. Rooms without their own meter act as value-free headings; existing room counters remain separate. Device readings, including manifold pump power, retain zero/offline/live values and archive icons without changing parent totals. The hierarchy stays accessible on device-only floors.
- **Hydronic 3D equipment (Symcon 0.2.23):** Place configurable heating/cooling manifolds, buffer tanks and fresh-water stations from the furniture library. Manifolds support separate valve/pump circuits and valve-free feed pumps, independent command/readback bindings, raw-value changeover selection and visual-only valve inversion. Buffers start with seven height-configurable probe slots and support up to 64 plus flow/return; fresh-water stations expose flow, return, circulation and domestic hot water with independent charging/circulation pumps. Live pump rotors, valve pointers and probe colours accompany lazy floating cards/dialogs, archive trends and native action controls with read-only guards. Feedback stays authoritative even offline; native values and write ranges remain unchanged. Multi-reading hydraulic cards use nearby free columns to stay on screen.
- **Native area and room utility hierarchy (Symcon 0.2.22):** Floor overviews group by the linked native area ID and display its category name and readings once. Only rooms with explicitly assigned power/flow or consumption meters appear as indented children. The room editor provides native numeric meter selectors for all five media; children retain live values, archive access and navigation. Existing area totals cover room details; explicit room meters supply missing quantities without double counting and floor meters retain precedence.
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -113,7 +113,8 @@ function copySymconAssets() {
// may grow more than the view; German and English texts ride in every bundle.
// Native utility discovery/reports plus the building/floor overview need about 14 KB in the shared runtime.
// Hydronic geometry/readouts load separately; only model references, anchors and the loader join the host.
const BUDGET = { "nextfloor.js": 672 * 1024, "nextfloor-3d.js": 1000 * 1024, "nextfloor-editor.js": 720 * 1024, "nextfloor-card-editor.js": 240 * 1024, "nextfloor-trend.js": 100 * 1024, "nextfloor-hydronics.js": 100 * 1024 };
// Metered-device detail discovery adds about 2 KB; keep a small, explicit margin.
const BUDGET = { "nextfloor.js": 676 * 1024, "nextfloor-3d.js": 1000 * 1024, "nextfloor-editor.js": 720 * 1024, "nextfloor-card-editor.js": 240 * 1024, "nextfloor-trend.js": 100 * 1024, "nextfloor-hydronics.js": 100 * 1024 };
copyAssets();
copySymconAssets();
+11 -6
View File
@@ -4,7 +4,7 @@ import type { HomeAssistant } from "../types.ts";
import { buildingUtilityReadings, floorUtilityAreas, floorUtilityReadings, UTILITY_ICONS, UTILITY_LABELS, utilityMetricLabel, utilityText, type UtilityReading } from "../utilities.ts";
import { trendButton } from "./trend-button.ts";
/** Building → floors, floor → native areas → rooms with their own explicit meters. */
/** Building → floors, floor → native areas → rooms → placed devices with a linked power value. */
class NfUtilityOverview extends LitElement {
static properties = { hass: { attribute: false }, floors: { attribute: false }, floorId: { attribute: false }, inline: { type: Boolean, reflect: true }, compact: { type: Boolean }, folded: { state: true } };
declare hass: HomeAssistant;
@@ -37,9 +37,9 @@ class NfUtilityOverview extends LitElement {
return readings.length ? html`<div class="meter" aria-label=${`${floor?.name || "Gesamtgebäude"} · ${UTILITY_LABELS[kind]}`}><span class="medium" title=${floor?.name || "Gesamtgebäude"}>${UTILITY_ICONS[kind]} ${UTILITY_LABELS[kind]}</span><div class="values">${readings.map((r) => this.value(r))}</div></div>` : nothing;
})}`;
}
const entries = floor ? floorUtilityAreas(this.hass, floor, rooms)
: [...this.floors].sort((a, b) => b.elevation - a.elevation).map((f) => ({ id: f.id, name: f.name, path: "", readings: floorUtilityReadings(this.hass, f, rooms), rooms: [] }));
const shown = entries.filter((e) => e.readings.length);
const entries = floor ? floorUtilityAreas(this.hass, floor, rooms, true).map((area) => ({ ...area, hasDetails: area.rooms.length > 0 }))
: [...this.floors].sort((a, b) => b.elevation - a.elevation).map((f) => ({ id: f.id, name: f.name, path: "", readings: floorUtilityReadings(this.hass, f, rooms), rooms: [], hasDetails: floorUtilityAreas(this.hass, f, rooms, true).length > 0 }));
const shown = entries.filter((e) => e.readings.length || e.hasDetails);
if (!shown.length) return nothing;
const folded = this.folded ?? this.compact;
return html`<section class="panel" aria-label=${floor ? "Bereichszähler" : "Stockwerkszähler"}>
@@ -48,7 +48,9 @@ class NfUtilityOverview extends LitElement {
${shown.map((entry) => html`<section class="entry" data-area=${floor ? entry.id : nothing}>
${floor ? html`<div class="entry-name area-name" title=${entry.path || entry.name}>${entry.name}</div>` : html`<button class="entry-name" title=${entry.name} @click=${() => this.open(entry.id, false)}>${entry.name}</button>`}
${this.rows(entry.readings)}
${entry.rooms.map((room) => html`<section class="room-entry" data-room=${room.id}><button class="entry-name" title=${room.name} @click=${() => this.open(room.id, true)}><span aria-hidden="true">↳</span> ${room.name}</button>${this.rows(room.readings)}</section>`)}
${entry.rooms.map((room) => html`<section class="room-entry" data-room=${room.id}><button class="entry-name" title=${room.name} @click=${() => this.open(room.id, true)}><span aria-hidden="true">↳</span> ${room.name}</button>${this.rows(room.readings)}
${room.devices.map((device) => html`<section class="device-entry" data-device=${device.id}><div class="entry-name device-name" title=${device.name}><span aria-hidden="true">↳</span> ${device.name}</div>${this.rows(device.readings)}</section>`)}
</section>`)}
</section>`)}
</div>`}
</section>`;
@@ -79,7 +81,10 @@ class NfUtilityOverview extends LitElement {
.entry-name:hover { color:var(--nf-accent); }
.area-name:hover { color:inherit; }
.room-entry { margin-top:5px; padding-top:4px; border-top:1px dotted var(--nf-line); }
.room-entry .entry-name { padding-left:12px; color:var(--nf-muted); font-weight:normal; }
.room-entry>.entry-name { padding-left:12px; color:var(--nf-muted); font-weight:normal; }
.device-entry { margin-top:4px; }
.device-entry>.device-name { padding-left:24px; color:var(--nf-muted); font-weight:normal; }
.device-name:hover { color:var(--nf-muted); }
.row { min-height:20px; }
.kind { color:var(--nf-muted); font-size:10px; white-space:nowrap; }
.row .value b { font-size:11px; font-weight:normal; }
+2 -2
View File
@@ -55,7 +55,7 @@ import { fixtureGlow } from "../entities/kinds.ts";
import { coverTiltEntity } from "../entities/covers.ts";
import { isSymcon, isSymconVariable, nativeBool, nativeText } from "../entities/symcon-values.ts";
import { WEATHER_VARIABLE_LABELS } from "../symcon-weather.ts";
import { floorUtilityReadings, utilityText } from "../utilities.ts";
import { floorUtilityAreas, floorUtilityReadings, utilityText } from "../utilities.ts";
import "./utility-report.ts";
import "./utility-overview.ts";
import { trendButton } from "./trend-button.ts";
@@ -2790,7 +2790,7 @@ export class NfView3d extends LitElement {
const b = this.building;
if (!b || !isSymcon(this.hass) || !this.showEnergy || this.clean || this.roomId || this.panelOpen || (!inline && !this._utilityOverviewVisible)) return nothing;
const rooms = b.floors.flatMap((f) => f.rooms), floors = this.floorId ? b.floors.filter((f) => f.id === this.floorId) : b.floors;
if (!floors.some((f) => floorUtilityReadings(this.hass, f, rooms).length)) return nothing;
if (!floors.some((f) => floorUtilityReadings(this.hass, f, rooms).length || floorUtilityAreas(this.hass, f, rooms, true).length)) return nothing;
return html`<nf-utility-overview ?inline=${inline} .hass=${this.hass} .floors=${b.floors} .floorId=${this.floorId} .compact=${this._narrowStage}
@utility-open=${(e: CustomEvent<{ floorId: string; roomId: string | null }>) => { e.stopPropagation(); if (e.detail.roomId) this.openRoom(e.detail.floorId, e.detail.roomId); else this.fire("floor-tap", { floorId: e.detail.floorId }); }}></nf-utility-overview>`;
}
+10 -4
View File
@@ -2,6 +2,7 @@ import { UTILITY_KINDS, type Floor, type Room, type UtilityKind } from "./model.
import type { HassEntity, HomeAssistant, SymconObject } from "./types.ts";
import { isSymcon, nativeNumber } from "./entities/symcon-values.ts";
import { formatNumber } from "./i18n.ts";
import { roomDevicePowerLinks, type DevicePowerLink } from "./utility-device-power.ts";
export const UTILITY_LABELS: Record<UtilityKind, string> = { electricity: "Strom", water: "Wasser", gas: "Gas", heating: "Heizen", cooling: "Kühlen" };
export const UTILITY_ICONS: Record<UtilityKind, string> = { electricity: "⚡", water: "💧", gas: "🔥", heating: "♨", cooling: "❄" };
@@ -15,7 +16,7 @@ export interface UtilityReading {
export interface UtilityArea {
id: string; name: string; path: string; readings: UtilityReading[];
rooms: { id: string; name: string; readings: UtilityReading[] }[];
rooms: { id: string; name: string; readings: UtilityReading[]; devices: { id: string; name: string; readings: UtilityReading[] }[] }[];
}
const normalize = (s: string) => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/ß/g, "ss").replace(/[^a-z0-9]+/g, " ").trim();
@@ -144,12 +145,13 @@ export function roomUtilityReadings(hass: HomeAssistant, room: Room, rooms: read
}
/** Group by actual native category IDs, never by plan-room names or repeated meter values. */
export function floorUtilityAreas(hass: HomeAssistant, floor: Floor, rooms: readonly Room[] = floor.rooms): UtilityArea[] {
export function floorUtilityAreas(hass: HomeAssistant, floor: Floor, rooms: readonly Room[] = floor.rooms, withDevices = false): UtilityArea[] {
if (!isSymcon(hass)) return [];
const devices = withDevices ? roomDevicePowerLinks(hass, floor) : new Map<string, DevicePowerLink[]>();
const groups = new Map<string, { seed: Room; members: Room[] }>();
for (const room of floor.rooms) {
const refs = [...new Set([room.area_id, ...(room.sub_areas ?? [])].filter((id): id is string => !!areaId(id)))];
if (!refs.length && roomMeterSources(hass, room).length) refs.push("unassigned");
if (!refs.length && (roomMeterSources(hass, room).length || devices.get(room.id)?.length)) refs.push("unassigned");
for (const id of refs) {
const group = groups.get(id) ?? { seed: room, members: [] };
if (id === refs[0]) group.members.push(room);
@@ -163,7 +165,10 @@ export function floorUtilityAreas(hass: HomeAssistant, floor: Floor, rooms: read
const own = readings(hass, group.members.flatMap((r) => roomMeterSources(hass, r)), true);
// A room is a breakdown of an existing area meter, not an additional consumer.
const covered = (r: UtilityReading) => auto.some((a) => a.kind === r.kind && a.metric === r.metric && a.unit === r.unit && a.period === r.period);
const children = group.members.map((r) => ({ id: r.id, name: r.name, readings: ownRoomUtilityReadings(hass, r) })).filter((r) => r.readings.length);
const children = group.members.map((r) => ({
id: r.id, name: r.name, readings: ownRoomUtilityReadings(hass, r),
devices: (devices.get(r.id) ?? []).map((device) => ({ id: device.id, name: device.name, readings: readings(hass, [{ kind: "electricity", metric: "power", id: device.source, period: "total" }], true) })),
})).filter((r) => r.readings.length || r.devices.length);
return { id, name: id === "unassigned" ? "Nicht zugeordnet" : node?.name || hass.areas?.[id]?.name || "Bereich nicht verfügbar", path: node?.path || "", readings: [...auto, ...own.filter((r) => !covered(r))], rooms: children };
}).filter((g) => g.readings.length || g.rooms.length);
}
@@ -196,6 +201,7 @@ export function utilityWatched(hass: HomeAssistant, floors: readonly Floor[]): s
return [...new Set(floors.flatMap((f) => [
...f.rooms.flatMap((r) => roomSources(hass, r, rooms).map((s) => s.id)),
...f.rooms.flatMap((r) => roomMeterSources(hass, r).map((s) => s.id)),
...[...roomDevicePowerLinks(hass, f).values()].flatMap((devices) => devices.map((device) => device.source)),
...UTILITY_KINDS.flatMap((kind) => [floorMeter(hass, f, kind, "power"), floorMeter(hass, f, kind, "energy")]).filter((id): id is string => !!id),
]))];
}
+82
View File
@@ -0,0 +1,82 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { box, entity, floorWith, hassOf } from "./entities/fixtures.ts";
import type { Furniture } from "./model.ts";
import { roomDevicePowerLinks } from "./utility-device-power.ts";
import { buildingUtilityReadings, floorUtilityAreas, floorUtilityReadings, utilityText, utilityWatched } from "./utilities.ts";
const meter = (id: string, value: number, unit = "W") => entity(id, "open", { symcon_variable_type: 1, symcon_value: value, unit_of_measurement: unit });
const furniture = (id: string, power: string | null, extra: Partial<Furniture> = {}): Furniture => ({ id, type: "desk", name: id, x: 2, z: 2, w: 1, d: 1, h: 1, rotation: 0, variant: null, power, entity: "none", ...extra });
const native = (states: ReturnType<typeof entity>[]) => hassOf(states, {}, { language: "de", symconObjects: [{ object_id: 10, parent_id: 0, name: "Büro", path: "Haus / Büro", object_type: 0 }] });
test("area → room → metered device retains zero and live values without manufacturing room or floor totals", () => {
const room = box("room", 0, 0, 5, 5, "symcon-category-10"), floor = floorWith([room], { furniture: [furniture("Wallbox", "cover.1")] });
const h = native([meter("cover.1", 0)]);
const area = floorUtilityAreas(h, floor, floor.rooms, true)[0];
assert.equal(area.name, "Büro"); assert.deepEqual(area.readings, []);
assert.deepEqual(area.rooms[0].readings, []);
assert.equal(area.rooms[0].devices[0].name, "Wallbox");
assert.equal(utilityText(h, area.rooms[0].devices[0].readings[0]), "0 W");
assert.deepEqual(floorUtilityAreas(h, floor), []);
assert.deepEqual(floorUtilityReadings(h, floor), []);
assert.deepEqual(buildingUtilityReadings(h, [floor]), []);
assert.ok(utilityWatched(h, [floor]).includes("cover.1"));
h.states["cover.1"] = meter("cover.1", -1.5, "kW");
assert.equal(floorUtilityAreas(h, floor, floor.rooms, true)[0].rooms[0].devices[0].readings[0].value, -1500);
h.states["cover.1"].state = "unavailable";
assert.equal(utilityText(h, floorUtilityAreas(h, floor, floor.rooms, true)[0].rooms[0].devices[0].readings[0]), "Err: –");
});
test("device-only rooms and explicitly metered rooms share an area without changing its total or floor override", () => {
const a = box("A", 0, 0, 5, 5, "symcon-category-10"), b = box("B", 5, 0, 10, 5, "symcon-category-10");
b.utility_meters = { electricity: { power: "sensor.2" } };
a.sub_areas = ["symcon-category-20"];
const floor = floorWith([a, b], { furniture: [furniture("Gerät", "light.1")], utility_meters: { electricity: { power: "sensor.3" } } });
const h = native([meter("light.1", 250), meter("sensor.2", 30), meter("sensor.3", 900), meter("sensor.12", 320)]);
h.symconObjects = [...h.symconObjects!, { object_id: 11, parent_id: 10, object_type: 0, name: "Strom", path: "Büro / Strom", hidden: false, position: 0, icon: "" }, { object_id: 12, parent_id: 11, object_type: 2, name: "Leistung", path: "", entity_id: "sensor.12", hidden: false, position: 0, icon: "" }];
const [area] = floorUtilityAreas(h, floor, floor.rooms, true);
assert.equal(area.readings[0].value, 320);
assert.deepEqual(area.rooms.map((r) => [r.id, r.readings.map((v) => v.value), r.devices.map((d) => d.name)]), [["A", [], ["Gerät"]], ["B", [30], []]]);
assert.equal(floorUtilityReadings(h, floor)[0].value, 900);
assert.equal(buildingUtilityReadings(h, [floor])[0].value, 900);
assert.equal(floorUtilityAreas(h, floor, floor.rooms, true).filter((g) => g.rooms.some((r) => r.id === "A")).length, 1);
});
test("geometry assigns devices to their own room once; outside and unlinked items do not create room headers", () => {
const floor = floorWith([box("A", 0, 0, 5, 5), box("B", 5, 0, 10, 5)], { furniture: [furniture("A", "sensor.1"), furniture("B", "sensor.1", { x: 7 }), furniture("outside", "sensor.1", { x: 20 }), furniture("empty", "none")], placements: [{ entity_id: "sensor.1", x: 2, y: 0, z: 2, outside: true }] });
const h = native([meter("sensor.1", 8)]);
assert.deepEqual([...roomDevicePowerLinks(h, floor)].map(([id, ds]) => [id, ds.map((d) => d.name)]), [["A", ["A"]], ["B", ["B"]]]);
const [group] = floorUtilityAreas(h, floor, floor.rooms, true);
assert.equal(group.name, "Nicht zugeordnet"); assert.equal(group.rooms.length, 2);
floor.rooms.push({ ...floor.rooms[0], id: "overlap" });
assert.equal(roomDevicePowerLinks(h, floor).has("overlap"), false);
assert.deepEqual(roomDevicePowerLinks(hassOf(Object.values(h.states)), floor), new Map());
});
test("native numeric power placements and additional readings use metadata regardless of their name or inferred domain", () => {
const floor = floorWith([box("room", 0, 0, 5, 5)], { placements: [{ entity_id: "cover.1", name: "Beliebiger Name", x: 2, y: 0, z: 2 }, { entity_id: "switch.2", x: 1, y: 0, z: 2, values: [{ id: "v", entity: "light.3", icon: "sun" }] }], furniture: [furniture("Zusatzleistung", "none", { values: [{ id: "v", entity: "light.3", icon: "sun" }] }), furniture("Temperatur", "none", { values: [{ id: "v", entity: "sensor.4", icon: "temperature" }] })] });
const h = native([meter("cover.1", 0), entity("switch.2", "off"), meter("light.3", 4), meter("sensor.4", 23, "°C")]);
assert.deepEqual(roomDevicePowerLinks(h, floor).get("room")?.map((d) => [d.name, d.source]), [["Zusatzleistung", "light.3"], ["Beliebiger Name", "cover.1"], ["switch.2", "light.3"]]);
});
test("associated power meters follow placed devices; aliases watch and display their canonical native source", () => {
const h = native([entity("switch.1", "off"), entity("sensor.2", "0", { device_class: "power", unit_of_measurement: "W" }), meter("cover.3", 7), entity("light.alias", "on", { symcon_source_entity: "cover.3" })]);
h.entities = { "switch.1": { entity_id: "switch.1", device_id: "plug" }, "sensor.2": { entity_id: "sensor.2", device_id: "plug" } };
const floor = floorWith([box("r", 0, 0, 5, 5)], { placements: [{ entity_id: "switch.1", x: 2, y: 0, z: 2 }], furniture: [furniture("Alias", "light.alias"), furniture("Fehlt", "sensor.deleted")] });
assert.deepEqual(roomDevicePowerLinks(h, floor).get("r")?.map((d) => d.source), ["cover.3", "sensor.deleted", "sensor.2"]);
assert.deepEqual(utilityWatched(h, [floor]).sort(), ["cover.3", "sensor.2", "sensor.deleted"]);
const ds = floorUtilityAreas(h, floor, floor.rooms, true)[0].rooms[0].devices;
assert.equal(ds[0].readings[0].value, 7); assert.equal(ds[1].readings[0].incomplete, true);
});
test("hidden furniture stays out; a manifold's pump circuits retain separate device values", () => {
const floor = floorWith([box("r", 0, 0, 5, 5)], { furniture: [furniture("Hidden", "sensor.1", { show_when: { entity: "switch.hide" } }), furniture("Verteiler", null, { type: "heating_manifold", hydronic: { circuits: [{ id: "p", kind: "pump", name: "Vorschubpumpe", power: "sensor.1" }, { id: "v", kind: "heating", name: "Nur Ventil", has_pump: false, power: "sensor.1" }] } })] });
const h = native([meter("sensor.1", 0), entity("switch.hide", "off")]);
assert.deepEqual(roomDevicePowerLinks(h, floor).get("r")?.map((d) => [d.name, d.source]), [["Verteiler · Vorschubpumpe", "sensor.1"]]);
});
test("legacy light-pin migration preserves a native power value even when its guessed domain is light", () => {
const h = native([meter("light.1", 120)]);
const floor = floorWith([box("r", 0, 0, 5, 5)], { furniture: [furniture("Serverschrank", null, { type: "lamp_ceiling", entity: "light.1" }), furniture("Abgewählt", "none", { entity: "light.1" })] });
assert.deepEqual(roomDevicePowerLinks(h, floor).get("r")?.map((d) => [d.name, d.source]), [["Serverschrank", "light.1"]]);
});
+59
View File
@@ -0,0 +1,59 @@
import { pointInPolygon, type Floor } from "./model.ts";
import type { HomeAssistant } from "./types.ts";
import { furnitureEntities } from "./entities/furniture-links.ts";
import { entityName } from "./entities/kinds.ts";
import { furnitureShown } from "./entities/visibility.ts";
import { furnitureName } from "./furniture-names.ts";
import { powerSensorFor } from "./energy.ts";
import { hasPump, hydronicConfig, isHydronic, realRef } from "./hydronic-model.ts";
import { isSymcon } from "./entities/symcon-values.ts";
export interface DevicePowerLink { id: string; name: string; source: string }
const sourceOf = (hass: HomeAssistant, id: string) => String(hass.states[id]?.attributes.symcon_source_entity || id);
/** Only metadata establishes whether an additional value is electrical power; names never filter it. */
function knownPower(hass: HomeAssistant, id: string): boolean {
const a = hass.states[sourceOf(hass, id)]?.attributes;
return a?.device_class === "power" || /^[km]?w$/i.test(String(a?.unit_of_measurement ?? "").trim());
}
/** Read-only detail rows for actual placements. These links never become room/area meter totals. */
export function roomDevicePowerLinks(hass: HomeAssistant, floor: Floor): Map<string, DevicePowerLink[]> {
const result = new Map<string, DevicePowerLink[]>();
if (!isSymcon(hass)) return result;
const links = furnitureEntities(hass, [floor]);
const add = (id: string, name: string, x: number, z: number, source: string | null | undefined) => {
if (!realRef(source)) return;
const room = floor.rooms.find((r) => r.points.length >= 3 && pointInPolygon([x, z], r.points));
if (!room) return;
const rows = result.get(room.id) ?? [];
rows.push({ id, name, source: sourceOf(hass, source) }); result.set(room.id, rows);
};
for (const item of floor.furniture) {
if (!furnitureShown(hass, item)) continue;
const name = item.name || furnitureName(hass, item.type);
const extra = (item.values ?? []).find((v) => realRef(v.entity) && knownPower(hass, v.entity));
const entity = links.get(item.id)?.entity;
const power = item.power === "none" ? null : item.power || links.get(item.id)?.power || (entity && knownPower(hass, entity) ? entity : null);
add(`furniture:${item.id}`, name, item.x, item.z, power || extra?.entity);
if (!power && !extra) {
const seen = new Set<string>();
for (const entity of item.gang_entities ?? []) {
if (!realRef(entity)) continue;
const source = powerSensorFor(hass, entity);
if (!source || seen.has(sourceOf(hass, source))) continue;
seen.add(sourceOf(hass, source));
add(`furniture:${item.id}:${entity}`, `${name} · ${entityName(hass, entity)}`, item.x, item.z, source);
}
}
if (isHydronic(item.type)) for (const c of hydronicConfig(item).circuits ?? []) {
if (hasPump(c)) add(`furniture:${item.id}:${c.id}`, `${name} · ${c.name || "Pumpe"}`, item.x, item.z, c.power);
}
}
for (const item of floor.placements) {
if (item.outside) continue;
const extra = (item.values ?? []).find((v) => realRef(v.entity) && knownPower(hass, v.entity));
const power = knownPower(hass, item.entity_id) ? item.entity_id : powerSensorFor(hass, item.entity_id);
add(`device:${item.entity_id}`, item.name || entityName(hass, item.entity_id), item.x, item.z, power || extra?.entity);
}
return result;
}
+41 -5
View File
@@ -40,10 +40,17 @@ try {
node(9030, 9000, "Serverraum"); node(9300, 9030, "Strom"); variable(9301, 9300, "Leistung", 2, "kW"); variable(9302, 9300, "Verbrauch", 20, "kWh");
variable(9900, 9000, "Eigener Stockwerksverbrauch", 75, "kWh", "cover");
variable(9801, 9000, "Direkte Raumleistung", 0, "W", "cover"); variable(9802, 9000, "Direkter Raumverbrauch", 2, "kWh");
variable(9701, 9000, "Garagenladung", 0, "W", "cover"); variable(9702, 9000, "Technikwert", 120, "W", "cover");
states["cover.9701"].attributes.symcon_archive = { id: 999, counter: false };
states["cover.9801"].attributes.symcon_archive = { id: 999, counter: false };
const b = structuredClone(p.data.building), floor = b.floors[0];
for (const f of b.floors) { f.furniture = []; f.placements = []; }
const centre = (room) => room.points.reduce(([x,z], [px,pz]) => [x + px / room.points.length, z + pz / room.points.length], [0,0]);
const [wx,wz] = centre(floor.rooms[3]), [px,pz] = centre(floor.rooms[1]);
floor.furniture.push({ id: "wallbox", type: "desk", name: "Wallbox", x: wx, z: wz, w: .3, d: .3, h: .4, rotation: 0, variant: null, entity: "none", power: "cover.9701" });
floor.placements.push({ entity_id: "cover.9702", name: "Serverschrank", x: px, z: pz, y: 0 });
floor.rooms[0].area_id = "symcon-category-9010"; floor.rooms[1].area_id = "symcon-category-9020";
floor.rooms[0].name = "IT Chef"; floor.rooms[2].name = "IT Werkstatt"; floor.rooms[3].name = "WC Damen";
floor.rooms[0].name = "IT Chef"; floor.rooms[1].name = "Küche"; floor.rooms[2].name = "IT Werkstatt"; floor.rooms[3].name = "WC Damen";
floor.rooms[2].area_id = floor.rooms[3].area_id = "symcon-category-9010";
floor.power_entity = null; floor.utility_meters = null;
b.floors[1].rooms[0].area_id = "symcon-category-9030";
@@ -132,8 +139,24 @@ try {
assert.equal(await page.evaluate(() => window.utilityView.shadowRoot.querySelector('.nf-utility-right nf-utility-overview').shadowRoot.querySelectorAll('.entry').length), 2, "floor view lists its two native areas, despite multiple plan rooms sharing one area");
assert.deepEqual(await page.evaluate(() => {
const root = window.utilityView.shadowRoot.querySelector('.nf-utility-right nf-utility-overview').shadowRoot;
return [...root.querySelectorAll('.entry')].map((entry) => ({ name: entry.querySelector('.area-name').textContent, rooms: [...entry.querySelectorAll('.room-entry')].map((room) => ({ name: room.querySelector('.entry-name').textContent.trim(), values: [...room.querySelectorAll('.value b')].map((b) => b.textContent), indent: Number.parseFloat(getComputedStyle(room.querySelector('.entry-name')).paddingLeft), trend: !!room.querySelector('nf-trend-button') })) }));
}), [{ name: "Büro", rooms: [{ name: "↳ IT Chef", values: ["0 W"], indent: 12, trend: true }, { name: "↳ IT Werkstatt", values: ["2 kWh"], indent: 12, trend: false }] }, { name: "Küche", rooms: [] }], "only directly metered rooms are indented under the actual area; unassigned room values do not inherit area totals");
return [...root.querySelectorAll('.entry')].map((entry) => ({ name: entry.querySelector('.area-name').textContent, rooms: [...entry.querySelectorAll('.room-entry')].map((room) => ({ name: room.querySelector('.entry-name').textContent.trim(), values: [...room.querySelectorAll(':scope > .row .value b')].map((b) => b.textContent), indent: Number.parseFloat(getComputedStyle(room.querySelector('.entry-name')).paddingLeft), devices: [...room.querySelectorAll('.device-entry')].map((d) => ({ name: d.querySelector('.device-name').textContent.trim(), value: d.querySelector('.value b').textContent, indent: Number.parseFloat(getComputedStyle(d.querySelector('.device-name')).paddingLeft), trend: !!d.querySelector('nf-trend-button') })) })) }));
}), [{ name: "Büro", rooms: [{ name: "↳ IT Chef", values: ["0 W"], indent: 12, devices: [] }, { name: "↳ IT Werkstatt", values: ["2 kWh"], indent: 12, devices: [] }, { name: "↳ WC Damen", values: [], indent: 12, devices: [{ name: "↳ Wallbox", value: "0 W", indent: 24, trend: true }] }] }, { name: "Küche", rooms: [{ name: "↳ Küche", values: [], indent: 12, devices: [{ name: "↳ Serverschrank", value: "120 W", indent: 24, trend: false }] }] }], "metered devices sit below value-free room headers; directly assigned room meters remain separate");
await page.evaluate(async () => {
const p = window.nfPanel, st = p.hass.states["cover.9701"];
p.hass = { ...p.hass, states: { ...p.hass.states, "cover.9701": { ...st, attributes: { ...st.attributes, symcon_value: 7400 } } } }; await p.updateComplete;
});
await page.waitForFunction(() => window.utilityView.shadowRoot.querySelector('.nf-utility-right nf-utility-overview').shadowRoot.querySelector('[data-device="furniture:wallbox"] .value b').textContent === "7,4 kW");
assert.match(await page.evaluate(() => window.utilityView.shadowRoot.querySelector('nf-utility-overview[inline]').shadowRoot.textContent), /1,5 kW/, "device breakdown never increases the existing floor total");
await page.evaluate(async () => {
const p = window.nfPanel, st = p.hass.states["cover.9701"];
p.hass = { ...p.hass, states: { ...p.hass.states, "cover.9701": { ...st, state: "unavailable" } } }; await p.updateComplete;
});
await page.waitForFunction(() => window.utilityView.shadowRoot.querySelector('.nf-utility-right nf-utility-overview').shadowRoot.querySelector('[data-device="furniture:wallbox"] .value b').textContent === "Err: –");
assert.doesNotMatch(await page.evaluate(() => window.utilityView.shadowRoot.querySelector('nf-utility-overview[inline]').shadowRoot.textContent), /Err:/, "an unavailable device leaves independent area/floor readings unchanged");
await page.evaluate(async () => {
const p = window.nfPanel, st = p.hass.states["cover.9701"];
p.hass = { ...p.hass, states: { ...p.hass.states, "cover.9701": { ...st, state: "open" } } }; await p.updateComplete;
});
await page.evaluate(async () => {
const p = window.nfPanel, st = p.hass.states["cover.9801"];
p.hass = { ...p.hass, states: { ...p.hass.states, "cover.9801": { ...st, attributes: { ...st.attributes, symcon_value: 37 } } } }; await p.updateComplete;
@@ -221,10 +244,23 @@ try {
window.nfPanel._roomId = null;
[...window.nfPanel.shadowRoot.querySelectorAll('[role=tab]')].find((b) => b.textContent.trim() === '3D').click();
});
await page.waitForFunction(() => window.nfPanel.shadowRoot.querySelector('nf-view3d')?.shadowRoot.querySelector('.nf-utility-right nf-utility-overview')?.shadowRoot.querySelectorAll('.room-entry').length === 1);
await page.waitForFunction(() => window.nfPanel.shadowRoot.querySelector('nf-view3d')?.shadowRoot.querySelector('.nf-utility-right nf-utility-overview')?.shadowRoot.querySelectorAll('.room-entry').length === 3);
assert.equal(await page.evaluate(() => window.nfPanel.shadowRoot.querySelector('nf-view3d').shadowRoot.querySelector('.nf-utility-right nf-utility-overview').shadowRoot.querySelector('.room-entry .entry-name').textContent.trim()), '↳ IT Werkstatt', 'clearing a room meter removes only its child row and retains its area');
await page.evaluate(async () => {
const p = window.nfPanel, b = structuredClone(p.data.building);
for (const f of b.floors) { f.power_entity = null; f.utility_meters = null; for (const r of f.rooms) r.utility_meters = null; }
p.data.edit(b);
p.hass = { ...p.hass, symconObjects: p.hass.symconObjects.filter((o) => ![9100,9110,9120,9130,9140,9200,9300].includes(o.object_id)) };
await p.updateComplete;
});
await page.waitForFunction(() => window.nfPanel.shadowRoot.querySelector('nf-view3d')?.shadowRoot.querySelector('.nf-utility-right nf-utility-overview')?.shadowRoot.querySelectorAll('.device-entry').length === 2);
assert.deepEqual(await page.evaluate(() => {
const v = window.nfPanel.shadowRoot.querySelector('nf-view3d'), root = v.shadowRoot.querySelector('.nf-utility-right nf-utility-overview').shadowRoot;
return { areaValues: root.querySelectorAll('.entry > .row').length, roomValues: root.querySelectorAll('.room-entry > .row').length, topValues: v.shadowRoot.querySelector('nf-utility-overview[inline]').shadowRoot.querySelectorAll('.meter').length, toggle: !!v.shadowRoot.querySelector('.nf-utility-overview-toggle') };
}), { areaValues: 0, roomValues: 0, topValues: 0, toggle: true }, "a floor with only device meters keeps the hierarchy visible without inventing parent sums");
await page.screenshot({ path: join(out, "symcon-utility-overview-devices-only.png") });
assert.deepEqual(errors, []);
console.log("OK: native area groups, repeated-area deduplication, explicit indented room meters, power/energy-only children, trends/live updates/clear, unchanged totals, floor overrides, Err and desktop/mobile overview");
console.log("OK: native area → room → device hierarchy, value-free room headers, explicit room meters, device-only floors, zero/live/offline power, archive icons, unchanged totals, floor overrides and desktop/mobile overview");
} finally {
await browser?.close(); await new Promise((done) => server.close(done));
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+14 -1
View File
@@ -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.2.23 / Build 26** die Konsole neu laden. Unter
Nach der Aktualisierung auf **0.2.24 / Build 27** die Konsole neu laden. Unter
**Instanz hinzufügen → Hersteller NextFloor** erscheint **„NextFloor Designer und 3D-Kachel“**.
### Für die Entwicklung
@@ -46,6 +46,19 @@ 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.24
- Die rechte Stockwerksübersicht zeigt **Bereich → Raum → Gerät**, wenn ein
im Raum platziertes Gerät einen Leistungswert hat. Das gilt auch für Möbel
wie Wallboxen und für die Pumpen der Heiz-/Kühlkreisverteiler.
- Ohne eigenen Raumzähler dient der Raum nur als eingerückte Überschrift.
Der Leistungswert steht am Gerät; direkt verknüpfte Raumzähler bleiben am
Raum sichtbar. Gerätewerte werden nicht zusätzlich zu Bereichs-,
Stockwerks- oder Gebäudesummen addiert.
- Nullwerte, Live-Updates und Archivsymbole bleiben erhalten. Auch ohne
Bereichs- oder Stockwerkszähler lassen sich die Geräte in der Übersicht
anzeigen; fehlende übergeordnete Werte werden nicht erfunden.
## Änderungen in 0.2.23
- **Heiz-/Kühlkreisverteiler:** Neues 3D-Bauteil in der Möbelbibliothek mit bis zu
+2 -2
View File
@@ -6,7 +6,7 @@
"compatibility": {
"version": "9.0"
},
"version": "0.2.23",
"build": 26,
"version": "0.2.24",
"build": 27,
"date": 1794441600
}