diff --git a/ajax/AutoAction.php b/ajax/AutoAction.php
index fcbcf38..39ec23c 100644
--- a/ajax/AutoAction.php
+++ b/ajax/AutoAction.php
@@ -155,11 +155,14 @@ $nutzdaten = json_encode([
+
diff --git a/homeMesh_automations.sql b/homeMesh_automations.sql
index dca92a2..e4d6178 100644
--- a/homeMesh_automations.sql
+++ b/homeMesh_automations.sql
@@ -29,7 +29,7 @@ SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `automations` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL COMMENT 'Anzeigename, z.B. Kinder zu',
- `floor` enum('','UG','EG','OG') NOT NULL DEFAULT '' COMMENT 'Reiter in der Uebersicht',
+ `floor` enum('UG','EG','OG') NOT NULL DEFAULT 'OG' COMMENT 'Reiter in der Uebersicht. Ohne Etage waere die Automatik in keinem davon zu sehen, deshalb gibt es keinen leeren Wert',
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Aktiv oder pausiert',
`window_from` time NOT NULL DEFAULT '00:00:00' COMMENT 'Aktiver Zeitraum, Beginn',
`window_to` time NOT NULL DEFAULT '23:59:00' COMMENT 'Aktiver Zeitraum, Ende. Kleiner als window_from = ueber Mitternacht',
diff --git a/js/solar/autoActionFuncs.js b/js/solar/autoActionFuncs.js
index 81b8523..90acba0 100644
--- a/js/solar/autoActionFuncs.js
+++ b/js/solar/autoActionFuncs.js
@@ -373,7 +373,14 @@ function fuelleFormular() {
optionListe(sperre, autoLockouts.map(o => ({ value: o.value, text: o.label })),
autoModel.lockout_secs);
document.getElementById("autoName").value = autoModel.name;
- document.getElementById("autoFloor").value = autoModel.floor;
+ // Kennt die Liste die Etage nicht, bleibt eine Auswahlliste sonst leer
+ // stehen und schickt beim Speichern "" mit.
+ const etage = document.getElementById("autoFloor");
+ etage.value = autoModel.floor;
+ if (etage.selectedIndex < 0) {
+ etage.selectedIndex = 0;
+ autoModel.floor = etage.value;
+ }
document.getElementById("tSpanFrom").value = autoModel.window_from;
document.getElementById("tSpanTo").value = autoModel.window_to;
document.getElementById("actFerien").checked = autoModel.on_vacation;
diff --git a/restricted/automations.php b/restricted/automations.php
index d8c9f76..4a4171e 100644
--- a/restricted/automations.php
+++ b/restricted/automations.php
@@ -267,7 +267,9 @@ function emptyAutomation($floor)
return [
"id" => 0,
"name" => "",
- "floor" => $floor,
+ // Aufgerufen wird der Editor immer aus einem Etagenreiter. Fehlt die
+ // Angabe trotzdem, gilt dieselbe Etage wie auf der Startseite.
+ "floor" => in_array($floor, ["UG", "EG", "OG"], true) ? $floor : "OG",
"enabled" => true,
"window_from" => "00:00",
"window_to" => "23:59",
@@ -370,8 +372,10 @@ function saveAutomation($data)
throw new InvalidArgumentException("Bitte einen Namen vergeben.");
}
$floor = strval($data["floor"] ?? "");
- if (!in_array($floor, ["", "UG", "EG", "OG"], true)) {
- $floor = "";
+ if (!in_array($floor, ["UG", "EG", "OG"], true)) {
+ // Nicht stillschweigend auf "" zurueckfallen: die Automatik wuerde
+ // dann in keinem der drei Reiter mehr auftauchen.
+ throw new InvalidArgumentException("Bitte eine Etage wählen.");
}
$conditions = is_array($data["conditions"] ?? null) ? $data["conditions"] : [];
$actions = is_array($data["actions"] ?? null) ? $data["actions"] : [];