Schalter „Alle Kategorien“: automatischer Wechsel durch alle Effekte
Neues Feld allCategories in /api/state (nach dem Einschalten false), in der App ein zweiter Schalter unter „Automatisch wechseln“. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e5e424a7a6
commit
f8360c31f6
9 files changed
+39
-10
No files matched your search
@@ -42,6 +42,7 @@ void sendState() {
|
||||
JsonDocument doc;
|
||||
doc["effect"] = effectId(currentEffect());
|
||||
doc["auto"] = autoAdvance;
|
||||
doc["allCategories"] = autoAll;
|
||||
doc["brightness"] = brightness;
|
||||
sendJson(200, doc);
|
||||
}
|
||||
@@ -81,7 +82,7 @@ void updateState() {
|
||||
if (deserializeJson(body, server.arg("plain")) || !body.is<JsonObject>())
|
||||
return sendError(400, "JSON-Objekt erwartet");
|
||||
|
||||
JsonVariant effect = body["effect"], autoOn = body["auto"], level = body["brightness"];
|
||||
JsonVariant effect = body["effect"], autoOn = body["auto"], all = body["allCategories"], level = body["brightness"];
|
||||
int index = -1;
|
||||
if (!effect.isNull()) {
|
||||
if (!effect.is<const char *>()) return sendError(400, "effect muss eine Effekt-id sein, siehe /api/effects");
|
||||
@@ -89,11 +90,13 @@ void updateState() {
|
||||
if (index < 0) return sendError(400, "unbekannter Effekt, siehe /api/effects");
|
||||
}
|
||||
if (!autoOn.isNull() && !autoOn.is<bool>()) return sendError(400, "auto muss true oder false sein");
|
||||
if (!all.isNull() && !all.is<bool>()) return sendError(400, "allCategories muss true oder false sein");
|
||||
if (!level.isNull() && !(level.is<int>() && level.as<int>() >= 0 && level.as<int>() <= 255))
|
||||
return sendError(400, "brightness muss eine ganze Zahl von 0 bis 255 sein");
|
||||
|
||||
if (index >= 0) selectEffect(index);
|
||||
if (!autoOn.isNull()) autoAdvance = autoOn.as<bool>();
|
||||
if (!all.isNull()) autoAll = all.as<bool>();
|
||||
if (!level.isNull()) setBaseBrightness(level.as<int>());
|
||||
sendState();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user