Syntax command control nextion display

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

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 ?

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

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.

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

Show us how you have set the template

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

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

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

[edit] cheers @dceejay, fixed remnant.

1 Like

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

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

1 Like

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

1 Like

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