En plus de laisser la possibilité de comparer des variables créé précédemment, laisser la possibilité de prendre une valeur instantanée sans devoir à créer une action « get device value »
Demandée ici:
guim31
Novembre 2, 2023, 8:03
2
Je n’avais jamais vu cette demande, et je trouve qu’elle est en fait très importante pour faciliter la création de scènes > donc aider les gens à se projeter dans l’utilisation de Gladys !!
Totalement d’accord avec toi @guim31 , ça participe largement à rendre plus simple la création de scènes quand on a pas encore d’expérience.
guim31
Novembre 2, 2023, 8:06
4
De mon retour d’expérience, je pense que la gestion / création des scènes est l’élément qui m’a demandé le plus de temps d’apprentissage.
Donc je pense que vu la philosophie du projet qui se veut facile d’accès, toute simplification à ce niveau là sera bénéfique !
Hizo
Décembre 29, 2023, 12:45
5
Petit up de cette super demande
Je remonte ça… Pour moi c’est must have !
@guim31 elle se trouve où cette box "continuer seulement si " ?
Si je ne me trompe pas, elle n’existe plus car on a le Si...Alors...Sinon qui la remplace.
@pierre-gilles tu confirmes ?
Et dans l’affirmative on peut fermer ce sujet.
@pierre-gilles je fais remonter cette demande en vue de la semaine prochaine. Simplement à noter que la box ‹ continuer seulement si › est celle qui a été renommée en ‹ condition sur variable ›.
Salut tout le monde !
Ce sujet est désormais en cours de développement .
Une PR a été ouverte pour proposer les valeurs instantanées des appareils dans « Continuer seulement si » :
master ← claude/box-continuer-seulement-si-devu3t
ouvert 06:43PM - 23 Jul 26 UTC
### Pull Request check-list
To ensure your Pull Request can be accepted as fast… as possible, make sure to review and check all of these items:
- [x] If your changes affect the code, did you write the tests?
- [x] Are server tests passing with coverage? (`cd server && npm run coverage`) — Codecov requires **100% coverage on lines changed in this PR** (all scene, MCP and controller test suites pass locally; the new `device_feature` branches in `scene.actions.js` are each covered by a dedicated test)
- [ ] Did Cypress E2E tests pass? (`npm run cypress:run` from repo root, if UI changed) — no existing Cypress coverage for the "Only continue if" box
- [x] Is the linter passing? (`npm run eslint` on both front/server)
- [x] Did you run prettier? (`npm run prettier` on both front/server)
- [x] If you are adding a new feature/service, did you run the integration comparator? (`npm run compare-translations` on front) — only existing keys were modified, in all three languages (fr/en/de)
- [ ] Did you test this pull request in real life? With real devices? — not yet, community testing via the preview Docker image is welcome
- [x] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code) — no REST API change; the MCP scene schema was updated accordingly
- [ ] If you are adding a new features/services which needs explanation, did you modify the user documentation? — the scene documentation on the website should be updated to mention that device values are now available directly in conditions
- [x] Did you add fake requests data for the demo mode (`front/src/config/demo.js`) so that the demo website is working without a backend? (if needed) — the condition select reuses the existing `/api/v1/room?expand=devices` and `/api/v1/device` routes already mocked for the demo
### Description of change
Implements the community feature request [La box "Continuer seulement si" devrait proposer les valeurs instantanées des appareils par défaut](``https://community.gladysassistant.com/t/la-box-continuer-seulement-si-devrait-proposer-les-valeurs-instantanee-des-appareils-par-defaut/6502``) (opened in 2021, bumped several times since).
Until now, the "Only continue if" box only offered scene variables created by previous blocks, so comparing a device's current state required adding a "Get device value" block first — a common stumbling block for newcomers building their first scenes.
**Server** (`scene.actions.js`, `models/scene.js`, MCP `sceneSchemas.js`):
- A condition now accepts a `device_feature` selector as an alternative to a scope `variable`. The feature's instantaneous value is resolved from the state manager at evaluation time (`last_value`, or `last_value_string` for text features, mirroring the front's `DeviceFeatureTypesString` logic).
- If the selector doesn't resolve, the scene aborts with `DEVICE_FEATURE_NOT_FOUND`, consistent with existing `AbortScene` codes.
- The Joi schema enforces exactly one of `variable` / `device_feature` (`xor`), so existing scenes remain valid unchanged. The MCP Zod schema accepts both forms with the same exclusivity rule.
**Front** (`OnlyContinueIfParams.jsx`, `Condition.jsx`, i18n fr/en/de):
- The condition select now lists all device features grouped by room (same data source as `SelectDeviceFeature`), after the scene-variable groups from previous blocks. With no prior "Get device value" block, devices are proposed by default — which is the exact ask of the topic.
- The selection stores `condition.device_feature` or `condition.variable` depending on the chosen option, and re-selects correctly when reopening the scene.
- Label renamed to "Device or variable" and the explanation text updated in all three languages.
Since the "If/Then/Else" box reuses the same component and the same server handler for its `if` conditions, it benefits from this automatically.
**Tests**: 4 new server tests cover the `device_feature` path (numeric condition verified/not verified, text feature, unknown feature). Full scene (232), MCP (92) and scene controller/model (15) suites pass.
## Summary by CodeRabbit
* **New Features**
* Scene conditions can now compare values directly from devices or scene variables.
* Device features are available as selectable, room-organized options in the scene editor.
* Numeric and text device values are supported for condition checks.
* **Bug Fixes**
* Improved validation ensures each condition references exactly one device feature or variable.
* Missing device features now produce a clear condition error.
* Updated English, German, and French guidance for configuring scene conditions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01MqXp8m7ZvLenVXiBuhsqqS
## Summary by CodeRabbit
* **New Features**
* Scene conditions can compare values directly from devices or scene variables.
* Device feature options are available in the condition editor, organized and grouped by room.
* Supports comparisons using current numeric or text device values.
* **Bug Fixes**
* Improved condition validation and handling when selecting devices or variables.
* Clear errors are shown when a referenced device feature is missing or unavailable.
* Device references in nested scene conditions are updated during migrations.
* **Documentation**
* Updated English, German, and French descriptions to explain device and variable comparisons.
N’hésitez pas à suivre la PR, à tester dès que possible et à faire vos retours ici.