feat: add native Symcon room climate, schedules, weather and presence

This commit is contained in:
jhartworks committed 2026-11-11 09:34:26 +01:00
1 parent 510aece983
commit 18e73194e0
37 files changed
+2861 -2132

No files matched your search

+2 -1
View File
@@ -2,6 +2,7 @@
import { html, LitElement, nothing, svg, type PropertyValues, type TemplateResult } from "lit";
import { withCoverControls } from "../entities/cover-controls.ts";
import { withSymconWeather } from "../symcon-weather.ts";
import { hint } from "./editor/fields.ts";
import { fetchImage, importPack, storeImage } from "../api.ts";
import { defaultHeight, entityName, kindOf, roomEntities } from "../devices.ts";
@@ -1049,7 +1050,7 @@ export class NfEditor extends LitElement {
</div>`}
${this.render3dBar()}
<nf-view3d
.hass=${this.hass ? withCoverControls(this.hass, this._doc3d.floors) : undefined}
.hass=${this.hass ? withSymconWeather(withCoverControls(this.hass, this._doc3d.floors), this._doc3d.settings) : undefined}
.building=${this._doc3d}
.floorId=${this.houseTool ? null : this._floorId}
.roomId=${null}
@@ -7,6 +7,8 @@ import { pointInPolygon, type Room } from "../../../model.ts";
import { entityOptions } from "../entities.ts";
import { checkField, deviceIcon, entityField, hint } from "../fields.ts";
import type { EditorHost } from "../host.ts";
import { isSymcon } from "../../../entities/symcon-values.ts";
import { renderSymconRoomHvac } from "../symcon-fields.ts";
import { matchesQuery, placedElsewhere, placedInRoom, rankedBy, takeFirst, withToggled } from "../ops/device-list.ts";
import type { SideState } from "../side-state.ts";
@@ -126,7 +128,7 @@ export function renderDeviceList(host: EditorHost, state: SideState, room: Room,
export function renderRoomClimate(host: EditorHost, room: Room, patch: (patch: Partial<Room>) => void): TemplateResult | typeof nothing {
const { hass } = host;
if (!hass) return nothing;
const chosen = !!room.climate && Object.values(room.climate).some((x) => x != null);
const chosen = !!room.floor_heating || !!room.hvac || (!!room.climate && Object.values(room.climate).some((x) => x != null));
const change = (key: ClimateKey, value: string | string[] | null) => {
const next = { ...(room.climate ?? {}), [key]: value };
patch({ climate: Object.values(next).every((x) => x == null) ? null : next });
@@ -148,7 +150,7 @@ export function renderRoomClimate(host: EditorHost, room: Room, patch: (patch: P
};
return html`<details class="nf-points" ?open=${chosen || !!room.climate_card}>
<summary>${host.t("climate")}</summary>
<div class="nf-form">${field("temperature", host.t("climate_temperature"))} ${field("humidity", host.t("climate_humidity"))} ${field("co2", host.t("climate_co2"))} ${field("illuminance", host.t("climate_illuminance"))}</div>
<div class="nf-form">${field("temperature", host.t("climate_temperature"))} ${field("humidity", host.t("climate_humidity"))} ${field("co2", host.t("climate_co2"))} ${field("illuminance", host.t("climate_illuminance"))}${isSymcon(hass) ? renderSymconRoomHvac(host, room, patch) : nothing}</div>
${checkField(host, host.t("climate_card"), !!room.climate_card, (on) => patch({ climate_card: on || undefined }))}
${hint(host.t("climate_card_hint"))}
${hint(host.t("climate_hint"))}
@@ -5,6 +5,8 @@ import { entityName, outsideEntities } from "../../../devices.ts";
import type { I18nKey } from "../../../i18n.ts";
import { BUTTON_ACTIONS, uid, type ButtonAction, type Circuit, type CustomButton, type ForecastCard, type MediaPreset, type OwnAlert, type StartView } from "../../../model.ts";
import { entityOptions, isNumeric } from "../entities.ts";
import { isSymcon } from "../../../entities/symcon-values.ts";
import { renderSymconPresence } from "../symcon-fields.ts";
import { actions, checkField, colorField, entityField, hint, iconField, selectField, textField } from "../fields.ts";
import type { EditorHost } from "../host.ts";
import { likelyRoomSensors, parseButtonData, patchPresence, startViewYaml } from "../ops/house.ts";
@@ -267,6 +269,7 @@ export function renderStartView(host: EditorHost, paneView: () => StartView | nu
/** Which room sensor says where each person is. */
export function renderPresence(host: EditorHost): TemplateResult {
if (isSymcon(host.hass)) return renderSymconPresence(host);
const linked = host.doc.presence.map((l) => l.person);
const persons = [...new Set([...Object.keys(host.hass?.states ?? {}).filter((id) => id.startsWith("person.")).sort(), ...linked])];
const numeric = entityOptions(host.hass, isNumeric);
@@ -296,6 +299,7 @@ export function renderPresence(host: EditorHost): TemplateResult {
/** Locating Bluetooth tags by room: pick a tag, walk through the rooms, record them (the element does the work). */
export function renderBleLocate(host: EditorHost, doc: unknown): TemplateResult {
if (isSymcon(host.hass)) return html``;
return html`<details class="nf-section">
<summary>${host.t("ble")}</summary>
${hint(host.t("ble_hint"))}
+4 -3
View File
@@ -14,6 +14,7 @@ import { formatArea, formatLength } from "../../../units.ts";
import { generateWalls, innerSize, type Wall } from "../../../geometry/walls.ts";
import { countsAsLiving, roomArea } from "../../../geometry/living-area.ts";
import { roomSpeaker } from "../../../live/announce.ts";
import { isSymcon } from "../../../entities/symcon-values.ts";
/** What the room form makes the editor do, and the parts of it that the editor still draws itself. */
export interface RoomActions {
@@ -120,7 +121,7 @@ function ceilingField(host: EditorHost, room: Room, floor: Floor, actions: RoomA
/** Announcements in the room: its speaker (automatic, chosen, or none) and a quiet time. */
function announceFields(host: EditorHost, room: Room, floor: Floor | null, actions: RoomActions): TemplateResult {
const t = host.t;
if (!host.hass) return html``;
if (!host.hass || isSymcon(host.hass)) return html``;
const auto = roomSpeaker(host.hass, floor, { ...room, announce_speaker: null });
const speakers = entityOptions(host.hass, (id) => /^(media_player|assist_satellite)\./.test(id) || (id.startsWith("notify.") && id.endsWith("_announce")));
const quiet = room.announce_quiet ?? null;
@@ -171,8 +172,8 @@ export function renderRoomForm(host: EditorHost, state: SideState, room: Room, a
${hint(t("room_floor_offset_hint"), "nf-wide")}
${entityField(host, t("room_clean"), room.clean_entity ?? null, undefined, entityOptions(host.hass, (id) => /^(script|button|input_button)\./.test(id)), (v) => actions.patch({ clean_entity: v && v !== "none" ? v : null }))}
${room.clean_entity ? nothing : hint(t("room_clean_hint"), "nf-wide")}
${entityField(host, t("floor_heating"), room.floor_heating ?? null, undefined, entityOptions(host.hass, (id) => /^(climate|switch|valve|binary_sensor|input_boolean)\./.test(id)), (v) => actions.patch({ floor_heating: v && v !== "none" ? v : null }))}
${room.floor_heating ? hint(t("floor_heating_hint"), "nf-wide") : nothing}
${isSymcon(host.hass) ? nothing : entityField(host, t("floor_heating"), room.floor_heating ?? null, undefined, entityOptions(host.hass, (id) => /^(climate|switch|valve|binary_sensor|input_boolean)\./.test(id)), (v) => actions.patch({ floor_heating: v && v !== "none" ? v : null }))}
${room.floor_heating && !isSymcon(host.hass) ? hint(t("floor_heating_hint"), "nf-wide") : nothing}
${announceFields(host, room, host.floor ?? null, actions)}
${inner ? html`<p class="nf-sub nf-wide" title=${t("room_inner_hint")}>${t("room_inner", { w: formatLength(host.hass, inner[0]), d: formatLength(host.hass, inner[1]) })}</p>` : nothing}
${livingLine(host, room, walls)}
@@ -1,5 +1,7 @@
import { html, nothing, type TemplateResult } from "lit";
import { weatherEntity } from "../../../weather.ts";
import { isSymcon } from "../../../entities/symcon-values.ts";
import { renderSymconWeather } from "../symcon-fields.ts";
import type { I18nKey } from "../../../i18n.ts";
import { DEFAULT_PAINT_INSIDE, DEFAULT_PAINT_OUTSIDE, DEFAULT_WEATHER_EFFECTS, WEATHER_EFFECTS, type Building, type RoofType } from "../../../model.ts";
import { entityName } from "../../../devices.ts";
@@ -91,14 +93,14 @@ export function renderSettings(host: EditorHost, actions: SettingsActions): Temp
: nothing}
${gable ? numberField(host, t("roof_pitch"), s.roof.pitch, (v) => setRoof({ pitch: clamp(v, 5, 60) }), 1, 5) : nothing}
${s.roof.type !== "none" ? numberField(host, t("roof_overhang"), s.roof.overhang, (v) => setRoof({ overhang: clamp(v, 0, 2) }), 0.05, 0) : nothing}
${host.hass ? entityField(host, t("weather_entity"), s.weather_entity ?? null, weatherEntity(host.hass, null), entityOptions(host.hass, (id) => id.startsWith("weather.")), (v) => set({ weather_entity: v })) : nothing}
${isSymcon(host.hass) ? renderSymconWeather(host, s, set) : host.hass ? entityField(host, t("weather_entity"), s.weather_entity ?? null, weatherEntity(host.hass, null), entityOptions(host.hass, (id) => id.startsWith("weather.")), (v) => set({ weather_entity: v })) : nothing}
<div class="nf-sub nf-wide">${t("weather_effects")}</div>
${WEATHER_EFFECTS.map((effect) => checkField(host, t(`weather_effect_${effect}` as I18nKey), current.includes(effect), (on) => set({ weather_effects: withEffect(current, effect, on) }), { wide: false }))}
${checkField(host, t("rain_warning"), s.rain_warning !== false, (on) => set({ rain_warning: on }))}
${host.hass && s.rain_warning !== false
${host.hass && !isSymcon(host.hass) && s.rain_warning !== false
? entityField(host, t("rain_sensor"), s.rain_sensor ?? null, undefined, entityOptions(host.hass, (id) => /^(binary_sensor|sensor)\./.test(id)), (v) => set({ rain_sensor: v === "none" ? null : v }))
: nothing}
${host.hass && s.rain_warning !== false && s.rain_sensor && s.rain_sensor !== "none" ? checkField(host, t("rain_sensor_inverted"), !!s.rain_sensor_inverted, (on) => set({ rain_sensor_inverted: on || undefined }), { title: t("rain_sensor_inverted_hint") }) : nothing}
${host.hass && !isSymcon(host.hass) && s.rain_warning !== false && s.rain_sensor && s.rain_sensor !== "none" ? checkField(host, t("rain_sensor_inverted"), !!s.rain_sensor_inverted, (on) => set({ rain_sensor_inverted: on || undefined }), { title: t("rain_sensor_inverted_hint") }) : nothing}
${host.hass ? entityField(host, t("outage_sensor"), s.outage_sensor ?? null, undefined, entityOptions(host.hass, (id) => /^(binary_sensor|sensor)\./.test(id)), (v) => set({ outage_sensor: v === "none" ? null : v })) : nothing}
${hint(t("outage_hint"), "nf-wide")}
${checkField(host, t("contact_warning"), !!s.contact_warning, (on) => set({ contact_warning: on || undefined }), { title: t("contact_warning_hint") })}
@@ -106,7 +108,7 @@ export function renderSettings(host: EditorHost, actions: SettingsActions): Temp
${selectField(host, t("room_double_tap"), s.room_double_tap ?? "area", [["area", t("room_double_tap_area")], ["plan", t("room_double_tap_plan")], ["off", t("room_double_tap_off")]] as const, (v) => set({ room_double_tap: v === "plan" || v === "off" ? v : null }), { title: t("room_double_tap_hint") })}
${checkField(host, t("motion_markers_active"), !!s.motion_markers_active, (on) => set({ motion_markers_active: on || undefined }), { title: t("motion_markers_active_hint") })}
${host.hass ? statusFields(host, s.status_entities ?? [], (status_entities) => set({ status_entities: status_entities.length ? status_entities : null })) : nothing}
${host.hass ? entityField(host, t("announce_tts"), s.announce_tts ?? null, undefined, entityOptions(host.hass, (id) => id.startsWith("tts.")), (v) => set({ announce_tts: v === "none" ? null : v })) : nothing}
${isSymcon(host.hass) ? nothing : html`${host.hass ? entityField(host, t("announce_tts"), s.announce_tts ?? null, undefined, entityOptions(host.hass, (id) => id.startsWith("tts.")), (v) => set({ announce_tts: v === "none" ? null : v })) : nothing}
<label class="nf-field nf-wide"
>${t("announce_phrases")}
<textarea
@@ -120,11 +122,11 @@ export function renderSettings(host: EditorHost, actions: SettingsActions): Temp
}}
></textarea>
</label>
${hint(t("announce_phrases_hint"), "nf-wide")}
${hint(t("announce_phrases_hint"), "nf-wide")}`}
${checkField(host, t("sun_patches"), s.sun_patches !== false, (on) => set({ sun_patches: on }), { title: t("sun_patches_hint") })}
${checkField(host, t("sun_arc"), s.sun_arc === true, (on) => set({ sun_arc: on }), { title: t("sun_arc_hint") })}
${backdropFields(host, s.backdrop ?? null, (backdrop) => set({ backdrop }))}
</div>
${hint(`${t("north_hint")} ${t("weather_entity_hint")}`)}
${hint(isSymcon(host.hass) ? t("north_hint") : `${t("north_hint")} ${t("weather_entity_hint")}`)}
</details>`;
}
@@ -0,0 +1,50 @@
import { html, nothing } from "lit";
import { WEATHER_VARIABLE_KEYS, type BuildingSettings, type PresenceLink, type Room, type RoomHvac } from "../../model.ts";
import { WEATHER_VARIABLE_LABELS } from "../../symcon-weather.ts";
import { ROOM_HVAC_FIELDS } from "../../entities/room-hvac.ts";
import { isSymconVariable } from "../../entities/symcon-values.ts";
import { entityName } from "../../devices.ts";
import { entityOptions } from "./entities.ts";
import { checkField, entityField, hint, textField } from "./fields.ts";
import type { EditorHost } from "./host.ts";
export function renderSymconRoomHvac(host: EditorHost, room: Room, patch: (change: Partial<Room>) => void) {
const set = (change: Partial<RoomHvac>) => patch({ hvac: { ...room.hvac, ...change } });
const schedules = room.hvac?.schedules ?? [];
const plans = entityOptions(host.hass, (id) => !!host.hass?.states[id]?.attributes.symcon_schedule);
return html`
${entityField(host, host.t("floor_heating"), room.floor_heating ?? null, undefined, entityOptions(host.hass, (id) => isSymconVariable(host.hass, id, [0, 1, 2])), (v) => patch({ floor_heating: v === "none" ? null : v }))}
${ROOM_HVAC_FIELDS.map((field) => entityField(host, field.label, room.hvac?.[field.key] ?? null, undefined, entityOptions(host.hass, (id) => isSymconVariable(host.hass, id, field.types)), (v) => set({ [field.key]: v === "none" ? null : v })))}
${hint("Raumstatus zeigt den in Symcon hinterlegten Alias der Integer-Variable. Beschreibbare Heizungs- und Lüftungswerte können im Raummenü bedient werden.", "nf-wide")}
${schedules.map((id, i) => entityField(host, `Schaltuhr ${i + 1}`, id, undefined, plans.filter((p) => p.id === id || !schedules.includes(p.id)), (v) => set({ schedules: v && v !== "none" ? schedules.map((old, j) => i === j ? v : old) : schedules.filter((_, j) => i !== j) })))}
${entityField(host, "Schaltuhr hinzufügen", null, undefined, plans.filter((p) => !schedules.includes(p.id)), (v) => v && v !== "none" && set({ schedules: [...schedules, v] }))}`;
}
export function renderSymconWeather(host: EditorHost, settings: BuildingSettings, set: (change: Partial<BuildingSettings>) => void) {
return html`<details class="nf-wide nf-symcon-weather"><summary>Wettervariablen</summary><div class="nf-form">
${WEATHER_VARIABLE_KEYS.map((key) => entityField(host, WEATHER_VARIABLE_LABELS[key], settings.weather_variables?.[key] ?? null, undefined,
entityOptions(host.hass, (id) => isSymconVariable(host.hass, id, key === "condition" ? [0, 1, 2, 3] : key === "wind_bearing" ? [1, 2, 3] : ["snow", "fog", "lightning"].includes(key) ? [0, 1, 2] : [1, 2])),
(v) => set({ weather_variables: { ...settings.weather_variables, [key]: v === "none" ? null : v } })))}
${entityField(host, host.t("rain_sensor"), settings.rain_sensor ?? null, undefined, entityOptions(host.hass, (id) => isSymconVariable(host.hass, id, [0, 1, 2])), (v) => set({ rain_sensor: v === "none" ? null : v }))}
${settings.rain_sensor ? checkField(host, host.t("rain_sensor_inverted"), !!settings.rain_sensor_inverted, (on) => set({ rain_sensor_inverted: on || undefined })) : nothing}
${hint("Wähle die Wetterwerte einzeln aus dem Symcon-Objektbaum. Einheiten werden aus den Variablen übernommen. Der Regensensor kann Boolean oder eine numerische Regenrate sein.", "nf-wide")}
</div></details>`;
}
export function renderSymconPresence(host: EditorHost) {
const links = host.doc.presence;
const replace = (next: PresenceLink[]) => host.replace({ ...structuredClone(host.doc), presence: next });
const patch = (i: number, change: Partial<PresenceLink>) => replace(links.map((link, j) => j === i ? { ...link, ...change, sensor: null } : link));
const rooms = host.doc.floors.flatMap((f) => f.rooms.map((r) => ({ id: r.id, name: `${f.name} · ${r.name}` })));
const options = entityOptions(host.hass, (id) => isSymconVariable(host.hass, id, [0]));
return html`<details class="nf-section nf-symcon-presence"><summary>${host.t("presence")}</summary>
${links.map((link, i) => html`<div class="nf-form">
${textField(host, "Person", link.name ?? entityName(host.hass, link.person), (name) => patch(i, { name }), { wide: true, maxlength: 100 })}
${entityField(host, "Anwesenheit (Boolean)", link.person, undefined, options.filter((o) => o.id === link.person || !links.some((l) => l.person === o.id)), (v) => v && v !== "none" ? patch(i, { person: v }) : replace(links.filter((_, j) => j !== i)))}
<label class="nf-field nf-wide">Raum für die 3D-Anzeige<select ?disabled=${!host.admin} .value=${link.room ?? ""} @change=${(e: Event) => patch(i, { room: (e.target as HTMLSelectElement).value || null })}><option value="">Kein Raum</option>${rooms.map((r) => html`<option value=${r.id}>${r.name}</option>`)}</select></label>
<button class="nf-link nf-wide" ?disabled=${!host.admin} @click=${() => replace(links.filter((_, j) => j !== i))}>× Person entfernen</button>
</div>`)}
<div class="nf-form">${entityField(host, "Person hinzufügen (Boolean)", null, undefined, options.filter((o) => !links.some((l) => l.person === o.id)), (v) => v && v !== "none" && replace([...links, { person: v, sensor: null }]))}</div>
${hint("Jede Person wird mit einer beliebigen Boolean-Variable verknüpft: true bedeutet anwesend, false abwesend. Ein Raum ist optional und bestimmt die Position der Person in 3D.")}
</details>`;
}
+90
View File
@@ -0,0 +1,90 @@
import { css, html, LitElement, nothing } from "lit";
import type { Room } from "../model.ts";
import type { HomeAssistant } from "../types.ts";
import { ROOM_HVAC_FIELDS } from "../entities/room-hvac.ts";
import { nativeBool, nativeNumber, nativeText, nativeValue } from "../entities/symcon-values.ts";
import { controls, tokens } from "../styles.ts";
interface SchedulePoint { hour: number; minute: number; second: number; action: number }
interface ScheduleGroup { id: number; days: number; points: SchedulePoint[] }
interface ScheduleAction { id: number; name: string; color: number }
export class NfRoomHvac extends LitElement {
static properties = { hass: { attribute: false }, room: { attribute: false }, _pending: { state: true }, _error: { state: true } };
declare hass: HomeAssistant;
declare room: Room;
private declare _pending: Set<string>;
private declare _error: string;
constructor() { super(); this._pending = new Set(); this._error = ""; }
private async send(id: string, domain: string, service: string, data: Record<string, unknown>) {
this._pending = new Set([...this._pending, id]);
this._error = "";
try { await this.hass.callService(domain, service, { entity_id: id, ...data }); }
catch (error) { this._error = error instanceof Error ? error.message : String(error); }
finally { this._pending = new Set([...this._pending].filter((x) => x !== id)); }
}
private value(label: string, id: string, control: boolean) {
const st = this.hass.states[id], value = nativeValue(st), a = st?.attributes;
const writable = control && !!a?.symcon_has_action && value !== null && !this._pending.has(id);
return html`<div class="value"><span>${label}</span><b>${nativeText(st)}</b>
${control && a?.symcon_has_action && a.symcon_variable_type === 0 ? html`<button class="nf-chip" aria-pressed=${nativeBool(st) === true} ?disabled=${!writable} @click=${() => void this.send(id, "symcon", "set_value", { value: !nativeBool(st) })}>${nativeBool(st) ? "Ein" : "Aus"}</button>`
: control && a?.symcon_has_action && [1, 2].includes(Number(a.symcon_variable_type)) ? html`<input type="number" aria-label=${label} .value=${String(nativeNumber(st) ?? "")} min=${String(a.symcon_min ?? 0)} max=${String(a.symcon_max ?? 100)} step=${String(a.symcon_step || (a.symcon_variable_type === 1 ? 1 : 0.1))} ?disabled=${!writable}
@change=${(event: Event) => { const input = event.target as HTMLInputElement; if (input.value.trim() && input.checkValidity()) void this.send(id, "symcon", "set_value", { value: Number(input.value) }); }} />` : nothing}
</div>`;
}
private schedule(id: string) {
const st = this.hass.states[id];
if (!st?.attributes.symcon_schedule) return html`<p class="missing">Schaltuhr nicht verfügbar</p>`;
const actions = (st.attributes.actions ?? []) as ScheduleAction[];
const groups = (st.attributes.groups ?? []) as ScheduleGroup[];
const next = Number(st.attributes.next_run ?? 0);
const nextAction = actions.find((a) => a.id === st.attributes.next_action);
const days = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"];
const time = (p: SchedulePoint) => `${String(p.hour).padStart(2, "0")}:${String(p.minute).padStart(2, "0")}${p.second ? `:${String(p.second).padStart(2, "0")}` : ""}`;
return html`<details class="schedule"><summary>${String(st.attributes.friendly_name ?? "Schaltuhr")}</summary>
<label class="nf-check"><input type="checkbox" .checked=${st.state === "on"} ?disabled=${this._pending.has(id)} @change=${(e: Event) => void this.send(id, "schedule", "set_active", { active: (e.target as HTMLInputElement).checked })} /> Aktiv</label>
${next > 0 ? html`<p class="next">Nächster Schaltpunkt: ${new Date(next * 1000).toLocaleString(this.hass.language)}${nextAction ? ` · ${nextAction.name}` : ""}</p>` : nothing}
${groups.length ? groups.map((group) => html`<div class="schedule-group"><b>${days.filter((_, i) => group.days & (1 << i)).join(" · ")}</b><div class="points">
${[...group.points].sort((a, b) => a.hour * 3600 + a.minute * 60 + a.second - (b.hour * 3600 + b.minute * 60 + b.second)).map((point) => {
const action = actions.find((a) => a.id === point.action);
return html`<span class="point"><time>${time(point)}</time><span class="dot" style=${`background:#${Number(action?.color ?? 0x8796a9).toString(16).padStart(6, "0").slice(-6)}`}></span>${action?.name || "Aktion"}</span>`;
})}
</div></div>`) : html`<p class="missing">Keine Schaltpunkte vorhanden.</p>`}
</details>`;
}
render() {
if (!this.hass || !this.room) return nothing;
const rows = ROOM_HVAC_FIELDS.filter((field) => field.key !== "status" && this.room.hvac?.[field.key] && this.room.hvac[field.key] !== "none");
const plans = this.room.hvac?.schedules ?? [];
const heating = this.room.floor_heating && this.room.floor_heating !== "none" ? this.room.floor_heating : null;
return html`${heating || rows.length ? html`<section><h3>Raumklima</h3>${heating ? this.value("Fußbodenheizung", heating, true) : nothing}${rows.map((field) => this.value(field.label, this.room.hvac![field.key]!, !!field.control))}</section>` : nothing}
${plans.length ? html`<section><h3>Schaltuhren</h3>${plans.map((id) => this.schedule(id))}</section>` : nothing}
${this._error ? html`<p role="alert" class="error">${this._error}</p>` : nothing}`;
}
static styles = [tokens, controls, css`
:host { display:block; }
section { margin:18px 0; }
h3 { font-size:12px; text-transform:uppercase; letter-spacing:.05em; color:var(--nf-muted); margin:0 0 8px; }
.value { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:center; padding:10px 0; border-bottom:1px solid var(--nf-line); }
.value b { font-size:13px; color:var(--nf-muted); }
.value input,.value button { grid-column:2; max-width:110px; min-width:0; }
input[type=number] { background:var(--nf-fill); color:var(--nf-text); border:1px solid var(--nf-line); border-radius:8px; padding:6px 8px; font:inherit; box-sizing:border-box; }
.schedule { margin:8px 0; padding:10px; border:1px solid var(--nf-line); border-radius:10px; }
summary { cursor:pointer; font-weight:600; }
.nf-check { margin-top:10px; }
.next,.missing { color:var(--nf-muted); font-size:12px; }
.schedule-group { padding:10px 0; border-top:1px solid var(--nf-line); font-size:12px; }
.points { display:flex; gap:6px 14px; flex-wrap:wrap; margin-top:8px; }
.point { display:inline-flex; align-items:center; gap:6px; }
.point time { font-variant-numeric:tabular-nums; }
.dot { width:8px; height:8px; border-radius:50%; }
.error { color:var(--nf-danger,#ff6b7a); font-size:12px; }
`];
}
if (!customElements.get("nf-room-hvac")) customElements.define("nf-room-hvac", NfRoomHvac);
+12 -5
View File
@@ -8,6 +8,8 @@ import { iconPath } from "../icons.ts";
import { openMoreInfo, stateText } from "../markers.ts";
import { pluginRoomSections } from "../plugins/registry.ts";
import { canAnnounce, roomHasSpeaker } from "../live/announce.ts";
import { isSymcon, nativeText } from "../entities/symcon-values.ts";
import "./room-hvac.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";
@@ -451,7 +453,9 @@ export class NfRoomPanel extends LitElement {
: (this.memo = { entities: this.hass.entities, floor: this.floor, room, ...(this.floor ? roomPanelEntities(this.hass, this.floor, room) : { shown: all, more: [] }) });
const extra = groupByDevice(this.hass, more).map((g) => g.primary);
const hiddenCount = extra.length;
const ids = this._showAll ? [...shown, ...extra] : shown;
const hvacRefs = [room.floor_heating, ...Object.values(room.hvac ?? {}).flat()].filter((x): x is string => !!x && x !== "none");
const hvacNative = new Set(hvacRefs.map((id) => this.hass.states[id]?.attributes.symcon_id).filter(Boolean));
const ids = (this._showAll ? [...shown, ...extra] : shown).filter((id) => !isSymcon(this.hass) || !hvacNative.has(this.hass.states[id]?.attributes.symcon_id));
const by = (kinds: DeviceKind[]) => ids.filter((id) => kinds.includes(kindOf(id)!)).map((id) => this.hass.states[id]);
const lights = by(["light"]);
const covers = by(["cover"]);
@@ -480,9 +484,9 @@ export class NfRoomPanel extends LitElement {
<div class="nf-rp-body" ?hidden=${this._folded}>
${this.renderAllOff([...lights, ...media, ...switches])}
${this.renderClean(room)}
${!room.area_id && !outside
${!room.area_id && !outside && !(isSymcon(this.hass) && hvacRefs.length)
? html`<p class="nf-rp-note">${this.t("panel_no_area")}</p>`
: !ids.length
: !ids.length && !(isSymcon(this.hass) && hvacRefs.length)
? html`<p class="nf-rp-note">${this.t("panel_empty")}</p>`
: nothing}
${scenes.length
@@ -531,12 +535,13 @@ export class NfRoomPanel extends LitElement {
: nothing,
)
: nothing}
${isSymcon(this.hass) ? html`<nf-room-hvac .hass=${this.hass} .room=${room}></nf-room-hvac>` : nothing}
${climates.length ? this.section("panel_climate", climates.map((st) => this.climateRow(st))) : nothing}
${media.length ? this.section("panel_media", media.map((st) => this.mediaRow(st))) : nothing}
${switches.length ? this.section("panel_switches", switches.map((st) => this.switchRow(st))) : nothing}
${sensors.length ? this.section("panel_sensors", sensors.map((st) => this.sensorRow(st))) : nothing}
${this.extraValues(room)}
${canAnnounce(this.hass) && roomHasSpeaker(this.hass, this.floor, room) ? this.announceSection(room) : nothing}
${!isSymcon(this.hass) && canAnnounce(this.hass) && roomHasSpeaker(this.hass, this.floor, room) ? this.announceSection(room) : nothing}
${this.pluginSections(room, ids)}
${hiddenCount
? html`<button class="nf-btn nf-rp-small nf-rp-more" @click=${() => (this._showAll = !this._showAll)}>
@@ -621,7 +626,9 @@ export class NfRoomPanel extends LitElement {
if (need && !off.includes("air")) out.push(`💨 ${this.t(`air_${need}`)}`);
// how comfortable it is (0 … 100)
const comfort = comfortScore(t, h, roomClimateValue(this.hass, this.floor, room, "co2"), isSummer(new Date(), this.hass.config?.latitude));
if (comfort !== null && (t !== null || h !== null) && !off.includes("comfort")) out.push(`😊 ${this.t("comfort_n", { n: comfort })}`);
const status = room.hvac?.status;
if (status && status !== "none") out.push(nativeText(this.hass.states[status]));
else if (comfort !== null && (t !== null || h !== null) && !off.includes("comfort")) out.push(`😊 ${this.t("comfort_n", { n: comfort })}`);
return out;
}
@@ -57,7 +57,7 @@ export class SymconObjectPicker extends LitElement {
private variableNode(entity: string | null): SymconObject | undefined {
const source = this.allowed.get(entity ?? "")?.sourceEntity ?? entity;
const native = this.objects.find((node) => node.entity_id === source && node.object_type === 2);
const native = this.objects.find((node) => node.entity_id === source && (node.object_type === 2 || node.object_type === 4));
return native ? this.tree.nodes.get(native.object_id) : undefined;
}
@@ -216,7 +216,7 @@ export class SymconObjectPicker extends LitElement {
${!rows.length ? html`<p class="empty">${this.objects.length ? "Keine Objekte gefunden." : "Kein Objektbaum verfügbar. Bitte das Symcon-Modul aktualisieren und den Designer neu laden."}</p>` : nothing}
</div>
<footer><div class="selection"><strong>${pendingNode?.name ?? pending?.label ?? "Noch kein Datenpunkt ausgewählt"}</strong>
<small>${pendingNode?.path ?? "Nur passende Variablen können ausgewählt werden."}</small></div>
<small>${pendingNode?.path ?? "Nur passende Datenpunkte können ausgewählt werden."}</small></div>
<div class="actions"><button type="button" @click=${this.close}>Abbrechen</button>
<button class="apply" type="button" ?disabled=${this.disabled || !pending} @click=${this.commit}>Übernehmen</button></div>
</footer>
+15 -3
View File
@@ -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;
@@ -82,6 +82,8 @@ export function watchedEntities(inputs: WatchInputs): string[] {
...b.presence.flatMap((p) => [p.person, p.sensor]),
...lightsOfRooms,
...roomsOf(b).map((r) => r.floor_heating),
...roomsOf(b).flatMap((r) => Object.values(r.hvac ?? {}).flat()),
...Object.values(b.settings.weather_variables ?? {}),
...b.floors.flatMap((f) => (f.outdoor ?? []).flatMap((a) => [a.temp_entity, a.pump_entity])),
...sensorsOfRooms,
...(inputs.alertSources ? alertEntities(inputs.alertSources) : []),