"Konnte die Anfrage nicht lesen."], 400); } try { if (($_GET["action"] ?? "") === "command") { $text = executeCommand(intval($body["command_id"] ?? 0), is_array($body["params"] ?? null) ? $body["params"] : [], !empty($body["probe"])); raumAntwort(["ok" => $text]); } if (($_GET["action"] ?? "") === "temp") { // Bewusst derselbe Weg wie im alten Thermostat-Modal: das Topic // Raumtemp///changeSetTemp. $raum = preg_replace('/[^A-Za-z0-9_]/', '', strval($body["room"] ?? "")); $temp = intval($body["temp"] ?? 0); if ($temp < 10 || $temp > 30) { raumAntwort(["error" => "Temperatur außerhalb 10–30 °C."], 400); } $mqtt = new Bluerhinos\phpMQTT(MQTT_BROKER, MQTT_PORT, "RoomTempSetter_" . getmypid()); if (!$mqtt->connect(true, null, "", "")) { raumAntwort(["error" => "Keine Verbindung zum MQTT-Broker."], 500); } $mqtt->publish("Raumtemp/" . str_replace("_", "/", $raum) . "/changeSetTemp", strval($temp), 0, false); $mqtt->close(); raumAntwort(["ok" => "Solltemperatur " . $temp . " °C"]); } raumAntwort(["error" => "Unbekannte Aktion."], 400); } catch (InvalidArgumentException $e) { raumAntwort(["error" => $e->getMessage()], 400); } catch (Throwable $e) { raumAntwort(["error" => $e->getMessage()], 500); } } // --- Inhalt des Modals ---------------------------------------------------- $schluessel = preg_replace('/[^A-Za-z0-9_]/', '', strval($_GET["room"] ?? "")); $teile = explode("_", $schluessel, 2); $etage = $teile[0] ?? ""; $name = $teile[1] ?? ""; $raumKey = $etage . "/" . $name; // Hat der Raum ein Thermostat? Nur dann gibt es etwas zu heizen. $hatThermostat = false; foreach (allRooms() as $raum) { if ($raum["floor"] === $etage && $raum["mqtt"] === $name) { $hatThermostat = isset($raum["x"]); // Kachel = Thermostat vorhanden } } // Alles im Raum, sortiert nach Bedienform. Das Thermostat selbst faellt // heraus: es wird oben zum Schieberegler und braucht daneben keine zweite // Bedienung - "Solltemperatur" stand vorher zweimal im Modal. $katalog = deviceCatalog(); $gruppen = []; foreach ($katalog as $d) { if ($d["room"] !== $raumKey) { continue; } $form = bedienform($d); if ($form === "heizung") { continue; } $gruppen[$form][] = $d; } echo "
"; if ($hatThermostat) { echo "
"; echo "
"; echo ""; echo ""; echo "
"; echo ""; // Der Ist-Zustand kommt live ueber MQTT, nicht aus der Datenbank - der // Browser hoert ohnehin schon auf Raumtemp/#, und ein Wert von vorhin // waere neben dem Regler nur irrefuehrend. echo "
"; echo " °C"; echo " %rF"; echo "heizt"; echo "
"; echo "
"; } if (!$gruppen && !$hatThermostat) { echo "

Diesem Raum ist noch nichts zugeordnet. " . "Das geht über das Haus-Symbol in der Karte „Automatismen“.

"; } foreach (raumGruppenTitel() as $form => $titel) { if (empty($gruppen[$form])) { continue; } // Eine einzelne Lampe braucht keine Ueberschrift "Licht" - der Name der // Lampe steht direkt darunter. Ueberschriften ordnen erst ab zwei. if (count($gruppen[$form]) > 1) { echo gruppenTitel($titel[0], $titel[1]); } foreach ($gruppen[$form] as $d) { echo zeichneGeraet($d, $form); } } echo "
"; echo "
";