fix: show incomplete Symcon utility sums with Err prefix
This commit is contained in:
1 parent
a804fc8e15
commit
bb153490b0
14 files changed
+361
-293
No files matched your search
@@ -11,7 +11,7 @@ import { canAnnounce, roomHasSpeaker } from "../live/announce.ts";
|
||||
import { isSymcon, nativeText } from "../entities/symcon-values.ts";
|
||||
import "./room-hvac.ts";
|
||||
import "./utility-report.ts";
|
||||
import { roomUtilityReadings } from "../utilities.ts";
|
||||
import { roomUtilityReadings, utilityText } from "../utilities.ts";
|
||||
import type { Building, Floor, LightMood, LightSetting, Room } from "../model.ts";
|
||||
import { roomPower, roomPowerSensors } from "../heatmap.ts";
|
||||
import { energyCost, loadRoomEnergy, type RoomEnergy } from "../live/room-energy.ts";
|
||||
@@ -586,8 +586,10 @@ export class NfRoomPanel extends LitElement {
|
||||
const lux = roomClimateValue(this.hass, this.floor ?? null, room, "illuminance");
|
||||
if (lux !== null) out.push(`☀ ${formatNumber(this.hass, lux, 0)} lx`);
|
||||
// what the room's devices draw now
|
||||
const power = this.floor && this.building ? roomPower(this.hass, this.building, this.floor, room) : null;
|
||||
if (power !== null) out.push(`⚡ ${powerText(this.hass, power)}`);
|
||||
const meter = roomUtilityReadings(this.hass, room, this.building?.floors.flatMap((f) => f.rooms)).find((r) => r.kind === "electricity" && r.metric === "power" && r.unit === "W");
|
||||
const power = !meter && this.floor && this.building ? roomPower(this.hass, this.building, this.floor, room) : null;
|
||||
if (meter) out.push(`⚡ ${utilityText(this.hass, meter)}`);
|
||||
else if (power !== null) out.push(`⚡ ${powerText(this.hass, power)}`);
|
||||
// how long its windows and doors stand open (the one open longest)
|
||||
const openSince = this.floor
|
||||
? this.floor.openings
|
||||
|
||||
@@ -14,7 +14,7 @@ class NfUtilityReport extends LitElement {
|
||||
render() {
|
||||
return html`${UTILITY_KINDS.filter((kind) => this.readings.some((r) => r.kind === kind)).map((kind) => html`<section aria-label=${UTILITY_LABELS[kind]}>
|
||||
<h4>${UTILITY_ICONS[kind]} ${UTILITY_LABELS[kind]}</h4>
|
||||
${this.readings.filter((r) => r.kind === kind).map((r) => html`<div class="reading" title=${`${r.manual ? "Stockwerkszähler" : "Bereichszähler"}${r.incomplete ? " · Wert nicht verfügbar" : ""}\n${r.sources.map((id) => this.hass.states[id]?.attributes.symcon_path || this.hass.states[id]?.attributes.friendly_name || id).join("\n")}`}>
|
||||
${this.readings.filter((r) => r.kind === kind).map((r) => html`<div class="reading" title=${`${r.manual ? "Stockwerkszähler" : "Bereichszähler"}${r.incomplete ? " · Err: Mindestens ein Wert fehlt; angezeigt wird die Summe der verfügbaren Werte." : ""}\n${r.sources.map((id) => this.hass.states[id]?.attributes.symcon_path || this.hass.states[id]?.attributes.friendly_name || id).join("\n")}`}>
|
||||
<span>${utilityMetricLabel(r)}${r.manual ? html` <small>· Zähler</small>` : ""}</span><b>${utilityText(this.hass, r)}</b>
|
||||
</div>`)}
|
||||
</section>`)}`;
|
||||
|
||||
@@ -52,7 +52,7 @@ import { fixtureGlow } from "../entities/kinds.ts";
|
||||
import { coverTiltEntity } from "../entities/covers.ts";
|
||||
import { isSymcon, isSymconVariable, nativeBool, nativeText } from "../entities/symcon-values.ts";
|
||||
import { WEATHER_VARIABLE_LABELS } from "../symcon-weather.ts";
|
||||
import { floorUtilityReadings } from "../utilities.ts";
|
||||
import { floorUtilityReadings, utilityText } from "../utilities.ts";
|
||||
import "./utility-report.ts";
|
||||
import { deviceValuesText } from "../entities/device-values.ts";
|
||||
import { furnitureShown, hiddenFurniture, withoutHidden } from "../entities/visibility.ts";
|
||||
@@ -2600,10 +2600,11 @@ export class NfView3d extends LitElement {
|
||||
const hass = this.hass;
|
||||
const rows: { icon: string; label: string; value: string }[] = [];
|
||||
const floor = this.floorId ? b.floors.find((f) => f.id === this.floorId) : undefined;
|
||||
const floorPower = floor && isSymcon(hass) ? floorUtilityReadings(hass, floor, b.floors.flatMap((f) => f.rooms)).find((r) => r.kind === "electricity" && r.metric === "power" && r.unit === "W")?.value ?? null : floor?.power_entity ? readPower(hass?.states[floor.power_entity]) : null;
|
||||
if (floor && floorPower !== null) {
|
||||
const share = consumption && consumption > 0 ? ` · ${translate(hass, "floor_power_share", { n: Math.round((Math.max(0, floorPower) / consumption) * 100) })}` : "";
|
||||
rows.push({ icon: "⚡", label: floor.name, value: `${powerText(hass, floorPower)}${share}` });
|
||||
const meter = floor && isSymcon(hass) ? floorUtilityReadings(hass, floor, b.floors.flatMap((f) => f.rooms)).find((r) => r.kind === "electricity" && r.metric === "power" && r.unit === "W") : undefined;
|
||||
const floorPower = isSymcon(hass) ? meter?.value ?? null : floor?.power_entity ? readPower(hass?.states[floor.power_entity]) : null;
|
||||
if (floor && (meter || floorPower !== null)) {
|
||||
const share = !meter?.incomplete && floorPower !== null && consumption && consumption > 0 ? ` · ${translate(hass, "floor_power_share", { n: Math.round((Math.max(0, floorPower) / consumption) * 100) })}` : "";
|
||||
rows.push({ icon: "⚡", label: floor.name, value: `${meter ? utilityText(hass, meter) : powerText(hass, floorPower!)}${share}` });
|
||||
}
|
||||
for (const [key, icon, label] of [["gas", "🔥", "energy_gas_short"], ["water", "💧", "energy_water_short"]] as const) {
|
||||
const id = b.energy[key];
|
||||
|
||||
Reference in new issue
Block a user