Hi! Im trying to read out value from an counter n domoticz to send to a textbox in nextion but i cant get it to work.
I can read out sensors and send but not counters.
I have used the luascript Ierlandfan posted earlier her
but cant get it to work.
Domoticz log says LUA: Counter = 75.015
I would be very grateful for help, here is the script

Thanks a lot for the efforts you have had with the plugin. The WAF (women's acceptance factor) raised up to 100%.

Short question: using the original RX/TX hard serial on the Wemos D1 mini (GPIO3/1) works 100% reliable (opposite to the soft serial) - you described this some pages earlier. But if I'm configuring the speed higher than 9600 I get no connection to the Nextion. Normal behaviour?

Thanks a lot for the efforts you have had with the plugin. The WAF (women's acceptance factor) raised up to 100%.

Short question: using the original RX/TX hard serial on the Wemos D1 mini (GPIO3/1) works 100% reliable (opposite to the soft serial) - you described this some pages earlier. But if I'm configuring the speed higher than 9600 I get no connection to the Nextion. Normal behaviour?

Up to 115200 is supported as far as I know but if the plugin is programmed for 9600 I guess setting it to something else will make the communication miss.

I did'nt think that it would be useful for me to use a higher speed than 9600 baud because up to now I only fill a few variables and check one button to be pressed. These few bytes seemed to be communicated fast enough between the devices. Just from curiosity I changed the speed to 115200. At 9600 baud I had a lack of around 1.5 seconds betweeen pressing the button and switching the light on. Has been good for me, because the relay for the light is connected to another node in my network. At 115200 the light is switched on almost instantly. Never stop learning....

Setting the desired baudrate in the initializing section of the Nextion works fine. The plugin in its current state seems to me pretty stable and almost complete.

The one and only thing on my personal wishlist would be the possibility of flashing the Nextion over network. Its such a pain to unmount the display off the wall for only adding a textfield that I have ordered This one to get an useable access to the sd cardslot of the display mounted to the wall. Somehow I will integrate the cable in the future housing of the Nextion.

The combination should be that ESPEasy plays the Wifi card for the Nextion.

Flashing the Nextion using UART works perfectly out of the Nextion Editor while connected to my Laptop, in the Arduino library published by Itead there is an explicit function for doing this, too.

I am pretty sorry for the fact, that my coding skills are not sufficient do realize this wish. But looking at the Arduino libraries might show the way how to flash the Nextion over network using the existing - in my opinion pretty stable - serial connection of ESPEasy to the display - prerequisit hard serial.

I've never used the Ser2Net plugin, but maybe it could be used to assist with flashing the Nextion? Or maybe a spinoff of Ser2Net that has been altered to support Nextion's hardware serial wiring scheme. Minor code tweaks shouldn't be a problem, but a major code rewrite would be a deal killer for me.

In my first step I followed This wiring diagram, except diode and resistor, they are not necessary. My first configuration RX/TX of ESPEasy-plugin is shown here. To use hard serial my Nextion is meanwhile connected to the RX/TX pins of the Wemos.

In my first step I followed This wiring diagram, except diode and resistor, they are not necessary. My first configuration RX/TX of ESPEasy-plugin is shown here. To use hard serial my Nextion is meanwhile connected to the RX/TX pins of the Wemos.

Thanks Wiki, it works now. You have right, a wiring problem. I was looking to much too the colors. But the wiring of my screen was reversed. Better looking at the rear side of the print was the solution.

First I added two variables va0 and va1 and unchecked the Send Component ID of
Bt0, b0 and down buttons.
Next I put some code under the buttons:
Under Tough Release Event of bt0:
if(va1.val==0)
{
va1.val=1
print "|s,i99,sOn"
printh 0a
}else
{
va1.val=0
print "|s,i99,sOff"
printh 0x0a
}

With the code below, you can now also send values.
As for now I distinguish |u for update and |s for switch

First of all I will thanks BertB and ThomasB for this plugin. After a lot of reading and trying i can now switched the three lights in the livingroom on and off with the Nextion Display.
With the help of the part I quote it runs fine.
I have only one problem. Domoticz switched the lights automatic on. But i dont seen the state changing of the Nextion.
How can i made that visible?

In general its no problem to show every information you desire on the Nextion using some rules.

But to get help you should provide more information about the infrastructure you are using.

My situation, i have three table lights with a ESP01 and ESPEasy build 145.
I switched they on/off with Domoticz with this command:192.168.178.xxx/control?cmd=GPIO,0,1 and 192.168.178.xxx/control?cmd=GPIO,0,0
For this moment i try to use a Nextion as Remote Control. That works good, only when Domoticz switched on a table Light the Remote Control overruled the switch in Domoticz.
My wish, switch the lamp on with Domoticz, see changing the state on the Nextion, and switched the lamp off on the Nextion.
And how to do that i don't seen the light.

There might be a smarter solution, but I would go through rules. I assume that you have the domoticz configured as MQTT-controller in your ESP12. I assume that you have define a dual-state button in Nextion.

If not already done so, define the gpio port of the relay as a device, an example you can find here, third image of the example using your GPIO 0 as 1st GPIO. On your ESP12 enable rules in the Webgui "Tools/Advanced". Define a rule:

On Relay#State do
if [Relay#State]=0
Publish domoticz/in,{"idx":123456,"nvalue":0,"svalue":"0"} //replace idx 123456 with the correct idx of the switch in domoticz, domoticz will change the state by itself
SendToHTTP 192.168.xxx.xxx,80,/control?cmd=event,RelayState=0 //put in the ip of your wemos
else
Publish domoticz/in,{"idx":123456,"nvalue":1,"svalue":"1"} //replace idx 123456 with the correct idx of the switch in domoticz
SendToHTTP 192.168.xxx.xxx,80,/control?cmd=event,RelayState=1
endif
endon

On RelayState do
if %eventvalue%=0
//Here place the action you want to send to Nextion using the correct name 'pagex.bty' for yout button
//e.g. changing the value of your button: NEXTION,page0.bt0.val=0
else
//Here place the action you want to send to Nextion as opposite to switching off
//e.g. changing the value of yout button: NEXTION,page0.bt0.val=1
endif
endon

These two rules should change the state of the switch in domoticz as well as the state of your button in Nextion.

There might be a smarter solution, but I would go through rules. I assume that you have the domoticz configured as MQTT-controller in your ESP12. I assume that you have define a dual-state button in Nextion.

If not already done so, define the gpio port of the relay as a device, an example you can find here, third image of the example using your GPIO 0 as 1st GPIO. On your ESP12 enable rules in the Webgui "Tools/Advanced". Define a rule:

On Relay#State do
if [Relay#State]=0
Publish domoticz/in,{"idx":123456,"nvalue":0,"svalue":"0"} //replace idx 123456 with the correct idx of the switch in domoticz, domoticz will change the state by itself
SendToHTTP 192.168.xxx.xxx,80,/control?cmd=event,RelayState=0 //put in the ip of your wemos
else
Publish domoticz/in,{"idx":123456,"nvalue":1,"svalue":"1"} //replace idx 123456 with the correct idx of the switch in domoticz
SendToHTTP 192.168.xxx.xxx,80,/control?cmd=event,RelayState=1
endif
endon

On RelayState do
if %eventvalue%=0
//Here place the action you want to send to Nextion using the correct name 'pagex.bty' for yout button
//e.g. changing the value of your button: NEXTION,page0.bt0.val=0
else
//Here place the action you want to send to Nextion as opposite to switching off
//e.g. changing the value of yout button: NEXTION,page0.bt0.val=1
endif
endon

These two rules should change the state of the switch in domoticz as well as the state of your button in Nextion.

Wiki, Thanks for the rules, after a lot of trying it works for 90%
On the Nextion i have a button on page0 with objname bt0 and vscope global, Touch Release Event Send Component ID active.

I'm a bit confused, but here's what I think is going on.
1. The Nextion is wired to the ESP12 and has IP address 192.168.178.xxx.
2. The Relay is on ESP01 and has IP address 192.168.178.127.
3. The ESP12's rule is sending the NEXTION http command to the ESP01. This is not what is wanted because the NEXTION is wired to the EPS12.

What is needed is a rule in the ESP01 relay device that sends the NEXTION's http commands whenever the relay changes states. For example, in the ESP01 rules try this:

I'm a bit confused, but here's what I think is going on.
1. The Nextion is wired to the ESP12 and has IP address 192.168.178.xxx.
2. The Relay is on ESP01 and has IP address 192.168.178.127.
3. The ESP12's rule is sending the NEXTION http command to the ESP01. This is not what is wanted because the NEXTION is wired to the EPS12.

What is needed is a rule in the ESP01 relay device that sends the NEXTION's http commands whenever the relay changes states. For example, in the ESP01 rules try this:

On Relay#State do
if [Relay#State]=0
SendToHTTP 192.168.178.xxx,80,/control?cmd=NEXTION,page0.bt0.val=0 //put in the ip of your NEXTION's ESP12
else
SendToHTTP 192.168.178.xxx,80,/control?cmd=NEXTION,page0.bt0.val=1
endif
endon

If I have misunderstood how things are wired then please ignore my comments.

- Thomas

Hello ThomasB, thanks your answer. Instead of the ESP01 i use a Sonoff Pow for testing.
On the Sonoff Pow with IP: 192.168.178.126 i use this rule:
On Relay#State do
if [Relay#State]=0
SendToHTTP 192.168.178.53,8080,/json.htm?type=command&param=udevice&idx=1534&nvalue=0&svalue=0
SendToHTTP 192.168.178.127,80,/control?cmd=event,RelayState=0
else
SendToHTTP 192.168.178.53,8080,/json.htm?type=command&param=udevice&idx=1534123456&nvalue=1&svalue=1
SendToHTTP 192.168.178.127,80,/control?cmd=event,RelayState=1
endif
endon

On theWemos with the Nextion display, IP: 192.168.178.127 i use this rule:
On RelayState do
if %eventvalue%=0
SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=0
SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,0
else
SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=1
SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,1
endif
endon

On theWemos with the Nextion display, IP: 192.168.178.127 i use this rule:
On RelayState do
if %eventvalue%=0
SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=0
SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,0
else
SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=1
SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,1
endif
endon

I see that the Nextion Wemos (192.168.178.127) is sending http to itself. That is not supported. The Wemos NEXTION commands that originate from its own rules must use its serial port instead of the http.

As one example, on the Nextion Wemos device you would replace this rule line:

On theWemos with the Nextion display, IP: 192.168.178.127 i use this rule:
On RelayState do
if %eventvalue%=0
SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=0
SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,0
else
SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=1
SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,1
endif
endon

I see that the Nextion Wemos (192.168.178.127) is sending http to itself. That is not supported. The Wemos NEXTION commands that originate from its own rules must use its serial port instead of the http.

As one example, on the Nextion Wemos device you would replace this rule line:

As mentioned, a device should not http to itself. If there is a GPIO-12 I/O controlled device on the Wemos then use direct GPIO statements instead.

- Thomas

ThomasB, thanks for the tips. It let me learn more about rules.

The two rules with GPIO,12,0 and GPIO,12,1 was for me only a check if the rules works, thats all.

In my case Domoticz switched with timers the lights on/off in the livingroom.
The only thing what i want is a rule for a button that send a on/off command from the Nextion to, for example, the Sonoff Pow on 192.168.178.126

When i With Domoticz switch on/off the Sonoff Pow it works fine, it shows on the display the correct state.
Do i the same on the Nextion same result Pow on/ff and on the nextion the correct state.
When i switch on the Pow on Domoticz and off on the Nextion the Pow switched directly on again.
I believe the state of [Relay#State] and [Nextion#value] has a conflict with eachother.
But how to solve that.

If the wemos is rebooted the button might not show the correct state but after the first action of the relay it will be and stay correct. To avoid this you might define an additional pair of request and answer rules between wemos and sonoff for getting the correct state of the relay during boot time of the wemos and setting the button state in Nextion accordingly.

Yesterday morning i found the same solution with the trail and error method. It works for me good enough.
I saw the same thing with working with your code and my code.
When i start the Sonoff Pow from Domoticz and i will stop it on the Nextion i must sometimes press the button twice.
That's depend of the state of the variable on the Nextion. But I can live with it.

[...]
When i start the Sonoff Pow from Domoticz and i will stop it on the Nextion i must sometimes press the button twice.
That's depend of the state of the variable on the Nextion.
[...]

I have already seen a similar behaviour of my Netxion. I think its a timing problem of the serial connection between your Wemos and the Nextion because the variable - at least in my example - is set to the correct value because the Sonoff should trigger the event RelayState on the Wemos if switched on by Domoticz.

I solved this issue by switching to hard serial using GPIO3 and GPIO1 (on Wemos board these are the RX/TX pins) for connecting the Nextion and chose 115200 baud speed.

[...]
When i start the Sonoff Pow from Domoticz and i will stop it on the Nextion i must sometimes press the button twice.
That's depend of the state of the variable on the Nextion.
[...]

I have already seen a similar behaviour of my Netxion. I think its a timing problem of the serial connection between your Wemos and the Nextion because the variable - at least in my example - is set to the correct value because the Sonoff should trigger the event RelayState on the Wemos if switched on by Domoticz.

I solved this issue by switching to hard serial using GPIO3 and GPIO1 (on Wemos board these are the RX/TX pins) for connecting the Nextion and chose 115200 baud speed.

Totally agree, nextion should always use hardware serial. I have seen problems over time when bit banging the S8 sensor. Using hardware serial works "forever".

[...]
When i start the Sonoff Pow from Domoticz and i will stop it on the Nextion i must sometimes press the button twice.
That's depend of the state of the variable on the Nextion.
[...]

I have already seen a similar behaviour of my Netxion. I think its a timing problem of the serial connection between your Wemos and the Nextion because the variable - at least in my example - is set to the correct value because the Sonoff should trigger the event RelayState on the Wemos if switched on by Domoticz.

I solved this issue by switching to hard serial using GPIO3 and GPIO1 (on Wemos board these are the RX/TX pins) for connecting the Nextion and chose 115200 baud speed.