Als Benutzer,
Möchte ich wissen, welches Gerät/ welche Bedingung eine Szene auslöst,
Damit ich es in anderen Aktionen verwenden kann
Beispiel:
Ich habe eine Szene „Tür öffnen“ (mit dem Tag „Alarmanlage“ ) und wenn eine Tür geöffnet wird, erhalte ich den Status aller Türen und sende eine Nachricht, die mir sagt, „Schau dir den Status der Türen an“.
Was ich gerne hätte, wäre einfach zu wissen, welche Tür die Szene direkt auslöst (das ist weniger umständlich, als alles abzurufen, etc.).
Was haltet ihr davon?
Ich stimme dir zu, aber mit etwas globalerer Betrachtung.
Meine Einbruchserkennungsszene zu Hause wartet darauf, dass eine Tür, ein Fenster oder ein Bewegungssensor ausgelöst wird und mir dann eine Nachricht schickt.
Allerdings ist die Nachricht eine Liste aller Geräte mit ihrem Wert (0 oder 1). Das ist nicht besonders benutzerfreundlich.
Am besten wäre es, im Nachricht « geöffnet / geschlossen » anzuzeigen. Und eine Standardvariable mit den Daten des die Szene auslösenden Geräts hinzuzufügen?
Ich denke, das ist eine separate Anfrage
Die Türen waren für mich nur ein Beispiel ^^
Im Großen und Ganzen möchte ich, wenn eine Szene ausgelöst wird, identifizieren, wer die Szene ausgelöst hat.
Stell dir vor,
ich habe eine Szene, die den Zustand meiner Reifen überprüft. Wenn die Szene ausgelöst wird, wird die Variable „deviceTrigger“ mit dem Reifen instanziiert, der die Szene ausgelöst hat, und dann sende ich eine Nachricht mit „{{ deviceTrigger ist zu wechseln}}"
Das ist die Funktionsweise, die ich vorschlage
Ich denke, du möchtest eine Zuordnung 0 geschlossen 1 offen für die Öffnungssensoren?
spenceur:
Wenn die Szene ausgelöst wird, wird die Variable « deviceTrigger » mit dem Gerät instanziiert, das die Szene ausgelöst hat, und dann sende ich eine Nachricht mit « {{ deviceTrigger ist zu ändern »
Ich schlage dasselbe vor wie du, denke ich.
Aber tatsächlich habe ich auch die umgekehrte Zuordnung vorgeschlagen, um von 0/1 zu „offen / geschlossen“ zu wechseln.
Da habe ich es nicht verstanden ^^
Hallo,
Ich habe für die Integration dieser Funktion gestimmt
Ich gebe ein Beispiel
Ich erstelle eine Szene mit allen meinen Temperatursensoren als Auslöser, wenn ein bestimmter Schwellenwert überschritten wird.
Wenn dieser Schwellenwert überschritten wird, wird eine Nachricht mit der Information des Szenenauslösers sowie der diesem Auslöser zugeordneten Temperatur gesendet.
Ich kann die Temperaturinformation mit „Letzten Zustand abrufen“ abrufen, aber ich kann nicht die Information darüber erhalten, was die Szene ausgelöst hat
Ich hoffe, diese Funktion kommt bald in Gladys
Ich bringe diesen Punkt nochmal zur Sprache
@prohand willst du dich drauf stürzen?
Du wartest schon zwei Jahre darauf ahah
Entschuldigung, ich habe den Status hier nicht synchronisiert, aber es ist bereits entwickelt:
master ← claude/gladys-feature-request-clny6j
ouvert 07:14PM - 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** (full scene test suite passing locally: 229 tests, all branches of the new code are exercised)
- [ ] Did Cypress E2E tests pass? (`npm run cypress:run` from repo root, if UI changed)
- [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)
- [ ] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community ([forum](https://community.gladysassistant.com/)) for testing before merging. An AMD64 preview image is built automatically for non-draft PRs; for ARM64, comment `/build-arm64` on the PR.
- [ ] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
- [ ] If you are adding a new features/services which needs explanation, did you modify the user documentation? See [the GitHub repo](https://github.com/GladysAssistant/v4-website) and the [website](https://gladysassistant.com).
- [ ] 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) See [https://demo.gladysassistant.com](https://demo.gladysassistant.com).
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
### Description of change
Implements the community feature request [Avoir la possibilité de récupérer qui a déclenché la scène](https://community.gladysassistant.com/t/avoir-la-possibilite-de-recuperer-qui-a-declencher-la-scene/8534).
When a scene is triggered by a device state change (`device.new-state`), scene actions can now use variables identifying the trigger in their texts (send message, SMS, HTTP request, MQTT, ask AI…):
- `{{triggerEvent.device.name}}` — name of the device that triggered the scene
- `{{triggerEvent.deviceFeature.name}}` — name of the device feature
- `{{triggerEvent.last_value}}` — the new value
- `{{triggerEvent.previous_value}}` — the previous value
Example: a single scene with several door sensors as triggers can now send "{{triggerEvent.device.name}} was just opened" instead of requiring one scene per door.
**Server** (`server/lib/scene/scene.checkTrigger.js`): when a `device.new-state` trigger fires, the trigger event injected into the scene scope is enriched with the related device & device feature (name + selector), looked up in RAM through the `stateManager` (no DB query, computed once per event). If the feature is not found in RAM, the event is passed through unchanged.
**Front** (`DeviceFeatureState.jsx`, `TriggerCard.jsx`): the device state trigger now exposes these variables in the scene editor variable picker, following the exact same pattern as the calendar trigger (`setVariablesTrigger`). They automatically appear in every action input using `TextWithVariablesInjected`.
**Translations**: added in English, French and German (`compare-translations` passing).
**Tests**: new end-to-end server test verifying that a scene triggered by a device state change renders the enriched variables in a sent message (`Garage door (Door state) = 1`).
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QB1TD1R94bgsRT8qjnM2mv
---
_Generated by [Claude Code](https://claude.ai/code/session_01QB1TD1R94bgsRT8qjnM2mv)_
## Summary by CodeRabbit
* **New Features**
* Added scene variables for the triggering device, feature, current value, and previous value in device state-change actions.
* Added translated labels for these variables in English, French, and German.
* Device state-change variables are displayed consistently without duplicate trigger numbering.
* **Bug Fixes**
* Device state-change events now include relevant device and feature details when scenes run.
* Improved handling when device or feature information is unavailable while preserving event values.
prohand
17. August 2026 um 11:22
11
Perfekt
Danke @pierre-gilles
Hast du Neuigkeiten zu diesem Thema?
prohand
8. September 2026 um 18:36
13
Ich habe versucht zu sehen, ob es funktioniert und… Ich hatte nicht gesehen, dass es noch nicht gemerged war
Hallo zusammen!
Dieses Thema ist nun in Entwicklung .
Ein PR wurde eröffnet, um in den Aktionen einer Szene den Namen des Geräts (und der Funktion) offenzulegen, das eine Zustandsänderung ausgelöst hat:
master ← claude/funny-keller-5760sn
opened 06:03PM - 27 Nov 26 UTC
### Description
A scene started by a device state trigger can now say **which d… evice fired it**. One scene watching several doors sends "Garage door was just opened" instead of needing one scene per door.
The trigger hands four variables to the steps of the scene, usable wherever a variable is (messages, SMS, HTTP, MQTT, Ask AI, formulas…):
| Variable | Label in the editor | What it holds |
| --- | --- | --- |
| `{{triggerEvent.device.name}}` | Trigger device name | name of the device whose feature changed |
| `{{triggerEvent.deviceFeature.name}}` | Trigger feature name | name of that feature |
| `{{triggerEvent.last_value}}` | Trigger new value | the value which fired the trigger |
| `{{triggerEvent.previous_value}}` | Trigger previous value | the value just before |
This is a rewrite on top of the current `master` of https://github.com/GladysAssistant/Gladys/pull/2708, which was 401 commits behind and conflicting. It supersedes that pull request, which can be closed. The variable names are the same.
**What changed compared with the previous pull request**
- **Server**: `master` now lets the checker of a trigger return the trigger event the actions see (added for the triggers of external integrations). The device state checker uses that instead of a special case in `checkTrigger`: on a match it returns the event completed with `device` and `deviceFeature` (name + selector), both read in RAM. Nothing is computed for an event no scene matches, and the emitted event is not modified.
- **Front**: the trigger form declares its variables on mount, like the calendar and integration triggers. No change to `TextWithVariablesInjected`: `master` already lists a variable declared by several triggers once, and the stale-list fix of the previous pull request is not needed there (checked in the browser and by the new Cypress spec).
- **Labels**: every label names the trigger, following the last review comment on the previous pull request ("Nouvelle valeur" was too generic) — "Nouvelle valeur du déclencheur", "Valeur précédente du déclencheur", "Nom de l'appareil déclencheur", "Nom de la fonctionnalité déclencheuse". Translated in English, French, German and Spanish.
- **MCP**: the scene schema given to the assistant names the four variables, so a scene created through MCP can use them.
- **Spec**: new section C.8 in `docs/specs/scene-editor-mobile.md`.
Reviewing note: most of the diff of `server/lib/scene/scene.triggers.js` is the device state checker moving out of the `triggersFunc` object into a named function, so an indentation change. With whitespace hidden, the change is the 20 lines of `buildDeviceNewStateTriggerEvent`.
**Behavior worth knowing**
- With "for a duration", the scene starts when the timer ends: `last_value` is the value at that moment and `previous_value` the one which started the timer.
- `triggerEvent.deviceFeature.name` is the name stored on the feature, not the translated category the editor shows for a device with a single feature of a kind.
- The values are raw (`0` / `1` for a door): readable states ("open / closed"), asked in the same forum topic, are a separate subject.
### Related request
Forum: https://community.gladysassistant.com/t/avoir-la-possibilite-de-recuperer-qui-a-declencher-la-scene/8534
### Checklist
- [x] If a forum topic or GitHub issue exists, the description links it (`Forum: https://community.gladysassistant.com/t/...` or `Closes #...`)
- [x] Tests pass: `cd server && npm run coverage` (Codecov requires 100% coverage on changed lines) and Cypress (`npm run cypress:run`) if the UI changed — `npm run coverage` passes, `scene.triggers.js` has no uncovered line or branch. For Cypress, the nine scene specs were run locally (69 tests, the new `SceneTriggerVariables.cy.js` included), not the whole suite.
- [x] Linter and prettier pass on both front and server (`npm run eslint`, `npm run prettier`) — plus `compare-translations` and `npm run build` on the front
- [x] No undocumented breaking change
Also checked on a booted instance with a real state change (`device.saveState` on a seeded sensor): the message of the scene read "Test device / Test temperature sensor celsius: 20 -> 30". Not tested with physical devices.
---
_Generated by [Claude Code](https://claude.ai/code)_
Zögert nicht, dem PR zu folgen, zu testen (optional, vor allem bei kleinen Anfragen) und euer Feedback hier zu hinterlassen, falls nötig.
Es ist in Gladys 5.3.7 verfügbar! Eine Szene, die durch einen Auslöser „Gerätestatusänderung“ gestartet wird, überträgt jetzt 4 Variablen an ihre Aktionen: Name des auslösenden Geräts, Name der auslösenden Funktion, neuer Wert und vorheriger Wert. Geben Sie {{ in einer Nachricht ein, um sie auszuwählen: Eine einzige Szene kann jetzt sagen, welche Tür gerade geöffnet wurde. Danke an @spenceur für den Vorschlag! Details: Gladys Assistant 5.3.7: enlarge your charts, and scenes that know which device triggered them 📈