From ae5a23cf39ce602354dbc84b449224ec47ad5ed7 Mon Sep 17 00:00:00 2001 From: 3020772 <3020772@stud.hs-mannheim.de> Date: Tue, 17 Nov 2026 11:15:35 +0100 Subject: [PATCH] =?UTF-8?q?Ambient=C2=B2-Prototyp=20ans=20Backend=20angebu?= =?UTF-8?q?nden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die App-Komponente zeigt nur noch an, was GET /api/zustand liefert, und schickt Stimmen, Vortragsmodus, Jalousie und Demo-Szenario per POST. Design/CSS unveraendert; ergaenzt um Lichtstimme und Verbindungshinweis. Co-Authored-By: Claude Opus 5.5 --- frontend/ambient/index.html | 462 ++++++++++++++++-------------------- 1 file changed, 204 insertions(+), 258 deletions(-) diff --git a/frontend/ambient/index.html b/frontend/ambient/index.html index 067cf0c..5b84065 100644 --- a/frontend/ambient/index.html +++ b/frontend/ambient/index.html @@ -14273,117 +14273,34 @@ function requireClient() { } var clientExports = requireClient(); const ReactDOM = /* @__PURE__ */ getDefaultExportFromCjs(clientExports); -const scenarios = [ - { id: "normal", label: "Normal", description: "Alle Werte im Zielbereich" }, - { id: "co2", label: "CO₂ zu hoch", description: "Gesundheit priorisiert Lüften" }, - { id: "noise", label: "CO₂ + Außenlärm", description: "Frischluft mit Lärmschutz" }, - { id: "storm", label: "Sturm", description: "Fenster werden gesperrt" }, - { id: "presentation", label: "Vortragsmodus", description: "Licht und Jalousien angepasst" }, - { id: "outlier", label: "Ausreißer-Stimme", description: "Mehrheit bleibt ausschlaggebend" } -]; -const states = { - normal: { - co2: 742, - temperature: 22.1, - noise: 41, - wind: 9, - pm: 7, - window: "Geschlossen", - windowOpen: 0, - blinds: 32, - votes: "8 von 10 zufrieden", - banner: "Raumklima im Zielbereich", - detail: "Temperatur und Luftqualität sind stabil.", - tone: "good", - action: "Zielwerte gehalten", - reason: "Raumklima stabil. Keine Anpassung erforderlich." - }, - co2: { - co2: 1268, - temperature: 22.4, - noise: 47, - wind: 11, - pm: 8, - window: "Stoßlüftung", - windowOpen: 78, - blinds: 32, - votes: "7 von 10 zufrieden", - banner: "Frischluftzufuhr hat Vorrang", - detail: "CO₂ liegt über 1.000 ppm. Die Fenster öffnen automatisch.", - tone: "danger", - action: "Stoßlüftung gestartet", - reason: "Luft verbraucht. Gesundheitsschutz erzwingt Frischluft." - }, - noise: { - co2: 1374, - temperature: 22.5, - noise: 86, - wind: 8, - pm: 9, - window: "Gekippt", - windowOpen: 18, - blinds: 32, - votes: "6 von 10 zufrieden", - banner: "Frischluft, trotz hoher Außenlautstärke", - detail: "CO₂ erfordert Lüften. Der Lärmschutz begrenzt die Öffnung.", - tone: "warning", - action: "Fenster kurz gekippt", - reason: "Luft verbraucht. Fenster nur kurz gekippt wegen Lärm." - }, - storm: { - co2: 812, - temperature: 21.8, - noise: 63, - wind: 71, - pm: 12, - window: "Gesperrt", - windowOpen: 0, - blinds: 55, - votes: "8 von 10 zufrieden", - banner: "Fenster wegen Sturm gesperrt", - detail: "Das Kontext-Veto verhindert manuelles und automatisches Öffnen.", - tone: "warning", - action: "Fenster gesichert", - reason: "Sturmschutz aktiv. Fenster bleiben bis zur Entwarnung verriegelt." - }, - presentation: { - co2: 784, - temperature: 22.2, - noise: 39, - wind: 10, - pm: 7, - window: "Geschlossen", - windowOpen: 0, - blinds: 100, - votes: "9 von 10 zufrieden", - banner: "Vortragsmodus aktiv", - detail: "Jalousien geschlossen, Raumautomatik bleibt im Hintergrund aktiv.", - tone: "info", - action: "Vortragsmodus gestartet", - reason: "Vortragsmodus aktiviert. Jalousien für bessere Sicht geschlossen." - }, - outlier: { - co2: 768, - temperature: 22, - noise: 42, - wind: 8, - pm: 7, - window: "Geschlossen", - windowOpen: 0, - blinds: 32, - votes: "9 angenehm · 1 zu warm", - banner: "Mehrheitswunsch wird gehalten", - detail: "Eine einzelne abweichende Stimme verändert den Zielwert nicht.", - tone: "good", - action: "Zielwert 22 °C gehalten", - reason: "Ausreißer erkannt. Die Mehrheit bewertet 22 °C als angenehm." +// ---- Anbindung an das Backend (backend/server.js) ---- +// Alle Werte, Entscheidungen, Stimmen und der Verlauf kommen von GET /api/zustand. +// Die Seite berechnet nichts selbst, sie zeigt an und schickt Eingaben per POST. +const API_BASIS = location.protocol === "file:" ? "http://localhost:3000" : ""; +const ABFRAGE_MS = 1500; +function clientId() { + let id = null; + try { + id = localStorage.getItem("ambient-client"); + if (!id) { + id = Math.random().toString(36).slice(2) + Date.now().toString(36); + localStorage.setItem("ambient-client", id); + } + } catch { + id = id || "tab-" + Math.random().toString(36).slice(2); } -}; -const initialHistory = [ - { time: "10:18", title: "Zielwerte gehalten", reason: "Raumklima stabil. Keine Anpassung erforderlich.", tone: "good" }, - { time: "09:52", title: "Kurz gelüftet", reason: "Kurz gelüftet. Zielwert 22 °C wird wieder angesteuert.", tone: "info" }, - { time: "09:31", title: "Temperaturwunsch begrenzt", reason: "Wunsch liegt außerhalb des zulässigen Bereichs.", tone: "warning" } -]; + return id; +} +const CLIENT = clientId(); +async function apiPost(pfad, daten) { + const antwort = await fetch(API_BASIS + pfad, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(daten) }); + if (!antwort.ok) throw new Error((await antwort.json().catch(() => ({}))).fehler || `HTTP ${antwort.status}`); +} +function zahl(wert, stellen = 0) { + return wert === null || wert === void 0 ? "–" : wert.toLocaleString("de-DE", { minimumFractionDigits: stellen, maximumFractionDigits: stellen }); +} +const VOTE_IDS = { cooler: "kuehler", good: "angenehm", warmer: "waermer" }; +const LICHT_IDS = { darker: "dunkler", ok: "passt", brighter: "heller" }; function Icon({ name, size = 20 }) { const paths = { air: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ @@ -14461,100 +14378,100 @@ function formatCountdown(ms) { const seconds = total % 60; return `${hours > 0 ? `${String(hours).padStart(2, "0")}:` : ""}${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`; } +function Verbindungshinweis({ fehler }) { + return /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "status-banner tone-danger", children: [ + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-symbol", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "info", size: 24 }) }), + /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "status-copy", children: [ + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-title", children: "Backend nicht erreichbar" }), + /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "status-detail", children: [ + "Bitte backend/start_node.bat starten (bzw. node backend/server.js). ", + fehler + ] }) + ] }) + ] }); +} function App() { - const [role, setRole] = reactExports.useState("dozent"); - const [scenario, setScenario] = reactExports.useState("normal"); + const [role, setRole] = reactExports.useState(() => { + try { + return localStorage.getItem("ambient-rolle") || "studierende"; + } catch { + return "studierende"; + } + }); + const [z, setZ] = reactExports.useState(null); + const [offset, setOffset] = reactExports.useState(0); + const [fehler, setFehler] = reactExports.useState(null); const [demoOpen, setDemoOpen] = reactExports.useState(true); - const [duration, setDuration] = reactExports.useState(60); - const [presentationEnd, setPresentationEnd] = reactExports.useState(null); const [now, setNow] = reactExports.useState(/* @__PURE__ */ new Date()); - const [blindPosition, setBlindPosition] = reactExports.useState(32); - const [automationPause, setAutomationPause] = reactExports.useState(null); - const [history, setHistory] = reactExports.useState(initialHistory); - const [userVote, setUserVote] = reactExports.useState(null); - const state = states[scenario]; - const presentationActive = presentationEnd !== null && presentationEnd.getTime() > now.getTime(); - const pauseActive = automationPause !== null && automationPause.getTime() > now.getTime(); - const effectiveBlinds = presentationActive && !pauseActive ? 100 : blindPosition; - const presentationUntil = presentationEnd ? formatTime(presentationEnd) : ""; - const voteCounts = reactExports.useMemo(() => { - const counts = scenario === "outlier" ? { cooler: 0, good: 9, warmer: 0 } : { cooler: 1, good: 7, warmer: 1 }; - if (userVote) counts[userVote] += 1; - return counts; - }, [scenario, userVote]); - const voteTotal = voteCounts.cooler + voteCounts.good + voteCounts.warmer; - reactExports.useEffect(() => { - const timer = window.setInterval(() => setNow(/* @__PURE__ */ new Date()), 1e3); - return () => window.clearInterval(timer); + const laden = reactExports.useCallback(async () => { + try { + const antwort = await fetch(`${API_BASIS}/api/zustand?client=${encodeURIComponent(CLIENT)}`, { cache: "no-store" }); + if (!antwort.ok) throw new Error(`HTTP ${antwort.status}`); + const daten = await antwort.json(); + setOffset(Date.parse(daten.jetzt) - Date.now()); + setZ(daten); + setFehler(null); + } catch (e) { + setFehler(e.message); + } }, []); reactExports.useEffect(() => { - if (presentationEnd && presentationEnd.getTime() <= now.getTime()) { - setPresentationEnd(null); - setBlindPosition(32); - if (scenario === "presentation") setScenario("normal"); - setHistory((items) => [{ - time: formatTime(now), - title: "Vortragsmodus beendet", - reason: "Die eingestellte Dauer ist abgelaufen. Die reguläre Raumautomatik übernimmt.", - tone: "info" - }, ...items].slice(0, 6)); - } - }, [now, presentationEnd, scenario]); - const priority = reactExports.useMemo(() => { - if (state.co2 > 1e3) return { number: 1, label: "Gesundheit", icon: "air" }; - if (scenario === "storm") return { number: 2, label: "Kontext-Veto", icon: "shield" }; - if (scenario === "outlier") return { number: 3, label: "Mehrheit", icon: "people" }; - return { number: 4, label: "Energie", icon: "energy" }; - }, [scenario, state.co2]); - const chooseScenario = (id) => { - const next = states[id]; - setScenario(id); - setBlindPosition(next.blinds); - if (id === "presentation") { - const end = new Date(Date.now() + duration * 6e4); - setPresentationEnd(end); - } else { - setPresentationEnd(null); - } - setAutomationPause(null); - setUserVote(null); - setHistory((items) => [ - { time: formatTime(/* @__PURE__ */ new Date()), title: next.action, reason: next.reason, tone: next.tone }, - ...items - ].slice(0, 6)); - }; - const togglePresentation = () => { - if (presentationActive) { - setPresentationEnd(null); - setBlindPosition(32); - setHistory((items) => [{ time: formatTime(/* @__PURE__ */ new Date()), title: "Vortragsmodus beendet", reason: "Die reguläre Raumautomatik ist wieder aktiv.", tone: "info" }, ...items].slice(0, 6)); - } else { - const end = new Date(Date.now() + duration * 6e4); - setPresentationEnd(end); - setBlindPosition(100); - setHistory((items) => [{ time: formatTime(/* @__PURE__ */ new Date()), title: "Vortragsmodus gestartet", reason: `Jalousien bis ${formatTime(end)} geschlossen. Schutzregeln bleiben aktiv.`, tone: "info" }, ...items].slice(0, 6)); - } - }; - const changeDuration = (minutes) => { - setDuration(minutes); - if (presentationActive) { - setPresentationEnd(new Date(Date.now() + minutes * 6e4)); - } - }; - const moveBlinds = (position) => { - const pauseEnd = new Date(Date.now() + 30 * 6e4); - setBlindPosition(position); - setAutomationPause(pauseEnd); - setHistory((items) => [{ - time: formatTime(/* @__PURE__ */ new Date()), - title: position === 100 ? "Jalousien manuell geschlossen" : "Jalousien manuell geöffnet", - reason: `Automatik für 30 Minuten pausiert, bis ${formatTime(pauseEnd)}.`, - tone: "warning" - }, ...items].slice(0, 6)); - }; + laden(); + const abfrage = window.setInterval(laden, ABFRAGE_MS); + const uhr = window.setInterval(() => setNow(/* @__PURE__ */ new Date()), 1e3); + return () => { + window.clearInterval(abfrage); + window.clearInterval(uhr); + }; + }, [laden]); + const senden = (pfad, daten) => apiPost(pfad, daten).then(laden).catch((e) => setFehler(e.message)); + if (!z) { + return /* @__PURE__ */ jsxRuntimeExports.jsx("main", { className: "app-shell", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "page", children: fehler ? /* @__PURE__ */ jsxRuntimeExports.jsx(Verbindungshinweis, { fehler }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "subtitle", children: "Verbinde mit dem Backend …" }) }) }); + } + const d = z.entscheidung; + const w = z.werte; + const g = z.grenzwerte; + const co2 = w.eco2.wert; + const temperature = w.temperatur.wert; + const noise = w.laerm.wert; + const wind = w.wind.wert; + const ziel = d.zielTemperatur; + const co2High = co2 !== null && co2 > g.co2Ppm; + const serverNow = now.getTime() + offset; + const presentationActive = z.vortrag.aktiv; + const presentationEnd = presentationActive ? new Date(Date.parse(z.vortrag.ende) - offset) : null; + const presentationUntil = presentationEnd ? formatTime(presentationEnd) : ""; + const restMs = presentationActive ? Date.parse(z.vortrag.ende) - serverNow : 0; + const pauseUntil = z.jalousiePause ? new Date(Date.parse(z.jalousiePause.bis) - offset) : null; + const effectiveBlinds = d.jalousie; + const duration = z.vortrag.dauerMinuten; + const priority = d.prioritaet; + const tone = d.status.ton; + const statusTitle = d.status.titel === "Vortragsmodus aktiv" && presentationActive ? `Vortragsmodus aktiv bis ${presentationUntil}` : d.status.titel; + const t = z.stimmen.temperatur; + const voteCounts = { cooler: t.kuehler, good: t.angenehm, warmer: t.waermer }; + const voteTotal = voteCounts.cooler + voteCounts.good + voteCounts.warmer; + const userVote = Object.keys(VOTE_IDS).find((k) => z.stimmen.eigene && VOTE_IDS[k] === z.stimmen.eigene.temperatur) || null; + const l = z.stimmen.licht; + const lightCounts = { darker: l.dunkler, ok: l.passt, brighter: l.heller }; + const userLight = Object.keys(LICHT_IDS).find((k) => z.stimmen.eigene && LICHT_IDS[k] === z.stimmen.eigene.licht) || null; + const tempInTarget = temperature !== null && Math.abs(temperature - ziel) <= 1; + const tempState = temperature === null ? "Keine Daten" : tempInTarget ? "Im Ziel" : temperature > ziel ? "Zu warm" : "Zu kalt"; + const windowOpen = d.fenster.oeffnung; + const windowText = d.fenster.text + (d.lueftung > 0 ? " · Lüftung an" : "") + (d.heizung > 0 ? " · Heizung an" : ""); + const letzterMesswert = z.letzterMesswert ? formatTime(new Date(z.letzterMesswert.zeit)) : null; + const vote = (id) => senden("/api/stimme", { client: CLIENT, rolle: role, temperatur: VOTE_IDS[id] }); + const voteLight = (id) => senden("/api/stimme", { client: CLIENT, rolle: role, licht: LICHT_IDS[id] }); + const chooseScenario = (id) => senden("/api/szenario", { id }); + const togglePresentation = () => senden("/api/vortragsmodus", { rolle: role, aktiv: !presentationActive }); + const changeDuration = (minutes) => senden("/api/vortragsmodus", { rolle: role, dauerMinuten: minutes }); + const moveBlinds = (position) => senden("/api/jalousie", { rolle: role, position }); const chooseRole = (nextRole) => { setRole(nextRole); - setUserVote(null); + try { + localStorage.setItem("ambient-rolle", nextRole); + } catch { + } }; return /* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "app-shell", children: [ /* @__PURE__ */ jsxRuntimeExports.jsxs("header", { className: "topbar", children: [ @@ -14571,10 +14488,11 @@ function App() { ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "live-status", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "live-dot" }), - " System aktiv" + fehler ? " Verbindung unterbrochen" : z.sensorOnline ? " Sensor live" : " Sensor offline" ] }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "page", children: [ + fehler && /* @__PURE__ */ jsxRuntimeExports.jsx(Verbindungshinweis, { fehler }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "page-heading", children: [ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "eyebrow", children: "Seminarraum 2.14" }), @@ -14588,14 +14506,17 @@ function App() { /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "outside-chip", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "temperature" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: "14 °C" }), + /* @__PURE__ */ jsxRuntimeExports.jsxs("b", { children: [ + zahl(w.aussenTemperatur.wert), + " °C" + ] }), " außen" ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "divider" }), /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "wind" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ /* @__PURE__ */ jsxRuntimeExports.jsxs("b", { children: [ - state.wind, + zahl(wind), " km/h" ] }), " Wind" @@ -14615,21 +14536,21 @@ function App() { /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "countdown-small", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "clock", size: 16 }), " ", - formatCountdown(presentationEnd.getTime() - now.getTime()) + formatCountdown(restMs) ] }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: `status-banner tone-${state.tone}`, children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-symbol", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: state.tone === "good" ? "check" : state.tone === "info" ? "presentation" : "info", size: 24 }) }), + /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: `status-banner tone-${tone}`, children: [ + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-symbol", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: tone === "good" ? "check" : tone === "info" ? "presentation" : "info", size: 24 }) }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "status-copy", children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-title", children: presentationActive && state.co2 <= 1e3 && scenario !== "storm" ? `Vortragsmodus aktiv bis ${presentationUntil}` : state.banner }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-detail", children: state.detail }) + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-title", children: statusTitle }), + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-detail", children: d.status.detail }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "priority-chip", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: priority.icon, size: 16 }), " Priorität ", - priority.number, + priority.nummer, ": ", - priority.label + priority.text ] }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "content-grid", children: [ @@ -14642,22 +14563,26 @@ function App() { ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "updated", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "live-dot" }), - " Jetzt aktualisiert" + fehler ? " Keine Verbindung" : " Jetzt aktualisiert" ] }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "room-visual", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "room-wall", children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ceiling-light one" }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ceiling-light two" }), + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ceiling-light one", style: { opacity: 0.35 + 0.65 * d.licht } }), + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ceiling-light two", style: { opacity: 0.35 + 0.65 * d.licht } }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "screen", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "screen-title", children: "RAUM 2.14" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "screen-temp", children: [ - state.temperature.toFixed(1).replace(".", ","), + zahl(temperature, 1), "°" ] }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "screen-note", children: "Zielwert 22 °C" }) + /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "screen-note", children: [ + "Zielwert ", + zahl(ziel, ziel % 1 ? 1 : 0), + " °C" + ] }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "window-unit left-window", children: [ - /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `window-panel open-${state.windowOpen > 0 ? "yes" : "no"}`, children: [ + /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `window-panel open-${windowOpen > 0 ? "yes" : "no"}`, children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}), /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}), /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}) @@ -14665,14 +14590,14 @@ function App() { /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "blind-overlay", style: { height: `${effectiveBlinds}%` } }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "window-unit right-window", children: [ - /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `window-panel open-${state.windowOpen > 0 ? "yes" : "no"}`, children: [ + /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `window-panel open-${windowOpen > 0 ? "yes" : "no"}`, children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}), /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}), /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}) ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "blind-overlay", style: { height: `${effectiveBlinds}%` } }) ] }), - state.windowOpen > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "airflow", children: [ + windowOpen > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "airflow", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "→" }), /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "→" }), /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "→" }) @@ -14692,9 +14617,9 @@ function App() { ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "teacher-desk" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "room-label window-label", children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: state.window === "Gesperrt" ? "lock" : "air", size: 15 }), + /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: d.fenster.gesperrt ? "lock" : "air", size: 15 }), " Fenster: ", - state.window + windowText ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "room-label blind-label", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "blinds", size: 15 }), @@ -14705,69 +14630,77 @@ function App() { ] }) }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "measure-grid", children: [ - /* @__PURE__ */ jsxRuntimeExports.jsxs("article", { className: `metric-card ${state.co2 > 1e3 ? "metric-alert" : ""}`, children: [ + /* @__PURE__ */ jsxRuntimeExports.jsxs("article", { className: `metric-card ${co2High ? "metric-alert" : ""}`, children: [ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-top", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "air" }) }), - /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-state", children: state.co2 > 1e3 ? "Zu hoch" : "Gut" }) + /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-state", children: co2 === null ? "Keine Daten" : co2High ? "Zu hoch" : "Gut" }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-label", children: "Luftqualität" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-value", children: [ - state.co2.toLocaleString("de-DE"), + zahl(co2), " ", /* @__PURE__ */ jsxRuntimeExports.jsx("small", { children: "ppm" }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-bar", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { style: { width: `${Math.min(100, state.co2 / 15)}%` } }) }), + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-bar", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { style: { width: `${Math.min(100, (co2 || 0) / 15)}%` } }) }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-foot", children: [ - "Grenzwert 1.000 ppm ", + "Grenzwert ", + zahl(g.co2Ppm), + " ppm ", /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "lock", size: 13 }) ] }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("article", { className: "metric-card", children: [ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-top", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "temperature" }) }), - /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-state", children: "Im Ziel" }) + /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-state", children: tempState }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-label", children: "Temperatur" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-value", children: [ - state.temperature.toFixed(1).replace(".", ","), + zahl(temperature, 1), " ", /* @__PURE__ */ jsxRuntimeExports.jsx("small", { children: "°C" }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-bar neutral", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { style: { width: "61%" } }) }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-foot", children: "Zielbereich 21–23 °C" }) + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-bar neutral", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { style: { width: `${temperature === null ? 0 : Math.min(100, Math.max(0, (temperature - 15) / 15 * 100))}%` } }) }), + /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-foot", children: [ + "Zielbereich ", + zahl(ziel - 1, ziel % 1 ? 1 : 0), + "–", + zahl(ziel + 1, ziel % 1 ? 1 : 0), + " °C" + ] }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsxs("article", { className: `metric-card ${state.noise > 75 ? "metric-warning" : ""}`, children: [ + /* @__PURE__ */ jsxRuntimeExports.jsxs("article", { className: `metric-card ${d.vetos.laerm ? "metric-warning" : ""}`, children: [ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-top", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "volume" }) }), - /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-state", children: state.noise > 75 ? "Außen laut" : "Ruhig" }) + /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-state", children: noise === null ? "Keine Daten" : d.vetos.laerm ? "Außen laut" : "Ruhig" }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-label", children: "Außenlärm" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-value", children: [ - state.noise, + zahl(noise), " ", /* @__PURE__ */ jsxRuntimeExports.jsx("small", { children: "dB" }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-bar", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { style: { width: `${state.noise}%` } }) }), + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-bar", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { style: { width: `${Math.min(100, noise || 0)}%` } }) }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-foot", children: [ - "Öffnung wird ggf. begrenzt ", + `Ab ${g.laermDb} dB nur gekippt `, /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "shield", size: 13 }) ] }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsxs("article", { className: `metric-card ${state.wind > 60 ? "metric-warning" : ""}`, children: [ + /* @__PURE__ */ jsxRuntimeExports.jsxs("article", { className: `metric-card ${d.vetos.wind ? "metric-warning" : ""}`, children: [ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-top", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "wind" }) }), - /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-state", children: state.wind > 60 ? "Sturm" : "Leicht" }) + /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "metric-state", children: wind === null ? "Keine Daten" : d.vetos.wind ? "Sturm" : "Leicht" }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-label", children: "Wind" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-value", children: [ - state.wind, + zahl(wind), " ", /* @__PURE__ */ jsxRuntimeExports.jsx("small", { children: "km/h" }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-bar", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { style: { width: `${Math.min(100, state.wind)}%` } }) }), + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "metric-bar", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { style: { width: `${Math.min(100, wind || 0)}%` } }) }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "metric-foot", children: [ "Feinstaub ", - state.pm, + zahl(w.feinstaub.wert), " µg/m³" ] }) ] }) @@ -14795,7 +14728,7 @@ function App() { /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "countdown-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "clock" }) }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Verbleibende Zeit" }), - /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: formatCountdown(presentationEnd.getTime() - now.getTime()) }) + /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: formatCountdown(restMs) }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "until", children: [ "bis ", @@ -14812,10 +14745,10 @@ function App() { /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "icon-button", onClick: () => moveBlinds(100), title: "Jalousien schließen", children: "↓" }) ] }) ] }), - pauseActive && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pause-note", children: [ + pauseUntil && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pause-note", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "clock", size: 15 }), " Automatik pausiert bis ", - formatTime(automationPause) + formatTime(pauseUntil) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "guard-note", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "shield", size: 17 }), @@ -14839,7 +14772,7 @@ function App() { ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "vote-question", children: "Wie fühlt sich der Raum für dich an?" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vote-actions", "aria-label": "Raumtemperatur bewerten", children: [ - /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { className: `vote-button cooler ${userVote === "cooler" ? "active" : ""}`, onClick: () => setUserVote("cooler"), children: [ + /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { className: `vote-button cooler ${userVote === "cooler" ? "active" : ""}`, onClick: () => vote("cooler"), children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "vote-arrow", children: "↓" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: "Kühler" }), @@ -14847,7 +14780,7 @@ function App() { ] }), userVote === "cooler" && /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "check", size: 14 }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { className: `vote-button pleasant ${userVote === "good" ? "active" : ""}`, onClick: () => setUserVote("good"), children: [ + /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { className: `vote-button pleasant ${userVote === "good" ? "active" : ""}`, onClick: () => vote("good"), children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "vote-face", children: "—" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: "Angenehm" }), @@ -14855,7 +14788,7 @@ function App() { ] }), userVote === "good" && /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "check", size: 14 }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { className: `vote-button warmer ${userVote === "warmer" ? "active" : ""}`, onClick: () => setUserVote("warmer"), children: [ + /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { className: `vote-button warmer ${userVote === "warmer" ? "active" : ""}`, onClick: () => vote("warmer"), children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "vote-arrow", children: "↑" }), /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: "Wärmer" }), @@ -14869,9 +14802,9 @@ function App() { " Deine Stimme wurde berücksichtigt." ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vote-bar", children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "cold", style: { width: `${voteCounts.cooler / voteTotal * 100}%` } }), - /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "good", style: { width: `${voteCounts.good / voteTotal * 100}%` } }), - /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "warm", style: { width: `${voteCounts.warmer / voteTotal * 100}%` } }) + /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "cold", style: { width: `${voteTotal ? voteCounts.cooler / voteTotal * 100 : 0}%` } }), + /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "good", style: { width: `${voteTotal ? voteCounts.good / voteTotal * 100 : 0}%` } }), + /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "warm", style: { width: `${voteTotal ? voteCounts.warmer / voteTotal * 100 : 0}%` } }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vote-labels", children: [ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ @@ -14887,6 +14820,19 @@ function App() { voteCounts.warmer ] }) ] }), + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "vote-question", children: "Und das Licht?" }), + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "vote-actions", "aria-label": "Licht bewerten", children: [ + ["darker", "cooler", "↓", "Dunkler"], + ["ok", "pleasant", "—", "Passt"], + ["brighter", "warmer", "↑", "Heller"] + ].map(([id, farbe, zeichen, text]) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { className: `vote-button ${farbe} ${userLight === id ? "active" : ""}`, onClick: () => voteLight(id), children: [ + /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: id === "ok" ? "vote-face" : "vote-arrow", children: zeichen }), + /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ + /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: text }), + /* @__PURE__ */ jsxRuntimeExports.jsx("small", { children: lightCounts[id] }) + ] }), + userLight === id && /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "check", size: 14 }) + ] }, id)) }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "fairness-note", children: [ /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "info", size: 16 }), " Die Stimme des Dozenten zählt wie jede andere." @@ -14900,16 +14846,16 @@ function App() { ] }), /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "history" }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "timeline", children: history.slice(0, 4).map((entry, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "timeline-row", children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `timeline-dot ${entry.tone}` }), + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "timeline", children: z.verlauf.slice(0, 4).map((entry, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "timeline-row", children: [ + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `timeline-dot ${entry.ton}` }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "timeline-content", children: [ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: entry.title }), - /* @__PURE__ */ jsxRuntimeExports.jsx("time", { children: entry.time }) + /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: entry.titel }), + /* @__PURE__ */ jsxRuntimeExports.jsx("time", { children: entry.uhrzeit }) ] }), - /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: entry.reason }) + /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: entry.grund }) ] }) - ] }, `${entry.time}-${entry.title}-${index}`)) }) + ] }, `${entry.zeit}-${entry.titel}-${index}`)) }) ] }) ] }) ] }), @@ -14919,20 +14865,20 @@ function App() { /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "demo-spark", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "spark", size: 17 }) }), /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: "Demo-Szenarien" }), - /* @__PURE__ */ jsxRuntimeExports.jsx("small", { children: "Systemreaktionen direkt simulieren" }) + /* @__PURE__ */ jsxRuntimeExports.jsx("small", { children: "Werte im Backend überschreiben – gilt auch für den Unity-Zwilling" }) ] }) ] }), /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "demo-current", children: [ "Aktiv: ", - scenarios.find((item) => item.id === scenario)?.label + z.szenarien.find((item) => item.id === z.szenario)?.text ] }), /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `chevron ${demoOpen ? "up" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "chevron" }) }) ] }), - demoOpen && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "scenario-grid", children: scenarios.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { className: `scenario-button ${scenario === item.id ? "active" : ""}`, onClick: () => chooseScenario(item.id), children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "scenario-check", children: scenario === item.id && /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "check", size: 14 }) }), + demoOpen && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "scenario-grid", children: z.szenarien.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { className: `scenario-button ${z.szenario === item.id ? "active" : ""}`, onClick: () => chooseScenario(item.id), children: [ + /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "scenario-check", children: z.szenario === item.id && /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "check", size: 14 }) }), /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ - /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: item.label }), - /* @__PURE__ */ jsxRuntimeExports.jsx("small", { children: item.description }) + /* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: item.text }), + /* @__PURE__ */ jsxRuntimeExports.jsx("small", { children: item.beschreibung }) ] }) ] }, item.id)) }) ] }), @@ -14941,7 +14887,7 @@ function App() { /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "shield", size: 15 }), " Automatische Steuerung nach Gesundheit, Kontext, Mehrheit und Energie" ] }), - /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Letzte Sensorkalibrierung: heute, 07:30" }) + /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: letzterMesswert ? `Letzter Sensor-Messwert: ${letzterMesswert}` : "Noch kein Sensor-Messwert empfangen" }) ] }) ] }) ] });