feat: add floating room climate cards and fix Symcon humidity selection
This commit is contained in:
1 parent
24188f96f7
commit
ff54f4461a
21 files changed
+764
-398
No files matched your search
@@ -30,6 +30,7 @@ import { gateStates } from "../entities/gates.ts";
|
||||
import { weatherEntity } from "../weather.ts";
|
||||
import { chosenEffects, readSkyWeather, withDensity } from "../live/sky-weather.ts";
|
||||
import { energyPicture, houseHub, type EnergyPicture } from "../live/energy-flow.ts";
|
||||
import { roomClimateCards } from "../live/room-climate-card.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";
|
||||
@@ -690,7 +691,7 @@ export class NfView3d extends LitElement {
|
||||
if (changed.has("building") || changed.has("theme") || changed.has("floorThumbs") || changed.has("packs")) this.scheduleThumbs();
|
||||
// markers shown by kind outside the opened room change with the room
|
||||
const byRoom = this.markersOutside ? ["markersOutside", "floorId", "roomId"] : ["markersOutside"];
|
||||
const forced = this.pluginsDirty || ["building", "markerMode", "heatMode", "flows", "alerts", "dimmed", ...byRoom].some((k) => changed.has(k));
|
||||
const forced = this.pluginsDirty || ["building", "markerMode", "heatMode", "flows", "alerts", "dimmed", "holograms", "roomLabels", "floorId", "roomId", ...byRoom].some((k) => changed.has(k));
|
||||
this.pluginsDirty = false;
|
||||
if (forced || changed.has("hass")) this.syncDevices(forced);
|
||||
if (changed.has("autoOrbit")) v.setAutoOrbit(this.autoOrbit ? 0.06 : 0);
|
||||
@@ -969,7 +970,7 @@ export class NfView3d extends LitElement {
|
||||
playing.filter((m) => m.rings > 0).map((m) => ({ id: m.entity, at: m.at, color: m.color, level: m.volume ?? 0.5, size: m.rings })),
|
||||
multiroom(playing).map(([a, c]) => [a.at, c.at]),
|
||||
);
|
||||
this.syncLhCards(v, b, livePic, liveCars, playing);
|
||||
this.syncLhCards(v, b, livePic, liveCars, playing, hass);
|
||||
// TV screens: a TV or monitor linked to a media player that runs shows what runs
|
||||
v.setLiveScreens(this.dimmed ? [] : liveScreens(hass, b, this.furnitureLinks));
|
||||
v.setPictures(this.framePictures(hass, b));
|
||||
@@ -2618,7 +2619,7 @@ export class NfView3d extends LitElement {
|
||||
.catch(() => (this.dayCurves = null));
|
||||
}
|
||||
|
||||
private syncLhCards(v: NextFloorViewer, b: Building, pic: EnergyPicture, cars: ReturnType<NfView3d["liveCars"]>, media: MediaNow[]): void {
|
||||
private syncLhCards(v: NextFloorViewer, b: Building, pic: EnergyPicture, cars: ReturnType<NfView3d["liveCars"]>, media: MediaNow[], hass: HomeAssistant): void {
|
||||
const cards: LiveCard[] = [];
|
||||
const s = pic.summary;
|
||||
const hasEnergy = s.solar !== null || s.grid !== null || s.battery !== null || s.consumption !== null;
|
||||
@@ -2639,6 +2640,7 @@ export class NfView3d extends LitElement {
|
||||
for (const p of this.liveHeatPumps(b)) cards.push({ kind: "heatpump", at: p.at, name: p.name, pump: p.pump });
|
||||
for (const m of media) cards.push({ kind: "media", at: { ...m.at, y: m.at.y + 0.5 }, media: m });
|
||||
}
|
||||
if (this.liveCardsOn && !this.dimmed) cards.push(...roomClimateCards(hass, b, this.floorId, this.roomId));
|
||||
if (JSON.stringify(cards) !== JSON.stringify(this._liveCards)) this._liveCards = cards;
|
||||
v.setLiveAnchors(
|
||||
cards.map((c) => c.at),
|
||||
@@ -2689,7 +2691,9 @@ 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);
|
||||
if (!energy) return own.length ? html`<div class="nf-energy" aria-live="off">${own}</div>` : nothing;
|
||||
const climate = this.building?.floors.some((f) => f.rooms.some((r) => r.climate_card));
|
||||
const climateToggle = climate ? this.renderCardToggle() : nothing;
|
||||
if (!energy) return own.length || climateToggle !== nothing ? html`<div class="nf-energy" aria-live="off">${own}${climateToggle}</div>` : nothing;
|
||||
const t = (k: Parameters<typeof translate>[1]) => translate(this.hass, k);
|
||||
const items: { cls: string; label: string; value: string }[] = [];
|
||||
if (e.solar !== null) items.push({ cls: "solar", label: t("energy_solar"), value: formatPower(this.hass, e.solar) });
|
||||
@@ -2712,15 +2716,17 @@ export class NfView3d extends LitElement {
|
||||
: html`<button class="nf-energy-item nf-flow-toggle" aria-pressed=${this._flows} title=${t("flows_hint")} aria-label=${t("flows")} @click=${() => this.toggleFlows()}>
|
||||
<span>${t("flows")}</span><b>⚡</b>
|
||||
</button>`}
|
||||
${this.holograms !== null
|
||||
? nothing
|
||||
: html`<button class="nf-energy-item nf-flow-toggle" aria-pressed=${this._liveCardOn} title=${t("holos_hint")} aria-label=${t("holos")} @click=${() => this.toggleLhCards()}>
|
||||
<span>${t("holos")}</span><b>◫</b>
|
||||
</button>`}
|
||||
${this.renderCardToggle()}
|
||||
${own}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
private renderCardToggle() {
|
||||
return this.holograms !== null ? nothing : html`<button class="nf-energy-item nf-flow-toggle nf-card-toggle" aria-pressed=${this._liveCardOn} title=${translate(this.hass, "holos_hint")} aria-label=${translate(this.hass, "holos")} @click=${() => this.toggleLhCards()}>
|
||||
<span>${translate(this.hass, "holos")}</span><b>◫</b>
|
||||
</button>`;
|
||||
}
|
||||
|
||||
/** The plan's own sensors at the top (outside temperature, the alarm…): their name and state; a tap opens their details. */
|
||||
private ownSensors() {
|
||||
const ids = this.sensorBar && this.hass ? (this.building?.settings.status_entities ?? []) : [];
|
||||
@@ -2795,7 +2801,7 @@ export class NfView3d extends LitElement {
|
||||
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" : ""}"
|
||||
style=${style}
|
||||
>
|
||||
${this._error ? html`<p class="nf-error">${this._error}</p>` : nothing} ${this.renderTopLeft()} ${renderLhCards(this.hass, this.roomId || this.panelOpen ? [] : this._liveCards, (domain, service, entity, data) => this.hass?.callService(domain, service, { entity_id: entity, ...data }), { folded: this._houseFolded, toggle: () => this.toggleHouseFold() })} ${this.clean ? nothing : this.renderLegend()} ${this.renderMapCredit()}
|
||||
${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.showStats && this._stats
|
||||
|
||||
Reference in new issue
Block a user