fix: group utility overview by area and show explicit room meters

This commit is contained in:
jhartworks committed 2026-11-12 12:09:21 +01:00
1 parent 8c6b23bd22
commit 93c015ec77
17 files changed
+1475 -1253

No files matched your search

+2 -1
View File
@@ -15,6 +15,7 @@ import { generateWalls, innerSize, type Wall } from "../../../geometry/walls.ts"
import { countsAsLiving, roomArea } from "../../../geometry/living-area.ts";
import { roomSpeaker } from "../../../live/announce.ts";
import { isSymcon } from "../../../entities/symcon-values.ts";
import { renderSymconRoomMeters } from "../symcon-fields.ts";
/** What the room form makes the editor do, and the parts of it that the editor still draws itself. */
export interface RoomActions {
@@ -189,7 +190,7 @@ export function renderRoomForm(host: EditorHost, state: SideState, room: Room, a
<button class="nf-btn" title=${t("room_start_view_hint")} ?disabled=${!host.admin} @click=${() => actions.rememberView()}>${t("room_start_view")}</button>
${room.start_view ? html`<button class="nf-btn" title=${t("room_start_view_reset")} ?disabled=${!host.admin} @click=${() => actions.patch({ start_view: null })}>↺</button>` : nothing}
</div>
${actions.wallHeights} ${actions.climate} ${corners(host, room, rectangle, actions)}
${actions.wallHeights} ${actions.climate} ${isSymcon(host.hass) ? renderSymconRoomMeters(host, room, (change) => actions.patch(change)) : nothing} ${corners(host, room, rectangle, actions)}
${host.admin
? html`<div class="nf-actions">
<button class="nf-btn nf-primary" @click=${() => (state.packages = !state.packages)}>${t("pkg_open")}</button>
@@ -1,5 +1,6 @@
import { html, nothing } from "lit";
import { WEATHER_VARIABLE_KEYS, type BuildingSettings, type PresenceLink, type Room, type RoomHvac } from "../../model.ts";
import { UTILITY_KINDS, WEATHER_VARIABLE_KEYS, type BuildingSettings, type PresenceLink, type Room, type RoomHvac } from "../../model.ts";
import { UTILITY_ICONS, UTILITY_LABELS } from "../../utilities.ts";
import { WEATHER_VARIABLE_LABELS } from "../../symcon-weather.ts";
import { ROOM_HVAC_FIELDS } from "../../entities/room-hvac.ts";
import { isSymconVariable } from "../../entities/symcon-values.ts";
@@ -8,6 +9,18 @@ import { entityOptions } from "./entities.ts";
import { checkField, entityField, hint, textField } from "./fields.ts";
import type { EditorHost } from "./host.ts";
export function renderSymconRoomMeters(host: EditorHost, room: Room, patch: (change: Partial<Room>) => void) {
const options = entityOptions(host.hass, (id) => isSymconVariable(host.hass, id, [1, 2]));
return html`<details class="nf-room-utility-meters"><summary>Eigene Raumzähler</summary><div class="nf-form">
${hint("Nur direkt zugewiesene Raumzähler erscheinen als eingerückte Raumzeile unter dem verknüpften Bereich. Die Bereichswerte stehen einmal beim Bereich; vorhandene Bereichssummen enthalten die Raumwerte bereits. Fehlt dem Bereich ein passender Zähler, werden dafür die eigenen Raumzähler summiert.", "nf-wide")}
${UTILITY_KINDS.map((kind) => html`<b class="nf-wide">${UTILITY_ICONS[kind]} ${UTILITY_LABELS[kind]}</b>${(["power", "energy"] as const).map((metric) => entityField(host, metric === "power" ? "Leistung / Durchfluss" : "Energie / Verbrauch", room.utility_meters?.[kind]?.[metric] ?? null, undefined, options, (v) => {
const meters = { ...room.utility_meters, [kind]: { ...room.utility_meters?.[kind], [metric]: v === "none" ? null : v } };
if (!Object.values(meters[kind]!).some((id) => id && id !== "none")) delete meters[kind];
patch({ utility_meters: Object.keys(meters).length ? meters : null });
}, { types: [1, 2] }))}`)}
</div></details>`;
}
export function renderSymconRoomHvac(host: EditorHost, room: Room, patch: (change: Partial<Room>) => void) {
const set = (change: Partial<RoomHvac>) => patch({ hvac: { ...room.hvac, ...change } });
const schedules = room.hvac?.schedules ?? [];