# Enable use of the MQTT message in a scene

**URL:** <https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590>\
**Category:** Demande de fonctionnalités\
**Tags:** feature-core, mqtt, in-progress\
**Created:** [December 6, 2023, 12:20pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590 "2023-12-06T12:20:32Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [December 6, 2023, 12:20pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/1 "2023-12-06T12:20:32Z")

</div>

I would like to be able to use the received message in scenes when an MQTT message is

---

<div class="post-metadata">

**Author:** ![Fabic](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/f/a698b9/32.png) [@Fabic](https://community.gladysassistant.com/u/Fabic)\
**Post date:** [December 6, 2023, 5:58pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/2 "2023-12-06T17:58:59Z")

</div>

Hi @cce66 ,

For me the latest integration (which you put in image1) does it. That is to say (and I think that’s great), we have the «&nbsp;continue if&nbsp;» in the trigger, we only trigger if the expected message is the correct one

---

<div class="post-metadata">

**Author:** ![spenceur](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/spenceur/32/1961_2.png) [@spenceur](https://community.gladysassistant.com/u/spenceur)\
**Post date:** [December 6, 2023, 6:23pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/3 "2023-12-06T18:23:51Z")

</div>

I’d really like this integration to be more than just a «&nbsp;continue only if&nbsp;»  
Like injecting the MQTT response into a feature, for example

---

<div class="post-metadata">

**Author:** ![Fabic](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/f/a698b9/32.png) [@Fabic](https://community.gladysassistant.com/u/Fabic)\
**Post date:** [December 6, 2023, 10:07pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/4 "2023-12-06T22:07:49Z")

</div>

Ok, indeed, retrieving the MQTT info could be interesting +1

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [December 6, 2023, 10:10pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/5 "2023-12-06T22:10:10Z")

</div>

@Fabic

yes, but I cheated there to show what I’d like to have in my feature request; currently it doesn’t exist ☺

The idea would be to be able to retrieve the value of the message to use it as a variable in a message, for example (I realize my request actually isn’t explicit enough). If we could do it with ‹&nbsp;Retrieve the last state&nbsp;› we would have the message value that

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [December 7, 2023, 8:24am UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/6 "2023-12-07T08:24:19Z")

</div>

I agree — I don’t understand either what that adds!

The topic doesn’t change during the scene, so why would you want a variable? If you defined it at the top in the trigger, then it’s fixed, right? 🤔

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [December 7, 2023, 10:30am UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/7 "2023-12-07T10:30:25Z")

</div>

Hello @pierre-gilles,

This isn’t for the topic, it’s for the received message where we could change the scene’s behavior based on the received message, for example  
«&nbsp;continue only if&nbsp;» message=value \<  
"Send message {{ mqtt value "  
and another scene  
«&nbsp;continue only if&nbsp;» message=value \>  
"Send message {{ mqtt value "  
or when the «&nbsp;else&nbsp;» is added to the «&nbsp;continue only if&nbsp;»  
«&nbsp;continue only if&nbsp;» message=value \<  
«&nbsp;Else&nbsp;»  
"Send message {{ mqtt value "  
I put «&nbsp;send a message&nbsp;» but it could be another action

this ties into my feature request [Pouvoir créer des variables globales utilisables dans gladys (Latitude, Longitude, Date, Heure etc)](https://community.gladysassistant.com/t/pouvoir-creer-des-variables-globales-utilisables-dans-gladys/8589)  
the idea is to have a bit more flexibility and configurability in Gladys

These are just suggestions; if there’s demand there will be votes so it might be interesting to develop, if there isn’t then no need to develop, but you can’t know without asking! 😊

Also I had proposed this

> [@MQTT - creation d'un appareil MQTT pur](https://community.gladysassistant.com/t/mqtt-creation-dun-appareil-mqtt-pur/8455):
>
> Cette demande concerne cette discussion et me parait pas tout à fait similaire à celle-ci car ici c’est dans les scénes, d’où cette demande Donc l’idée serait d’avoir la possibilité de créer un appareil dans l’intégration MQTT qui réagirait à un suscribe mqtt propre pour le transformer et l’utiliser dans gladys et permettre depuis Gladys de publier vers lui sans devoir passer par Node-red donc passer d’un appareil «&nbsp;texte&nbsp;» à un appareil MQTT pur Voila j’espère avoir ét…

ideally it would be better because it covered the send/receive side of an MQTT message in the scenes that @Lokkye implemented but we could use the state feedback like for other MQTT devices while keeping Gladys’ internal syntax — it’s just a mapping to do:

- Gladys subscribes to the publish of an external device; when it receives it transforms it into Gladys MQTT syntax then sends it for processing as if it had received that message in Gladys format

- when Gladys must publish the MQTT of an external device it transforms Gladys MQTT syntax to external MQTT syntax then sends the message

This would allow avoiding Node-RED for all devices not yet integrated or that won’t be because they’re too specific  
But there aren’t many votes so maybe it’s not of interest; maybe an integration should be developed where we could handle this mapping as a simpler case since there would just be a table to add in the DB, I’m not there yet for that 🤔 but I’m not giving up 😊!

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [December 7, 2023, 10:59am UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/8 "2023-12-07T10:59:11Z")

</div>

Would assigning the value to a virtual device and acting on the state of that feature (like a regular device) meet your need?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [December 7, 2023, 12:26pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/9 "2023-12-07T12:26:05Z")

</div>

[quote=«&nbsp;cce66, post:7, topic:8590&nbsp;»]  
depending on the message received, for example  
« only continue if » message=value \<  
"

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [December 7, 2023, 1:10pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/10 "2023-12-07T13:10:30Z")

</div>

> [@pierre-gilles](#):
>
> But that’s already possible right now! I don’t see what that would add, my remark also applies to the message

Currently, either we leave nothing in the message field and the scene continues after the trigger only if any message arrives on the topic (which reflects the payload value — we’re OK) but we can’t do anything with the value received on the topic.  
Or indeed we put a value in message but we only handle that specific value case.

So if we put nothing in message, the scene runs, there is indeed a value received on the topic and it’s that value that I would like to use afterwards, but for that it must be assigned to a variable because if we do ‹&nbsp;retrieve device state&nbsp;› we don’t have a link to get that value and in the «&nbsp;continue if&nbsp;» area it’s the same (it seems to me).

Take the case of an exotic device «&nbsp;Exotic&nbsp;» not integrated, we put in the Topic field the value that the device exposes called «&nbsp;ExoticValue&nbsp;» so we have in the «&nbsp;Topic&nbsp;» field the value «&nbsp;Exotic/ExoticValue&nbsp;» and when the device «&nbsp;Exotic&nbsp;» has a change of value «&nbsp;ExoticValue&nbsp;» which is, for example, an integer from 0 to 100, we could, depending on ExoticValue, then send a telegram message that would say «&nbsp;warning the value of Exotic is xx&nbsp;»

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [December 7, 2023, 1:26pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/11 "2023-12-07T13:26:46Z")

</div>

currently you can’t assign any topic to a virtual device, note that since I couldn’t get the one in the scene to work maybe I don’t have the right syntax 🤔, an example should be provided! 🙄

After reflection, I remember seeing a message to that effect in the exchanges between @pierre-gilles and @Lokkye, indeed it’s better to go through a virtual device and not use this function in a scene (which isn’t useless otherwise but just not suited to what I wanted to do) I’ll keep using Node-RED for this!

---

<div class="post-metadata">

**Author:** ![spenceur](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/spenceur/32/1961_2.png) [@spenceur](https://community.gladysassistant.com/u/spenceur)\
**Post date:** [December 7, 2023, 4:25pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/12 "2023-12-07T16:25:50Z")

</div>

No, it’s not currently possible, or I’m doing it wrong.

I have a scene that sends

---

<div class="post-metadata">

**Author:** ![spenceur](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/spenceur/32/1961_2.png) [@spenceur](https://community.gladysassistant.com/u/spenceur)\
**Post date:** [December 8, 2023, 8:06pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/13 "2023-12-08T20:06:29Z")

</div>

So, @pierre-gilles, is it possible to do it?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [December 11, 2023, 10:28am UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/14 "2023-12-11T10:28:13Z")

</div>

No, that’s not possible!

---

<div class="post-metadata">

**Author:** ![cursor-bot](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cursor-bot/32/22252_2.png) [@cursor-bot](https://community.gladysassistant.com/u/cursor-bot)\
**Post date:** [August 17, 2026, 12:09pm UTC](https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590/15 "2026-08-17T12:09:06Z")

</div>

Hi everyone!

This topic is now **under development**.

A PR has been opened to use the MQTT topic and message received as scene variables:

> <https://github.com/GladysAssistant/Gladys/pull/2889>
>
> Implements feature request: https://community.gladysassistant.com/t/pouvoir-util…iser-le-message-mqtt-dans-une-scene/8590
> 
> \> \*\*Note:\*\* this PR was opened by an automated Claude Code run. It needs human review and real-life testing (an actual MQTT broker + a scene using the trigger) before being merged.
> 
> \### Description
> 
> When a scene is triggered by the \*\*"MQTT message received"\*\* trigger, the received message was only usable as an exact-match filter on the trigger itself. Users asked to be able to \*use\* the received payload inside the scene (forum topic above): the example given is listening on a \`tts\` topic and forwarding the received text to another action, instead of creating one scene per possible message.
> 
> This PR exposes the trigger event data as scene variables, following the same pattern as the calendar trigger (\`setVariablesTrigger\`):
> 
> \- \`{{triggerEvent.topic}}\` — the topic the message was received on
> \- \`{{triggerEvent.message}}\` — the received message
> 
> They now appear in the variable picker of every action input built on \`TextWithVariablesInjected\` (send a message, HTTP request, publish an MQTT message, set a device value, ask AI, set a variable, delay, ...), so they can be injected anywhere by typing \`{{\`.
> 
> They can also be selected as the \*\*left side of a condition in the "Only continue if" box\*\*: trigger variables were previously only available on the right side (value field). Since trigger variables are set before the scene runs, they are offered whatever the position of the box in the scene, in a dedicated "Scene triggers" group of the variable dropdown. This benefits the calendar trigger as well, which already declared trigger variables.
> 
> Changes:
> 
> \- \`front/src/routes/scene/edit-scene/triggers/MQTTReceivedTrigger.jsx\`: declare the two trigger variables via \`setVariablesTrigger\`, plus a short hint in the trigger card explaining they can be injected in the next actions.
> \- \`front/src/routes/scene/edit-scene/TriggerCard.jsx\`: pass \`variables\` / \`setVariablesTrigger\` down to the MQTT trigger component.
> \- \`front/src/routes/scene/edit-scene/actions/only-continue-if/OnlyContinueIfParams.jsx\`: add the triggers variables to the condition variable dropdown.
> \- \`front/src/config/i18n/{en,fr,de}.json\`: new labels.
> \- \`server/test/lib/scene/triggers/scene.trigger.mqttReceived.test.js\`: new end-to-end tests.
> 
> No server change was needed: \`checkTrigger\` already executes the scene with \`{ triggerEvent: event }\` as scope, and the \`mqtt.received\` event already carries \`topic\` and \`message\` (emitted from \`scene.addScene.js\`), so Handlebars resolves \`{{triggerEvent.topic}}\` / \`{{triggerEvent.message}}\` and \`get(scope, 'triggerEvent.message')\` works in "Only continue if". The new server tests verify that end to end so the behaviour cannot silently regress.
> 
> \## Forum
> 
> Forum: https://community.gladysassistant.com/t/pouvoir-utiliser-le-message-mqtt-dans-une-scene/8590
> 
> \### Checklist
> 
> \- \[x\] Tests pass: ran the scene test suites (\`test/lib/scene/\*\*\`, 302 passing, including 3 new tests in \`scene.trigger.mqttReceived.test.js\`). Full \`npm run coverage\` and Cypress were \*\*not\*\* run in this environment — the only non-test change is front-end, which Codecov does not gate, but CI should confirm.
> \- \[x\] Linter and prettier pass on both front and server (\`npm run eslint\` → 0 errors on both, \`prettier --check\` clean on the changed files)
> \- \[x\] No undocumented breaking change
> 
> 
> \---
> \_Generated by \[Claude Code\](https://claude.ai/code/session\_013yxguVaLdJ8ZKmw5x3HePT)\_
> 
> 
> \## Summary by CodeRabbit
> 
> \* \*\*New Features\*\*
> \* Added MQTT trigger variables for the received topic and message.
> \* Use MQTT data in subsequent scene actions and conditions.
> \* Added localized labels and guidance in English, German, and French.
> 
> \* \*\*Bug Fixes\*\*
> \* Improved MQTT-triggered scene behavior, including conditional continuation and user message delivery.

Don’t hesitate to follow the PR, test as soon as possible, and share your feedback here.
