Diskutiert hier: Associer un bouton +/- au slider de couleur ou luminosité - #16 par lmilcent
Beschreibung
In einer Szene eine Aktion wiederholen, bis ein oder mehrere Kriterien erfüllt sind.
Beispiel
Durch Drücken eines Knopfes die Helligkeit einer Lampe schrittweise erhöhen.
Solange: Aktion = « brightness_move_up » und Helligkeit < 100
Dann:
Helligkeit = Helligkeit + 10
200 ms warten
ich stelle diese Anfrage erneut, denn genau das brauche ich für meine IKEA-Knöpfe
Da es sich um die am häufigsten gewünschte Funktion handelt, habe ich Fable 5 damit gestartet!
Sein Vorschlag:
Docker-Image:
ghcr.io/gladysassistant/gladys-preview:claude-szenen-gesteuerte-schleifen-sceu7j
Der PR:
master ← claude/scenes-controlled-loops-sceu7j
ouvert 09:16AM - 02 Aug 26 UTC
### Description
This PR adds a new "while loop" action (`ACTIONS.CONDITION.WHIL… E`) to the scene automation system, enabling users to repeatedly execute a block of actions as long as specified conditions remain true.
**Key features:**
- Conditions are re-evaluated before each iteration
- Safety limits: default max 1000 iterations, absolute max 10000 (configurable)
- Minimum 100ms per iteration to prevent CPU-intensive tight loops
- Loop aborts if conditions are empty (prevents infinite loops)
- Full error handling and propagation from condition evaluation
**Changes include:**
- Backend action handler in `scene.actions.js` with iteration logic and safety guards
- Frontend UI component (`ConditionWhile.jsx`) with collapsible repeat section and max iterations input
- Comprehensive unit tests covering: normal execution, condition re-evaluation, max iterations limit, empty conditions error, and error handling
- i18n translations for English, French, and German
- Schema validation in MCP and Joi models
- Integration with scene variable tracking and action card rendering
### Checklist
- [x] Tests pass: Added comprehensive unit tests in `scene.action.conditionWhile.test.js` covering all scenarios (5 test cases with 100% coverage of new code)
- [x] Linter and prettier pass on both front and server
- [x] No breaking changes
https://claude.ai/code/session_01EAhGR17j5RnYsLsVU5CdWu
## Summary by CodeRabbit
* **New Features**
* Added a **While** condition action for scenes.
* Configure conditions, repeated actions, and an iteration limit of up to 10,000.
* Conditions are re-evaluated during execution, with repeated actions running sequentially.
* Added English, German, and French translations.
* **Bug Fixes**
* Improved validation and handling of nested While actions.
* Added safeguards against invalid or unbounded loop configurations.
* While loops stop when conditions fail, execution is aborted, or the iteration limit is reached.
* Improved variable availability in conditional branches.
Was haltet ihr davon?
Ich habe den PR nicht angesehen, aber wird der Fall „die Bedingung wird nie erfüllt“ behandelt? Damit es keine Zombie-Szenen gibt
Es gibt eine maximale Anzahl von Iterationen, die vom Benutzer definiert wird (man sieht das übrigens auf dem Screenshot!)
Super, dass du dich an diesem Devt versuchst
Ich würde vorschlagen, den Parameter ‹ Maximale Anzahl der Iterationen › weiter nach oben in der Struktur zu verschieben, damit er nicht zu weit unten steht, falls der Block ‹ Wiederhole › etwas lang ist…
sehr gut: aber ich sehe, dass in den Auslösebedingungen das « ODER » steht, aber es müsste vor allem das « UND » sein (z. B.: Drücken einer Taste UND Helligkeit < 100%)
Um „UND“-Bedingungen zu erstellen, müssen Sie einfach eine Bedingung hinzufügen!
Tatsächlich, ich habe gerade herausgefunden, dass man ETs in den Bedingungen machen kann! Danke
Das sollte man in der Dokumentation klarer angeben!
Sehr gutes Feedback, ich verbessere den Block:
Perfekt: Da ist es wenigstens sehr klar und man kann es nicht übersehen!
Getestet und abgesegnet, die Entwicklung geht in die nächste Version von Gladys
Ich schließe diesen Beitrag, da die Funktion in Gladys Assistant 4.86 verfügbar ist:
Salut à tous !
Super heureux de sortir Gladys Assistant 4.86.
C’est simple, c’est la plus grosse version depuis le début du projet, avec 68 PR fusionnées en une semaine
C’est juste incroyable, et ça montre le nouveau rythme qu’on peut tenir avec l’IA.
L’objectif est maintenant clair : rattraper et dépasser Home Assistant
Je vous parle de ces 68 nouveautés ici :
Merci à tous les contributeurs !!