# Syntax command control nextion display

**URL:** https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936
**Category:** Developing Nodes
**Created:** [13 February 2021 16:18 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936 "2021-02-13T16:18:20Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![pinie\_pinie](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@pinie\_pinie](https://discourse.nodered.org/u/pinie_pinie)
#### Post date: [13 February 2021 16:18 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/1 "2021-02-13T16:18:20Z")

</div>

Hi,

I would like to control a text field in a Nextion display with a variable text.  
The command must be at the end: NEXTION, t1.txt = "Hello"  
"Hello" should correspond to the payload. But it is imperative that the  
Quotation marks.  
I tried to write a function node.  
Can someone help me with the syntax for this?

Many Thanks

Thoralf

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [13 February 2021 16:21 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/2 "2021-02-13T16:21:39Z")

</div>

so what exact does the command need to be ? and where is the text you want to display coming from (is it already in msg.payload? ) - and what is the function you have tried so far ?

---

<div class="post-metadata">

### Author: ![pinie\_pinie](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@pinie\_pinie](https://discourse.nodered.org/u/pinie_pinie)
#### Post date: [13 February 2021 16:29 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/3 "2021-02-13T16:29:33Z")

</div>

Hi,

exactly the content is already included in msg.payload.  
I can't do that with the quotation times.  
I want to send the message to the display via MQTT.  
The "fixed" part is: NEXTION, t1.txt =  
The variable part would then be "msg.payload"  
But as already mentioned the quotation marks have to be.  
The content of msg.payload should then be shown in the text field "t1" of the display.  
I tested this with MQTT.fix and it works. Now Nodered should send the variable data.

Thoralf

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [13 February 2021 16:32 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/4 "2021-02-13T16:32:34Z")

</div>

Several ways as usual. One simple one would be you use a template node. The default setting should be a clue how to use it.

---

<div class="post-metadata">

### Author: ![pinie\_pinie](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@pinie\_pinie](https://discourse.nodered.org/u/pinie_pinie)
#### Post date: [13 February 2021 17:06 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/5 "2021-02-13T17:06:28Z")

</div>

Hi,

the hint was good.  
I just can't get the syntax right. My msg.payload has the following content: A.  
At the end NEXTION, t1.txt = "A" should be generated.  
Do you have a suggestion for me?

Thank you!  
Thoralf

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [13 February 2021 17:14 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/6 "2021-02-13T17:14:35Z")

</div>

Show us how you have set the template

---

<div class="post-metadata">

### Author: ![pinie\_pinie](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@pinie\_pinie](https://discourse.nodered.org/u/pinie_pinie)
#### Post date: [13 February 2021 17:16 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/7 "2021-02-13T17:16:58Z")

</div>

NEXTION,t1.txt={{"msg.payload"}}

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [13 February 2021 17:23 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/8 "2021-02-13T17:23:50Z")

</div>

Using function node.  
`msg.payload = 'NEXTION,t1.txt="' + msg.payload + '"'`

Or template  
`NEXTION,t1.txt="{{payload}}"`

[edit] cheers @dceejay, fixed remnant.

---

<div class="post-metadata">

### Author: ![pinie\_pinie](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@pinie\_pinie](https://discourse.nodered.org/u/pinie_pinie)
#### Post date: [13 February 2021 17:49 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/9 "2021-02-13T17:49:04Z")

</div>

Hi,

sorry, you don't have it easy with me.  
I thought I have to create 2 nodes. That didn't work.  
Now just used the template node and now it works.  
With the template node I can control the Nextion display via MQTT.  
The command NEXTION, t1.txt = "{{payload}}" generates the desired event.  
I didn't get the function node to run.  
Thanks for your support. You notice I have no idea about the syntax.  
Should the function node also work on its own?

Thank you!

Thoralf

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [13 February 2021 17:52 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/10 "2021-02-13T17:52:00Z")

</div>

Well it might if it didn’t have the extra }} at the end 😉

---

<div class="post-metadata">

### Author: ![pinie\_pinie](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@pinie\_pinie](https://discourse.nodered.org/u/pinie_pinie)
#### Post date: [13 February 2021 17:56 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/11 "2021-02-13T17:56:12Z")

</div>

Hi,

it is exactly like that. Now both nodes are running without problems.  
I couldn't have done it without your help.  
Learned something again.

Thoralf

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [27 February 2021 17:56 UTC](https://discourse.nodered.org/t/syntax-command-control-nextion-display/40936/12 "2021-02-27T17:56:42Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
