En la acción de escena « hablar a un altavoz », el volumen se define de forma fija. Sería útil poder definirlo con una variable recuperada con antelación.
El caso de uso: hacer un anuncio en una escena a un volumen dependiente de la hora del día, para ser más discreto por la tarde y de noche.
Por lo tanto, el campo de volumen de esta acción debería poder definirse con una variable en la forma {{ }}.
Quizás la funcionalidad de la acción ‹ controlar un dispositivo › que permite definir un valor simple o calculado podría ser reutilizada…
¡Hola a todos!
Este tema ahora está en desarrollo .
Se ha abierto una PR para permitir un volumen calculado (a través de una variable) en la acción « Hablar con un altavoz »:
master ← claude/play-notification-volume-variable
ouvert 02:24AM - 25 Aug 26 UTC
Implements feature request: https://community.gladysassistant.com/t/utiliser-une… -variable-comme-volume-pour-parler-a-une-enceinte/10692
### Description
The volume of the "Talk on a speaker" (`music.play-notification`) scene action could only be a fixed number. It can now also be a calculated value based on scene variables, so an announcement can be played quieter in the evening or at night, as requested on the forum.
The volume field gets the same **Simple / Computed** toggle already used by the "Control a device" and "Wait" actions:
- Simple: the existing slider, stored in `volume` (unchanged default behaviour).
- Computed: a text field where scene variables can be injected with `{{ }}`, stored in a new optional `evaluate_volume` field.
Server side, `evaluate_volume` is rendered with Handlebars against the scene scope and evaluated with the scene formula engine (the same restricted mathjs instance used by the other actions). The result is rounded and clamped between 0 and 100, since the speaker services expect a percentage, and the scene is aborted with `ACTION_VALUE_NOT_A_NUMBER` if the formula throws or does not return a finite number, instead of sending `NaN` to a speaker.
Backward compatibility: an action storing a plain numeric `volume` keeps behaving exactly as before, and an action without any volume still lets each speaker service apply its own default.
Changes:
- `server/lib/scene/scene.actions.js`: resolve the volume of the play notification action.
- `server/models/scene.js`: accept the new `evaluate_volume` string field.
- `server/services/mcp/lib/sceneSchemas.js`: same field in the MCP scene schema.
- `front/.../actions/PlayNotification.jsx`: Simple/Computed toggle for the volume.
- `front/.../edit-scene/index.js`: `evaluate_volume` added to the attributes whose variable paths are rewritten when action groups move.
- i18n: new strings in `en`, `fr` and `de`.
- `server/test/lib/scene/actions/scene.action.playNotification.test.js`: tests for the no-volume, fixed-volume, calculated, clamped (both bounds) and invalid formula paths.
This PR was produced by an automated run.
## Forum
Forum: https://community.gladysassistant.com/t/utiliser-une-variable-comme-volume-pour-parler-a-une-enceinte/10692
### Checklist
- [ ] Tests pass: `cd server && npm run coverage` (Codecov requires 100% coverage on changed lines) and Cypress (`npm run cypress:run`) if the UI changed
- [x] Linter and prettier pass on both front and server (`npm run eslint`, `npm run prettier`)
- [x] No undocumented breaking change
What was actually verified in the sandbox: the scene and MCP test suites pass (490 tests), and `c8` reports every changed line of `scene.actions.js` as covered. The full server suite has pre-existing failures unrelated to this change (missing `sqlite3` CLI, network-dependent gateway/AI tests), so the first box is left unticked. Cypress was not run (no browser available), and the new UI was checked with a production front build only, not manually in a browser. `npm run compare-translations` passes.
## Summary by CodeRabbit
- **New Features**
- Added computed volume support for “Play notification” scene actions.
- Choose between a fixed volume or a formula based on scene variables.
- Computed volumes are validated and constrained to the 0–100% range.
- Invalid calculations are rejected to prevent playback with an unusable volume.
- Switching modes preserves the current setting when possible.
- **Documentation**
- Added guidance and translations for the new volume options in English, German, and French.
No duden en seguir la PR, probar (opcional, especialmente para pequeñas solicitudes) y dar sus comentarios aquí si es necesario.