feat: add native Symcon room climate, schedules, weather and presence
This commit is contained in:
1 parent
510aece983
commit
18e73194e0
37 files changed
+2861
-2132
No files matched your search
@@ -50,6 +50,8 @@ import { scaleGlow, buildMarkers, openMoreInfo, stateText, toggleEntity, withPlu
|
||||
import { fanSpin } from "../entities/fans.ts";
|
||||
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 { deviceValuesText } from "../entities/device-values.ts";
|
||||
import { furnitureShown, hiddenFurniture, withoutHidden } from "../entities/visibility.ts";
|
||||
import { pictureUrl } from "../entities/pictures.ts";
|
||||
@@ -1133,7 +1135,7 @@ export class NfView3d extends LitElement {
|
||||
for (const floor of b.floors)
|
||||
for (const room of floor.rooms) {
|
||||
const st = room.floor_heating ? hass.states[room.floor_heating] : undefined;
|
||||
const heats = st && (st.entity_id.startsWith("climate.") ? st.attributes.hvac_action === "heating" : st.state === "on" || st.state === "open");
|
||||
const heats = st && (isSymcon(hass) ? nativeBool(st) === true : st.entity_id.startsWith("climate.") ? st.attributes.hvac_action === "heating" : st.state === "on" || st.state === "open");
|
||||
if (heats) (tint ??= new Map()).set(room.id, [0.55, 0.24, 0.08]);
|
||||
}
|
||||
}
|
||||
@@ -2742,13 +2744,18 @@ 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 ownSensors() {
|
||||
const ids = this.sensorBar && this.hass ? (this.building?.settings.status_entities ?? []) : [];
|
||||
return ids
|
||||
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"}</b></div>`) : [];
|
||||
const weather = isSymcon(this.hass) ? Object.entries(this.building?.settings.weather_variables ?? {}).filter((entry): entry is [keyof typeof WEATHER_VARIABLE_LABELS, string] => !!entry[1] && entry[1] !== "none").map(([key, id]) => [WEATHER_VARIABLE_LABELS[key] || key, id]) : [];
|
||||
if (isSymcon(this.hass) && this.building?.settings.rain_sensor && this.building.settings.rain_sensor !== "none") weather.push(["Regensensor", this.building.settings.rain_sensor]);
|
||||
const weatherValues = weather.length ? html`<button class="nf-energy-item nf-flow-toggle nf-weather-values" aria-label="Wetterwerte anzeigen" title="Wetterwerte anzeigen" aria-haspopup="dialog" @click=${() => this.renderRoot.querySelector<HTMLDialogElement>(".nf-weather-dialog")?.showModal()}><span>Wetter</span><b aria-hidden="true">⛅</b></button>
|
||||
<dialog class="nf-weather-dialog" aria-label="Wetterwerte" @keydown=${(event: KeyboardEvent) => event.stopPropagation()}><header><b>Wetter</b><button type="button" class="nf-chip" aria-label="Schließen" @click=${() => this.renderRoot.querySelector<HTMLDialogElement>(".nf-weather-dialog")?.close()}>×</button></header>${weather.map(([label, id]) => html`<p><span>${label}</span><b>${nativeText(this.hass.states[id])}</b></p>`)}</dialog>` : nothing;
|
||||
return [...people, weatherValues, ...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)}>
|
||||
<span>${entityName(this.hass, id)}</span><b>${stateText(this.hass, this.hass.states[id])}</b>
|
||||
</button>`,
|
||||
);
|
||||
)];
|
||||
}
|
||||
|
||||
/** The map's credit while a real map lies under the plan (OpenStreetMap asks for it). */
|
||||
@@ -4262,6 +4269,11 @@ export class NfView3d extends LitElement {
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
}
|
||||
.nf-weather-dialog { pointer-events:auto; width:min(380px,calc(100vw - 32px)); max-height:75dvh; overflow:auto; box-sizing:border-box; padding:16px; background:var(--nf-chrome-solid); color:var(--nf-text); font:14px/1.5 system-ui,sans-serif; border:1px solid var(--nf-line); border-radius:12px; box-shadow:var(--nf-shadow); }
|
||||
.nf-weather-dialog::backdrop { background:#0008; }
|
||||
.nf-weather-dialog header,.nf-weather-dialog p { display:flex; justify-content:space-between; gap:16px; margin:8px 0; }
|
||||
.nf-weather-dialog p span { color:var(--nf-muted); }
|
||||
.nf-weather-dialog p b { font-size:13px; white-space:nowrap; }
|
||||
.nf-own-sensor {
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
|
||||
Reference in new issue
Block a user