As a user,
I want to be able to know which device/condition triggered a scene,
So I can use it in other actions
Ex:
I have a door opening scene (with the tag alarm ) and when a door opens, I retrieve the state of all the doors and send a message to tell me « look at the state of the doors. »
What I would have liked to do is simply know which door triggered the scene directly (itâs less tedious than fetching everything, etc.)
What do you think?
I agree with you on the need, but with a somewhat more global perspective.
My homeâs intrusion detection scene waits for a door, window, or motion sensor to trigger and then sends me a message.
Except the message is a list of all devices with their value (0 or 1). Thatâs not very user-friendly.
It would be better to display « open / closed » for example in the message. And add a default variable with the data of the device that triggered the scene?
I think this is a separate request
The doors were an example for me ^^
Basically, if a scene triggers I want to identify who triggered the scene.
Imagine,
I have
[quote=« lmilcent, post:2, topic:8534 »]
And
Good evening,
I voted to include this feature
Iâll give an example
I create a scene with all my temperature sensors as triggers if a certain threshold is exceeded.
If this threshold is exceeded then we send a message with the information about the scene trigger as well as the temperature associated with that trigger.
I can retrieve the temperature information with « Retrieve the last state » but I canât get the info about who triggered the scene
Hopefully this feature will arrive soon in Gladys
Iâm bringing this point up
@prohand are you going to go for it?
Youâve been waiting for it for two years ahah
Sorry, I havenât synced the status here, but itâs already developed:
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
August 17, 2026, 11:22am
11
Perfect
Thanks @pierre-gilles
prohand
September 8, 2026, 6:36pm
13
I was trying to see if it worked and⊠I didnât notice that it wasnât merged yet
Hi everyone!
This topic is now in development .
A PR has been opened to expose, in a sceneâs actions, the name of the device (and feature) that triggered a state change:
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)_
Feel free to follow the PR, test (optional, especially for small requests), and share your feedback here if needed.