feat: show scoped utility overviews and compact trend controls
This commit is contained in:
1 parent
2bf5f4a60a
commit
5fd674bb00
17 files changed
+987
-456
No files matched your search
@@ -54,6 +54,7 @@ import { isSymcon, isSymconVariable, nativeBool, nativeText } from "../entities/
|
||||
import { WEATHER_VARIABLE_LABELS } from "../symcon-weather.ts";
|
||||
import { floorUtilityReadings, utilityText } from "../utilities.ts";
|
||||
import "./utility-report.ts";
|
||||
import "./utility-overview.ts";
|
||||
import { trendButton } from "./trend-button.ts";
|
||||
import { deviceValuesText } from "../entities/device-values.ts";
|
||||
import { furnitureShown, hiddenFurniture, withoutHidden } from "../entities/visibility.ts";
|
||||
@@ -2527,15 +2528,15 @@ export class NfView3d extends LitElement {
|
||||
</section>`;
|
||||
}
|
||||
|
||||
private renderToday() {
|
||||
private renderToday(utilities: ReturnType<NfView3d["utilityOverview"]>) {
|
||||
const b = this.building;
|
||||
const hass = this.hass;
|
||||
// the room panel (a room, or Outside) takes the right side; the Today card would lie under it and catch its taps (#83)
|
||||
if (!b || !hass || this.clean || this.roomId || this.panelOpen) return nothing;
|
||||
const forecast = this.renderForecast("top_right");
|
||||
const today = this.today === false ? nothing : this.renderTodayCard(b, hass);
|
||||
if (today === nothing && forecast === nothing) return nothing;
|
||||
return html`<div class="nf-right-col" style=${this.clock === "top_right" ? "top: 78px" : ""}>${today}${forecast}</div>`;
|
||||
if (today === nothing && forecast === nothing && utilities === nothing) return nothing;
|
||||
return html`<div class="nf-right-col ${utilities !== nothing ? "nf-utility-right" : ""}" style=${this.clock === "top_right" ? "top: 78px" : ""}>${utilities}${today}${forecast}</div>`;
|
||||
}
|
||||
|
||||
private renderTodayCard(b: Building, hass: HomeAssistant) {
|
||||
@@ -2746,6 +2747,15 @@ export class NfView3d extends LitElement {
|
||||
}
|
||||
|
||||
/** The plan's own sensors at the top (outside temperature, the alarm…): their name and state; a tap opens their details. */
|
||||
private utilityOverview(inline: boolean) {
|
||||
const b = this.building;
|
||||
if (!b || !isSymcon(this.hass) || !this.showEnergy || this.clean || this.roomId || this.panelOpen) return nothing;
|
||||
const rooms = b.floors.flatMap((f) => f.rooms), floors = this.floorId ? b.floors.filter((f) => f.id === this.floorId) : b.floors;
|
||||
if (!floors.some((f) => floorUtilityReadings(this.hass, f, rooms).length)) return nothing;
|
||||
return html`<nf-utility-overview ?inline=${inline} .hass=${this.hass} .floors=${b.floors} .floorId=${this.floorId} .compact=${this._narrowStage}
|
||||
@utility-open=${(e: CustomEvent<{ floorId: string; roomId: string | null }>) => { e.stopPropagation(); if (e.detail.roomId) this.openRoom(e.detail.floorId, e.detail.roomId); else this.fire("floor-tap", { floorId: e.detail.floorId }); }}></nf-utility-overview>`;
|
||||
}
|
||||
|
||||
private ownSensors() {
|
||||
const ids = this.sensorBar && this.hass ? (this.building?.settings.status_entities ?? []) : [];
|
||||
const people = isSymcon(this.hass) ? (this.building?.presence ?? []).filter((link) => isSymconVariable(this.hass, link.person, [0])).map((link) => html`<div class="nf-energy-item nf-presence-state"><span>${link.name || entityName(this.hass, link.person)}</span><b>${nativeBool(this.hass.states[link.person]) === null ? "–" : nativeBool(this.hass.states[link.person]) ? "Anwesend" : "Abwesend"}${trendButton(this.hass, [link.person], link.name || "Anwesenheit")}</b></div>`) : [];
|
||||
@@ -2756,7 +2766,7 @@ export class NfView3d extends LitElement {
|
||||
const floors = isSymcon(this.hass) ? (this.building?.floors ?? []).filter((f) => !this.floorId || f.id === this.floorId).map((f) => ({ floor: f, readings: floorUtilityReadings(this.hass, f, this.building?.floors.flatMap((x) => x.rooms)) })).filter((f) => f.readings.length) : [];
|
||||
const utilities = floors.length ? html`<button class="nf-energy-item nf-flow-toggle nf-utility-toggle" aria-label="Stockwerkszähler anzeigen" title="Stockwerkszähler anzeigen" aria-haspopup="dialog" @click=${() => this.renderRoot.querySelector<HTMLDialogElement>(".nf-utility-dialog")?.showModal()}><span>Stockwerkszähler</span><b aria-hidden="true">⚡ 💧</b></button>
|
||||
<dialog class="nf-weather-dialog nf-utility-dialog" aria-label="Stockwerkszähler" @keydown=${(event: KeyboardEvent) => event.stopPropagation()}><header><b>Stockwerkszähler</b><button type="button" class="nf-chip" aria-label="Schließen" @click=${() => this.renderRoot.querySelector<HTMLDialogElement>(".nf-utility-dialog")?.close()}>×</button></header>${floors.map(({ floor, readings }) => html`<h3>${floor.name}</h3><nf-utility-report .hass=${this.hass} .readings=${readings}></nf-utility-report>`)}</dialog>` : nothing;
|
||||
return [...people, weatherValues, utilities, ...ids
|
||||
return [this.utilityOverview(true), ...people, weatherValues, utilities, ...ids
|
||||
.filter((id) => this.hass.states[id])
|
||||
.map(
|
||||
(id) => html`<button class="nf-energy-item nf-own-sensor" title=${entityName(this.hass, id)} @click=${() => openMoreInfo(this, id)}>
|
||||
@@ -2819,17 +2829,18 @@ export class NfView3d extends LitElement {
|
||||
}
|
||||
|
||||
protected render() {
|
||||
const utilities = this.utilityOverview(false);
|
||||
const sky = this._sky;
|
||||
const mix = (a: number[], b: number[]) => `rgb(${a.map((v, i) => Math.round(v + (b[i] - v) * sky)).join(",")})`;
|
||||
const stage = STAGE[this.theme] ?? STAGE.neon;
|
||||
const style = `--nf-sky:${mix(stage.night[0], stage.day[0])};--nf-ground:${mix(stage.night[1], stage.day[1])}` + backdropStyle(this.building?.settings.backdrop);
|
||||
return html`<div
|
||||
class="nf-stage ${this.roomLabels ? "" : "nf-no-room-names"} ${this._low ? "nf-low" : ""} ${this.panelOpen ? "nf-panel-open" : ""} ${this._alerts.length ? "nf-has-alerts" : ""} ${this._narrowStage ? "nf-narrow" : ""}"
|
||||
class="nf-stage ${this.roomLabels ? "" : "nf-no-room-names"} ${this._low ? "nf-low" : ""} ${this.panelOpen ? "nf-panel-open" : ""} ${this._alerts.length ? "nf-has-alerts" : ""} ${this._narrowStage ? "nf-narrow" : ""} ${utilities !== nothing ? "nf-has-utility-overview" : ""}"
|
||||
style=${style}
|
||||
>
|
||||
${this._error ? html`<p class="nf-error">${this._error}</p>` : nothing} ${this.renderTopLeft()} ${renderLhCards(this.hass, this._liveCards, (domain, service, entity, data) => this.hass?.callService(domain, service, { entity_id: entity, ...data }), { folded: this._houseFolded, toggle: () => this.toggleHouseFold() }, !!this.roomId || this.panelOpen)} ${this.clean ? nothing : this.renderLegend()} ${this.renderMapCredit()}
|
||||
${this.renderAlerts()} ${this.renderAnnouncement()} ${this.clean ? nothing : html`${this.renderThumbs()} ${this.renderScenes()} ${this.renderFind()} ${this.renderCentral()}`} ${this.renderSwipe()}
|
||||
${this.renderMenu()} ${this.renderPlate()} ${this.renderEye()} ${this.renderLock()} ${this.renderWalk()} ${this.renderTravel()} ${this.renderClock()} ${this.renderToday()} ${this.renderLayers()} ${this.renderPluginWindow()}
|
||||
${this.renderMenu()} ${this.renderPlate()} ${this.renderEye()} ${this.renderLock()} ${this.renderWalk()} ${this.renderTravel()} ${this.renderClock()} ${this.renderToday(utilities)} ${this.renderLayers()} ${this.renderPluginWindow()}
|
||||
${this.showStats && this._stats
|
||||
? html`<span class="nf-stats"
|
||||
><b>${this._stats.fps ? translate(this.hass, "stats_fps", { fps: this._stats.fps, ms: this._stats.worstMs }) : translate(this.hass, "stats_idle")}</b>
|
||||
@@ -3411,6 +3422,24 @@ export class NfView3d extends LitElement {
|
||||
.nf-right-col > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
.nf-utility-right {
|
||||
height: calc(100% - 140px);
|
||||
}
|
||||
.nf-has-utility-overview:not(.nf-narrow) > .nf-energy,
|
||||
.nf-has-utility-overview:not(.nf-narrow) > .nf-topleft {
|
||||
max-width: calc(100% - 316px);
|
||||
}
|
||||
.nf-has-utility-overview .nf-energy {
|
||||
align-items: flex-start;
|
||||
}
|
||||
.nf-narrow .nf-utility-right {
|
||||
top: auto !important;
|
||||
bottom: 64px;
|
||||
height: 42%;
|
||||
max-height: 42%;
|
||||
justify-content: flex-end;
|
||||
width: min(280px, calc(100% - 24px));
|
||||
}
|
||||
.nf-has-alerts .nf-right-col {
|
||||
top: 58px;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user