"Konnte die Anfrage nicht lesen."], 400); } try { switch ($action) { case "save": $id = saveAutomation($body); jsonAntwort(["id" => $id]); case "delete": deleteAutomation(intval($body["id"] ?? 0)); jsonAntwort(["ok" => true]); case "toggle": jsonAntwort(["enabled" => toggleAutomation(intval($body["id"] ?? 0))]); default: jsonAntwort(["error" => "Unbekannte Aktion."], 400); } } catch (InvalidArgumentException $e) { jsonAntwort(["error" => $e->getMessage()], 400); } catch (Throwable $e) { jsonAntwort(["error" => "Speichern fehlgeschlagen: " . $e->getMessage()], 500); } } // --- Uebersichtstabelle -------------------------------------------------- if ($action === "list") { $tage = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"]; $list = listAutomations($floor); if (!$list) { echo "
Für diese Etage ist noch nichts eingerichtet.
"; } else { echo "| Name | Auslöser | " . "Aktion | " . "Wann | " . "Zuletzt | |
|---|---|---|---|---|---|
| " . htmlspecialchars($a["name"]) . " | "; echo "" . htmlspecialchars($a["conditionText"]) . " | "; echo "" . htmlspecialchars($a["actionText"]) . " | "; echo "" . htmlspecialchars($wann) . " | "; echo "" . $zuletzt . " | "; echo "" . " " . " " . "" . " |