feat: add 3D hydronic manifolds buffer tanks and fresh water stations

This commit is contained in:
jhartworks committed 2026-11-12 14:28:30 +01:00
1 parent 93c015ec77
commit 173d02e3cc
37 files changed
+3253 -1815

No files matched your search

+31 -1
View File
@@ -32,6 +32,8 @@ import { chosenEffects, readSkyWeather, withDensity } from "../live/sky-weather.
import { energyPicture, houseHub, type EnergyPicture } from "../live/energy-flow.ts";
import { roomClimateCards } from "../live/room-climate-card.ts";
import { furniturePowerCards } from "../live/furniture-power-card.ts";
import { isHydronic } from "../hydronic-model.ts";
import { loadHydronics } from "../load-hydronics.ts";
import { loadWeek, type WeekBars } from "../live/week-bars.ts";
import { binsDue, loadToday, sortDay, type TodayItem } from "../live/today.ts";
import { forecastDays, loadForecast } from "../live/forecast.ts";
@@ -413,6 +415,8 @@ export class NfView3d extends LitElement {
private declare _utilityOverviewVisible: boolean;
private viewer: NextFloorViewer | null = null;
private hydronicModule: Awaited<ReturnType<typeof loadHydronics>> | null = null;
private hydronicGeneration = 0;
private starting = false;
/** States of the placed entities as last sent to the viewer. */
private shownStates = new Map<string, HassEntity | undefined>();
@@ -549,6 +553,7 @@ export class NfView3d extends LitElement {
disconnectedCallback(): void {
super.disconnectedCallback();
this.hydronicGeneration++; this.hydronicModule?.closeHydronic();
this.stopPlugins?.();
this.stopPlugins = null;
this.listenToAnnouncements(false);
@@ -859,6 +864,7 @@ export class NfView3d extends LitElement {
// a piece shown only while a helper is on (seasonal decoration) comes and goes with it
if (hiddenFurniture(hass, b).join(",") !== this.shownFor?.key) v.setBuilding(this.shownBuilding(hass));
this.shownStates = new Map(this.watched.map((id) => [id, hass.states[id]]));
this.syncHydronics(v, b, hass);
this.refreshToday(b);
this.refreshForecast(b);
@@ -1380,6 +1386,7 @@ export class NfView3d extends LitElement {
}
// an item with its own tap action shows what it shows as usual; a tap on it or on its pin runs the action
const own = ownTaps(b, markers);
for (const f of b.floors.flatMap((fl) => fl.furniture)) if (isHydronic(f.type)) targets.set(f.id, `hydronic:${f.id}`);
this.tapPins = own.pins;
for (const f of b.floors.flatMap((fl) => fl.furniture)) if (f.tap?.action) targets.set(f.id, `tap:${f.id}`);
// one without a pin of its own gets one above it, like a device's, that does the same
@@ -2323,6 +2330,11 @@ export class NfView3d extends LitElement {
if (entityId.startsWith("lamp:")) return;
// in the past nothing is switched
if (this._travel) return;
if (entityId.startsWith("hydronic:")) {
const item = this.building?.floors.flatMap((f) => f.furniture).find((f) => f.id === entityId.slice(9));
if (item && this.hass) void loadHydronics().then((mod) => { if (this.isConnected && this.hass) { this.hydronicModule = mod; return mod.openHydronic(this.hass, item); } }).catch((err) => { this._error = String(err); });
return;
}
const ownTap = entityId.startsWith("tap:") ? entityId.slice(4) : this.tapPins.get(entityId);
if (ownTap) {
const f = this.building?.floors.flatMap((fl) => fl.furniture).find((it) => it.id === ownTap);
@@ -2639,6 +2651,18 @@ export class NfView3d extends LitElement {
.catch(() => (this.dayCurves = null));
}
private syncHydronics(v: NextFloorViewer, b: Building, hass: HomeAssistant): void {
const generation = ++this.hydronicGeneration;
const items = this.shownBuilding(hass).floors.filter((floor) => !this.floorId || floor.id === this.floorId).flatMap((floor) => floor.furniture.filter((item) => isHydronic(item.type)).map((item) => ({ floor, item })));
if (!items.length) { v.setHydronics([]); this.hydronicModule?.refreshHydronic(hass, b, !!this._travel); return; }
void loadHydronics().then((mod) => {
if (generation !== this.hydronicGeneration || this.viewer !== v || !this.isConnected) return;
this.hydronicModule = mod;
v.setHydronics(items.map(({ floor, item }) => ({ ...mod.hydronicVisual(hass, item, floor.id, mountBase(floor, item)), animate: !this.dimmed && !this._travel })));
mod.refreshHydronic(hass, b, !!this._travel);
}).catch((err) => { this._error = String(err); });
}
private syncLhCards(v: NextFloorViewer, b: Building, pic: EnergyPicture, cars: ReturnType<NfView3d["liveCars"]>, media: MediaNow[], hass: HomeAssistant): void {
const cards: LiveCard[] = [];
const s = pic.summary;
@@ -2663,6 +2687,12 @@ export class NfView3d extends LitElement {
if (this.liveCardsOn && !this.dimmed) {
cards.push(...roomClimateCards(hass, b, this.floorId, this.roomId));
cards.push(...furniturePowerCards(hass, b, this.furnitureLinks ?? new Map(), this.floorId, this.roomId));
for (const floor of b.floors) for (const item of floor.furniture) {
if (!isHydronic(item.type) || item.hydronic?.card === false || (this.floorId && floor.id !== this.floorId) || !furnitureShown(hass, item)) continue;
const room = this.roomId ? floor.rooms.find((r) => r.id === this.roomId) : null;
if (this.roomId && (!room || !pointInPolygon([item.x, item.z], room.points))) continue;
cards.push({ kind: "hydronic", item, readOnly: !!this._travel, at: { floorId: floor.id, x: item.x + (item.pin_offset?.x ?? 0), z: item.z + (item.pin_offset?.z ?? 0), y: mountBase(floor, item) + item.h + .3 + (item.pin_offset?.y ?? 0) } });
}
}
if (JSON.stringify(cards) !== JSON.stringify(this._liveCards)) this._liveCards = cards;
v.setLiveAnchors(
@@ -2714,7 +2744,7 @@ export class NfView3d extends LitElement {
const own = this.ownSensors();
const e = this._liveEnergy?.summary;
const energy = !!e && !this.roomId && this.showEnergy && !!this.hass && !(e.consumption === null && e.grid === null && e.solar === null && e.battery === null);
const climate = this.building?.floors.some((f) => f.rooms.some((r) => r.climate_card) || f.furniture.some((m) => m.power_card));
const climate = this.building?.floors.some((f) => f.rooms.some((r) => r.climate_card) || f.furniture.some((m) => m.power_card || (isHydronic(m.type) && m.hydronic?.card !== false)));
const climateToggle = climate ? this.renderCardToggle() : nothing;
const roomNames = this.roomNamesButton ? html`<button class="nf-energy-item nf-flow-toggle nf-room-names-toggle" aria-pressed=${this.roomLabels} title=${translate(this.hass, "room_names_toggle_hint")} @click=${() => {
this.roomLabels = !this.roomLabels;