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

+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;
}