feat: add fresh-water cascades with independent stations and buffer links
This commit is contained in:
1 parent
a2a119d3ee
commit
992c3e18f2
30 files changed
+2199
-1578
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import { html, nothing } from "lit";
|
||||
import { repeat } from "lit/directives/repeat.js";
|
||||
import { uid, type Furniture } from "../../../model.ts";
|
||||
import { hydronicConfig, type HydronicControl } from "../../../hydronic-model.ts";
|
||||
import { freshwaterStations, MAX_FRESHWATER_STATIONS, newFreshwaterStation, stationHasValve, withFreshwaterStations, type FreshwaterStation } from "../../../freshwater-model.ts";
|
||||
import { entityOptions } from "../entities.ts";
|
||||
import { checkField, entityField, hint, selectField, textField } from "../fields.ts";
|
||||
import type { EditorHost } from "../host.ts";
|
||||
|
||||
export function renderFreshwaterForm(host: EditorHost, item: Furniture, update: (patch: Partial<Furniture>) => void) {
|
||||
const h=hydronicConfig(item),stations=freshwaterStations(item),options=entityOptions(host.hass,()=>true);
|
||||
const save=(next:FreshwaterStation[],resize=false)=>update({hydronic:withFreshwaterStations(h,next),...(resize?{w:Math.round(item.w/stations.length*next.length*1000)/1000}:{})});
|
||||
const ref=(label:string,value:string|null|undefined,types:number[],set:(id:string|null)=>void)=>entityField(host,label,value??null,undefined,options,(v)=>set(v==="none"?null:v),{types});
|
||||
const numeric=(label:string,value:string|null|undefined,set:(id:string|null)=>void)=>ref(label,value,[1,2],set);
|
||||
const control=(label:string,value:HydronicControl|undefined,set:(c:HydronicControl)=>void)=>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)=>set({...value,feedback}))}
|
||||
${ref("Befehl / Sollwert (optional)",value?.command,[0,1,2],(command)=>set({...value,command}))}
|
||||
${hint("Eine zugewiesene Rückmeldung bestimmt die Anzeige auch bei Ausfall. Nur ohne Rückmeldung wird der Sollwert verwendet. Bedienbare Variablen verwenden ihre native Symcon-Schaltaktion und ihren unveränderten Wertebereich.","nf-wide")}
|
||||
</div></details>`;
|
||||
const floor=host.doc.floors.find((f)=>f.furniture.some((m)=>m.id===item.id));
|
||||
const buffers=(floor?.furniture??[]).filter((m)=>m.type==="buffer_tank");
|
||||
const choices:[string,string][]=[["","Keiner"],...buffers.map((m,i):[string,string]=>[m.id,m.name||`Pufferspeicher ${i+1}`])];
|
||||
if(h.buffer_id&&!buffers.some((b)=>b.id===h.buffer_id))choices.push([h.buffer_id,"Verknüpfter Puffer nicht im Stockwerk vorhanden"]);
|
||||
return html`<section class="nf-freshwater-form">
|
||||
<div class="nf-form">${selectField(host,"Pufferspeicher im Plan",h.buffer_id??"",choices,(id)=>update({hydronic:{...h,buffer_id:id||null}}),{wide:true})}
|
||||
${hint("Die Zuordnung zeichnet Vorlauf und Rücklauf zum platzierten Puffer im selben Stockwerk. Datenpunkte werden für jede Station separat aus dem Objektbaum gewählt. Eine Kaskade teilt sich die Sammelleitungen; die Zirkulationspumpe gehört zur gemeinsamen Leitung. Das Hinzufügen einer Station verbreitert das Bauteil, neue Stationen starten ohne Datenpunkt-Verknüpfungen.","nf-wide")}
|
||||
</div>
|
||||
${repeat(stations,(s)=>s.id,(s,i)=>{
|
||||
const patch=(p:Partial<FreshwaterStation>)=>save(stations.map((old)=>old.id===s.id?{...old,...p}:old));
|
||||
return html`<details class="nf-freshwater-station" data-station=${s.id} ?open=${i===0}><summary>K${i+1} · ${s.name||`Station ${i+1}`}</summary><div class="nf-form">
|
||||
${textField(host,"Name",s.name,(name)=>patch({name}),{wide:true,maxlength:100})}
|
||||
${numeric("Vorlauf",s.flow,(flow)=>patch({flow}))}${numeric("Rücklauf",s.return,(back)=>patch({return:back}))}
|
||||
${numeric("Trinkwarmwasser",s.hot_water,(hot_water)=>patch({hot_water}))}${numeric("Kaltwasser",s.cold_water,(cold_water)=>patch({cold_water}))}
|
||||
${control("Ladepumpe",s.pump,(pump)=>patch({pump}))}
|
||||
${numeric("Pumpenleistung (optional)",s.power,(power)=>patch({power}))}
|
||||
${checkField(host,"Kaskadenventil vorhanden",stationHasValve(s),(has_valve)=>patch({has_valve}))}
|
||||
${stationHasValve(s)?control("Kaskadenventil (Kaltwasser)",s.valve,(valve)=>patch({valve})):nothing}
|
||||
${stations.length>1?html`<button class="nf-link nf-wide nf-freshwater-remove" ?disabled=${!host.admin} @click=${()=>save(stations.filter((old)=>old.id!==s.id),true)}>× Station entfernen</button>`:nothing}
|
||||
</div></details>`;
|
||||
})}
|
||||
<button class="nf-btn nf-freshwater-add" ?disabled=${!host.admin||stations.length>=MAX_FRESHWATER_STATIONS} @click=${()=>save([...stations,newFreshwaterStation(uid("station"),`Station ${stations.length+1}`)],true)}>+ Station hinzufügen</button>
|
||||
<div class="nf-form">${numeric("Zirkulationstemperatur",h.circulation_temperature,(circulation_temperature)=>update({hydronic:{...h,circulation_temperature}}))}
|
||||
${control("Zirkulationspumpe",h.circulation,(circulation)=>update({hydronic:{...h,circulation}}))}
|
||||
</div>
|
||||
</section>`;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ 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";
|
||||
import { renderFreshwaterForm } from "./freshwater.ts";
|
||||
|
||||
export function renderHydronicForm(host: EditorHost, item: Furniture, update: (patch: Partial<Furniture>) => void) {
|
||||
const h = hydronicConfig(item), options = entityOptions(host.hass, () => true);
|
||||
@@ -46,7 +47,7 @@ export function renderHydronicForm(host: EditorHost, item: Furniture, update: (p
|
||||
<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}
|
||||
${item.type === "freshwater_station" ? renderFreshwaterForm(host,item,update) : nothing}
|
||||
${renderDeviceValues(host, item.values, (values) => update({ values }))}
|
||||
</section>`;
|
||||
}
|
||||
Reference in new issue
Block a user