feat: add 3D hydronic manifolds buffer tanks and fresh water stations
This commit is contained in:
1 parent
93c015ec77
commit
173d02e3cc
37 files changed
+3253
-1815
No files matched your search
@@ -17,6 +17,8 @@ import { dataField, TARGET_EXAMPLES } from "./house.ts";
|
||||
import { parkingForm } from "./parking.ts";
|
||||
import { stairForm } from "./stairs.ts";
|
||||
import { DEFAULT_STAIR } from "../../../geometry/stairs.ts";
|
||||
import { isHydronic } from "../../../hydronic-model.ts";
|
||||
import { renderHydronicForm } from "./hydronic.ts";
|
||||
|
||||
export interface FurnitureActions extends FurnitureLinkActions {
|
||||
rotate(delta: number): void;
|
||||
@@ -239,7 +241,7 @@ export function renderFurnitureForm(host: EditorHost, item: Furniture, actions:
|
||||
<div class="nf-h3row"><h3>${item.name || host.t("furniture")}</h3>${actions.lockButton}</div>
|
||||
<div class="nf-form">${nameFields(host, item, actions)} ${kindField(host, item, actions.packs, actions)} ${geometryFields(host, item, actions)}</div>
|
||||
${typeNotes(host, item, actions)} ${item.type === "stairs" && item.stair ? stairForm(host, item, actions) : nothing} ${variantField(host, item, actions)} ${paintField(host, item, actions)}
|
||||
${links} ${item.type.endsWith(":sprinkler") ? html`<div class="nf-form">${numberField(host, host.t("spray_reach"), item.spray ?? 3, (v) => actions.update({ spray: Math.min(15, Math.max(0.5, v)) }), 0.5, 0.5)}${hint(host.t("spray_hint"), "nf-wide")}</div>` : nothing}
|
||||
${isHydronic(item.type) ? renderHydronicForm(host, item, (patch) => actions.update(patch)) : links} ${item.type.endsWith(":sprinkler") ? html`<div class="nf-form">${numberField(host, host.t("spray_reach"), item.spray ?? 3, (v) => actions.update({ spray: Math.min(15, Math.max(0.5, v)) }), 0.5, 0.5)}${hint(host.t("spray_hint"), "nf-wide")}</div>` : nothing}
|
||||
${hasPicture(item.type) ? pictureFields(host, item, actions) : nothing}
|
||||
${packItem(item.type)?.pet
|
||||
? html`<div class="nf-form nf-links">${entityField(host, host.t("pet_room_sensor"), item.room_sensor ?? null, undefined, entityOptions(host.hass, (id) => /^(sensor|device_tracker|input_select|select)\./.test(id)), (v) => actions.update({ room_sensor: v && v !== "none" ? v : null }))}${hint(host.t("pet_room_hint"), "nf-wide")}</div>`
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { html, nothing } from "lit";
|
||||
import { repeat } from "lit/directives/repeat.js";
|
||||
import { uid, type Furniture } from "../../../model.ts";
|
||||
import { hasPump, hasValve, hydronicConfig, newCircuit, type HydronicConfig, type HydronicControl, type HydronicCircuit } from "../../../hydronic-model.ts";
|
||||
import { entityOptions } from "../entities.ts";
|
||||
import { checkField, entityField, hint, numberField, pinShiftField, selectField, textField } from "../fields.ts";
|
||||
import { renderDeviceValues } from "../device-values.ts";
|
||||
import type { EditorHost } from "../host.ts";
|
||||
|
||||
export function renderHydronicForm(host: EditorHost, item: Furniture, update: (patch: Partial<Furniture>) => void) {
|
||||
const h = hydronicConfig(item), options = entityOptions(host.hass, () => true);
|
||||
const set = (patch: Partial<HydronicConfig>) => update({ hydronic: { ...h, ...patch } });
|
||||
const ref = (label: string, value: string | null | undefined, types: number[], save: (id: string | null) => void) => entityField(host, label, value ?? null, undefined, options, (v) => save(v === "none" ? null : v), { types });
|
||||
const numeric = (label: string, value: string | null | undefined, save: (id: string | null) => void) => ref(label, value, [1, 2], save);
|
||||
const control = (label: string, value: HydronicControl | undefined, save: (c: HydronicControl) => void, valve = false) => html`<details class="nf-wide nf-hydronic-control"><summary>${label}</summary><div class="nf-form">
|
||||
${ref("Rückmeldung / Istwert", value?.feedback, [0, 1, 2], (feedback) => save({ ...value, feedback }))}
|
||||
${ref("Befehl / Sollwert (optional)", value?.command, [0, 1, 2], (command) => save({ ...value, command }))}
|
||||
${valve ? checkField(host, "Ventil nur in 3D umkehren", !!value?.inverted, (inverted) => save({ ...value, inverted })) : nothing}
|
||||
${hint("Eine zugewiesene Rückmeldung bestimmt die 3D-Anzeige, auch wenn sie gerade nicht verfügbar ist. Ohne Rückmeldung wird der verknüpfte Sollwert verwendet. Befehle werden über die Symcon-Schaltaktion in ihrem nativen Wertebereich gesendet. Die 3D-Umkehrung verändert weder Anzeige- noch Schreibwerte.", "nf-wide")}
|
||||
</div></details>`;
|
||||
const temperatures = html`${numeric("Vorlauf", h.flow, (flow) => set({ flow }))}${numeric("Rücklauf", h.return, (back) => set({ return: back }))}`;
|
||||
const circuit = (c: HydronicCircuit, i: number) => {
|
||||
const patch = (p: Partial<HydronicCircuit>) => set({ circuits: (h.circuits ?? []).map((old) => old.id === c.id ? { ...old, ...p } : old) });
|
||||
return html`<details class="nf-hydronic-circuit" data-circuit=${c.id} ?open=${i === 0}><summary>${c.name || `Kreis ${i + 1}`}</summary><div class="nf-form">
|
||||
${textField(host, "Name", c.name, (name) => patch({ name }), { wide: true, maxlength: 100 })}
|
||||
${selectField(host, "Kreisart", c.kind, [["heating", "Heizkreis"], ["cooling", "Kühlkreis"], ["changeover", "Heizen / Kühlen"], ["pump", "Einspeise- / Vorschubpumpe (ohne Ventil)"]], (kind) => patch({ kind, ...(kind === "pump" ? { has_pump: true, has_valve: false } : {}) }), { wide: true })}
|
||||
${c.kind !== "pump" ? html`${checkField(host, "Pumpe vorhanden", hasPump(c), (has_pump) => patch({ has_pump }))}${checkField(host, "Ventil vorhanden", hasValve(c), (has_valve) => patch({ has_valve }))}` : nothing}
|
||||
${hasPump(c) ? control("Pumpe", c.pump, (pump) => patch({ pump })) : nothing}
|
||||
${hasValve(c) ? control("Ventil", c.valve, (valve) => patch({ valve }), true) : nothing}
|
||||
${numeric("Vorlauf", c.flow, (flow) => patch({ flow }))}${numeric("Rücklauf", c.return, (back) => patch({ return: back }))}
|
||||
${hasPump(c) ? numeric("Pumpenleistung (optional)", c.power, (power) => patch({ power })) : nothing}
|
||||
${c.kind === "changeover" ? html`${ref("Umschaltung Heizen / Kühlen", c.mode_entity, [0, 1], (mode_entity) => patch({ mode_entity }))}${numberField(host, "Kühlbetrieb bei Wert", c.cooling_value ?? 1, (cooling_value) => patch({ cooling_value: Math.round(cooling_value) }), 1)}` : nothing}
|
||||
<button class="nf-link nf-wide nf-hydronic-remove" ?disabled=${!host.admin} @click=${() => set({ circuits: (h.circuits ?? []).filter((old) => old.id !== c.id) })}>× Kreis entfernen</button>
|
||||
</div></details>`;
|
||||
};
|
||||
return html`<section class="nf-hydronic-form">
|
||||
<div class="nf-form">${checkField(host, "Schwebende 3D-Kachel", h.card !== false, (card) => set({ card }))}${pinShiftField(host, item.pin_offset, (pin_offset) => update({ pin_offset }))}${hint("Verknüpfe jeden Datenpunkt über den Objektbaum. Namen und Pfade schränken die Auswahl nicht ein. Nicht verknüpfte Werte bleiben in der 3D-Kachel ausgeblendet. Das Bauteil öffnet beim Antippen seine Werte und Bedienung.", "nf-wide")}</div>
|
||||
${item.type === "heating_manifold" ? html`${repeat(h.circuits ?? [], (c) => c.id, circuit)}<button class="nf-btn nf-hydronic-add" title="Bis zu 32 Kreise" ?disabled=${!host.admin || (h.circuits?.length ?? 0) >= 32} @click=${() => set({ circuits: [...(h.circuits ?? []), newCircuit(uid("circuit"), `Kreis ${(h.circuits?.length ?? 0) + 1}`)] })}>+ Kreis hinzufügen</button>` : nothing}
|
||||
${item.type === "buffer_tank" ? html`<div class="nf-form">${temperatures}${hint("Die sieben Startplätze liegen von oben nach unten. Höhe 100 % liegt oben, 0 % unten. Fühlerplätze können ergänzt, entfernt und frei in der Höhe positioniert werden; die Anzeige sortiert sie von oben nach unten.", "nf-wide")}</div>
|
||||
${repeat([...(h.sensors ?? [])].sort((a, b) => b.level - a.level), (probe) => probe.id, (probe) => {
|
||||
const patch = (change: Partial<typeof probe>) => set({ sensors: (h.sensors ?? []).map((s) => s.id === probe.id ? { ...s, ...change } : s) });
|
||||
return html`<details class="nf-hydronic-probe" data-probe=${probe.id}><summary>${probe.name || "Fühler"} · ${Math.round(probe.level * 100)} %</summary><div class="nf-form">
|
||||
${textField(host, "Bezeichnung", probe.name, (name) => patch({ name }), { wide: true, maxlength: 100 })}${numeric("Temperatur", probe.entity, (entity) => patch({ entity }))}
|
||||
${numberField(host, "Höhe (%) · 100 = oben", Math.round(probe.level * 1000) / 10, (v) => patch({ level: Math.max(0, Math.min(1, v / 100)) }), .1, 0)}
|
||||
<button class="nf-link nf-wide" ?disabled=${!host.admin} @click=${() => set({ sensors: (h.sensors ?? []).filter((s) => s.id !== probe.id) })}>× Fühlerplatz entfernen</button>
|
||||
</div></details>`;
|
||||
})}<button class="nf-btn nf-hydronic-add-probe" title="Bis zu 64 Fühlerplätze" ?disabled=${!host.admin || (h.sensors?.length ?? 0) >= 64} @click=${() => set({ sensors: [...(h.sensors ?? []), { id: uid("probe"), name: `Fühler ${(h.sensors?.length ?? 0) + 1}`, entity: null, level: .5 }] })}>+ Fühlerplatz hinzufügen</button>` : nothing}
|
||||
${item.type === "freshwater_station" ? html`<div class="nf-form">${temperatures}${numeric("Zirkulationstemperatur", h.circulation_temperature, (circulation_temperature) => set({ circulation_temperature }))}${numeric("Trinkwarmwasser", h.hot_water, (hot_water) => set({ hot_water }))}${control("Ladepumpe", h.pump, (pump) => set({ pump }))}${control("Zirkulationspumpe", h.circulation, (circulation) => set({ circulation }))}</div>` : nothing}
|
||||
${renderDeviceValues(host, item.values, (values) => update({ values }))}
|
||||
</section>`;
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
type Vec2,
|
||||
} from "../../../model.ts";
|
||||
import { furnitureSize } from "../../../packs.ts";
|
||||
import { defaultHydronic, isHydronic } from "../../../hydronic-model.ts";
|
||||
|
||||
const thousandths = (v: number) => Math.round(v * 1000) / 1000;
|
||||
const quarterTurns = (degrees: number, by: number) => (((degrees + by) % 360) + 360) % 360;
|
||||
@@ -74,6 +75,7 @@ export function newFurniture(type: string, doc: Building, floor: Floor, at: Vec2
|
||||
const above = doc.floors.filter((f) => f.elevation > floor.elevation).sort((p, q) => p.elevation - q.elevation)[0];
|
||||
const h = type === "stairs" ? thousandths(above ? above.elevation - floor.elevation : floor.height + 0.25) : height;
|
||||
const item: Furniture = { id: uid("furniture"), type, x: thousandths(at[0]), z: thousandths(at[1]), rotation: 0, w, d, h, variant: null };
|
||||
if (isHydronic(type)) item.hydronic = defaultHydronic(type);
|
||||
// new stairs are shaped stairs: shape, turn and steps are set in the form, and they open only the floor they need
|
||||
if (type === "stairs") item.stair = { ...DEFAULT_STAIR };
|
||||
return item;
|
||||
|
||||
@@ -2003,4 +2003,8 @@ export const editorStyles = css`
|
||||
font-size: 12.5px;
|
||||
color: var(--nf-warm);
|
||||
}
|
||||
.nf-hydronic-form>details { border:1px solid var(--nf-line); border-radius:10px; padding:10px; margin:8px 0; }
|
||||
.nf-hydronic-form summary { cursor:pointer; font-weight:500; }
|
||||
.nf-hydronic-form details[open]>.nf-form { margin-top:9px; }
|
||||
.nf-hydronic-control { border-top:1px solid var(--nf-line); padding-top:7px; }
|
||||
`;
|
||||
Reference in new issue
Block a user