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

+17 -2
View File
@@ -23,6 +23,7 @@ import { fromCelsius, tempUnit } from "../devices.ts";
import { trendButton } from "../components/trend-button.ts";
import { loggedEntities } from "../trend-data.ts";
import type { FurniturePowerCard } from "./furniture-power-card.ts";
import type { Furniture } from "../model.ts";
export interface HouseCard {
kind: "house";
@@ -65,7 +66,8 @@ export interface HeatPumpCard {
pump: HeatPumpInfo;
}
export type LiveCard = HouseCard | CarCard | MediaCard | PrinterCard | HeatPumpCard | RoomClimateCard | FurniturePowerCard;
export interface HydronicCard { kind: "hydronic"; item: Furniture; readOnly: boolean; at: PlanPoint }
export type LiveCard = HouseCard | CarCard | MediaCard | PrinterCard | HeatPumpCard | RoomClimateCard | FurniturePowerCard | HydronicCard;
/** A button on a card was pressed: the 3D view calls the service (with extra data such as the volume). */
export type LiveCardAction = (domain: string, service: string, entity: string, data?: Record<string, unknown>) => void;
@@ -248,6 +250,7 @@ export function unstackLhCards(root: ParentNode): void {
const placed: { x0: number; x1: number; y0: number; y1: number }[] = [];
// a card near the edge slides back into the view (on a phone it was cut off); its thread still points home
const width = cards[0]?.parentElement?.clientWidth ?? 0;
const height = cards[0]?.parentElement?.clientHeight ?? 0;
const items = cards
.map((el) => {
const [anchor, w] = [Number(el.dataset.x), el.offsetWidth];
@@ -258,6 +261,17 @@ export function unstackLhCards(root: ParentNode): void {
.sort((a, b) => b.y - a.y);
for (const it of items) {
let bottom = it.y;
// Hydraulic cards contain several readings: use nearby free columns before stacking them out of view.
if (it.el.classList.contains("live-card-hydronic") && width > it.w + 16 && height > it.h + 16) {
const xs = [it.x, it.w / 2 + 8, width - it.w / 2 - 8, ...placed.flatMap((p) => [p.x0 - it.w / 2 - 8, p.x1 + it.w / 2 + 8])]
.filter((x) => x >= it.w / 2 + 8 && x <= width - it.w / 2 - 8).sort((a, b) => Math.abs(a - it.x) - Math.abs(b - it.x));
const ys = [Math.max(it.h + 8, Math.min(height - 8, bottom)), ...placed.flatMap((p) => [p.y0 - 8, p.y1 + it.h + 8])].filter((y) => y >= it.h + 8 && y <= height - 8);
let position: { x: number; y: number } | undefined;
for (const y of ys) { for (const x of xs) {
if (!placed.some((p) => x - it.w / 2 < p.x1 + 6 && x + it.w / 2 > p.x0 - 6 && y - it.h < p.y1 + 6 && y > p.y0 - 6)) { position = { x, y }; break; }
} if (position) break; }
if (position) { it.x = position.x; bottom = position.y; }
}
for (let guard = 0; guard < 12; guard++) {
const r = { x0: it.x - it.w / 2, x1: it.x + it.w / 2, y0: bottom - it.h, y1: bottom };
const hit = placed.find((p) => r.x0 < p.x1 + 6 && r.x1 > p.x0 - 6 && r.y0 < p.y1 + 6 && r.y1 > p.y0 - 6);
@@ -266,6 +280,7 @@ export function unstackLhCards(root: ParentNode): void {
}
placed.push({ x0: it.x - it.w / 2, x1: it.x + it.w / 2, y0: bottom - it.h, y1: bottom });
const lift = it.y - bottom;
it.el.style.setProperty("--live-dx", `${Math.round(Number(it.el.dataset.x) - it.x)}px`);
it.el.style.transform = `translate(${Math.round(it.x)}px, ${Math.round(bottom)}px) translate(-50%, -100%)`;
it.el.style.setProperty("--live-thread", `${Math.round(18 + lift)}px`);
}
@@ -338,7 +353,7 @@ function furniturePowerCard(hass: HomeAssistant | undefined, c: FurniturePowerCa
export function renderLhCards(hass: HomeAssistant | undefined, cards: readonly LiveCard[], act: LiveCardAction, fold?: LiveCardFold, climateOnly = false): TemplateResult | typeof nothing {
if (!cards.length) return nothing;
return html`<div class="live-cards">
${cards.map((c, i) => (c.kind === "roomclimate" ? roomClimateCard(hass, c, i) : c.kind === "power" ? furniturePowerCard(hass, c, i) : climateOnly ? nothing : c.kind === "house" ? houseCard(hass, c, i, fold) : c.kind === "car" ? carCard(hass, c, i, act) : c.kind === "printer" ? printerCard(hass, c, i) : c.kind === "heatpump" ? heatPumpCard(hass, c, i) : mediaCard(hass, c, i, act)))}
${cards.map((c, i) => (c.kind === "roomclimate" ? roomClimateCard(hass, c, i) : c.kind === "power" ? furniturePowerCard(hass, c, i) : c.kind === "hydronic" ? html`<div class="live-card live-card-hydronic" data-i=${i} data-furniture=${c.item.id}><nf-hydronic-card .hass=${hass} .item=${c.item} .readOnly=${c.readOnly}></nf-hydronic-card></div>` : climateOnly ? nothing : c.kind === "house" ? houseCard(hass, c, i, fold) : c.kind === "car" ? carCard(hass, c, i, act) : c.kind === "printer" ? printerCard(hass, c, i) : c.kind === "heatpump" ? heatPumpCard(hass, c, i) : mediaCard(hass, c, i, act)))}
</div>`;
}