Nextion display plugin
Moderators: grovkillen, Stuntteam, TD-er
Re: Nextion display plugin
I do not get you.
need to use node red?
need to use node red?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Nextion display plugin
Well if Domoticz is not allowing you to publish to a MQTT topic with only a single value then node red is your best choice I guess.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Nextion display plugin
I understood.
Re: Nextion display plugin
it was possible to transfer temperature data using node red.
now trying to make feedback with the switch nextion display , something is not working yet.
now trying to make feedback with the switch nextion display , something is not working yet.
Re: Nextion display plugin
- Attachments
-
- 2018-10-05 15_46_08-ESP_Easy.jpg (31.38 KiB) Viewed 309491 times
-
- 2018-10-05 15_45_31-ESP_Easy.jpg (57.44 KiB) Viewed 309491 times
Re: Nextion display plugin
Can I change the state of the button on the display with this rule?
on STH#Sw-Lamp do
if [STH#Sw-Lamp] = 1
Publish Nextion#page0.bt0.pic=0
if [STH#Sw-Lamp] = 0
Publish Nextion#page0.bt0.pic=1
endif
endon
on STH#Sw-Lamp do
if [STH#Sw-Lamp] = 1
Publish Nextion#page0.bt0.pic=0
if [STH#Sw-Lamp] = 0
Publish Nextion#page0.bt0.pic=1
endif
endon
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Nextion display plugin
Publish command is used for MQTT publishing. It got nothing to do with nextion commands. I think nextion is the command you're looking for?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Nextion display plugin
here is almost a working version
only sometimes on or off works the second time.
on STH#Sw-Lamp do
if [STH#Sw-Lamp] = 0
Nextion,page0.bt0.val=0
endon
on STH#Sw-Lamp do
if [STH#Sw-Lamp] = 1
Nextion,page0.bt0.val=1
endon
only sometimes on or off works the second time.
on STH#Sw-Lamp do
if [STH#Sw-Lamp] = 0
Nextion,page0.bt0.val=0
endon
on STH#Sw-Lamp do
if [STH#Sw-Lamp] = 1
Nextion,page0.bt0.val=1
endon
Re: Nextion display plugin
Assuming your page0.bt0.val variable is working correctly, then try this rule code:
- Thomas
Code: Select all
on STH#Sw-Lamp do
if [STH#Sw-Lamp]=0
Nextion,page0.bt0.val=0
endif
if [STH#Sw-Lamp]=1
Nextion,page0.bt0.val=1
endif
endon
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Nextion display plugin
Code: Select all
on STH#Sw-Lamp do
if [STH#Sw-Lamp] = 0
Nextion,page0.bt0.val=0
else
Nextion,page0.bt0.val=1
endif
endon
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Nextion display plugin
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
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
Code: Select all
-- we need this function to send the quotes around the values
function url_encode(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w %-%_%.%~])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
countervalueintext = otherdevices_svalues['Counter'] --this values can be for example 88.5 or 1433.2, just like temperature can be 2.3 or -4.4)
countervalueinquotes = '"' ..countervalueintext.. '"' --First part of the magic
commandArray = {}
print('Counter = '..countervalueintext) --This shows up in Domoticz log
counter =tonumber(countervalueintext) -- If you want to compare numeric values, see example later on
if (devicechanged['Counter'])then --If value changes of device SolarEnergyLive
os.execute('curl -s "http://192.168.x.x/control?cmd=NEXTION,page2.t7.txt=' .. url_encode(countervaluesinquotes) .. '"') --sending value to textbox in quotes
print('Sending data to Nextion') --This shows up in Domoticz log
return commandarray --execute the commands
end --To close the If
Re: Nextion display plugin
Hi,
meanwhile I think, I am stupid. I scrolled through the whole thread. My Nextion is connected to a Wemos D1, blue cable=> D7, yellow cable => D5. Serial port disabled.
Configuration of the Nextion in ESPEasy:
In Nextion, I have a textfield named "WZt", when I am tying to send esp_ip/control?cmd=NEXTION,page0.WZt.txt="hallo" nothing happens.
meanwhile I think, I am stupid. I scrolled through the whole thread. My Nextion is connected to a Wemos D1, blue cable=> D7, yellow cable => D5. Serial port disabled.
Configuration of the Nextion in ESPEasy:
In Nextion, I have a textfield named "WZt", when I am tying to send esp_ip/control?cmd=NEXTION,page0.WZt.txt="hallo" nothing happens.
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
1. When you issue your http command from a web browser, does the browser show a response that looks like this?In Nextion, I have a textfield named "WZt", when I am tying to send esp_ip/control?cmd=NEXTION,page0.WZt.txt="hallo" nothing happens.
Code: Select all
NEXTION075 : WRITE = page0.WZt.txt="hallo"
- Thomas
Re: Nextion display plugin
Yes, the browser shows me exactly the response that you've posted. Sorry, I should have added this info to my post.
And no, the "24.5" doesn't appear on the Nextion. Thats why I tried to send whatever to the node connected to the Nextion using the http control command.
And no, the "24.5" doesn't appear on the Nextion. Thats why I tried to send whatever to the node connected to the Nextion using the http control command.
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
That confirms the Nextion plugin is active.Yes, the browser shows me exactly the response that you've posted.
Code: Select all
And no, the "24.5" doesn't appear on the Nextion.
BTW, don't forget the Nextion's black (ground) wire needs to be connected to Wemos ground. Nextion requires 5.0V (not 3.3V).
2. Check your Nextion software that you created. Maybe there is an error in your code.
- Thomas
Re: Nextion display plugin
......and yes, I AM stupid.
Wiring OK, Plugin OK, Nextion OK. But now I've learned, that I should have checked the source of the Nextin for typos. If I want to send to "WZt" but the field was named by me "WWt" it could not work.
Never mind, sorry and thanks for your thoughts and tipps, and thanks for the plugin. Works absolutely perfect now.
Wiring OK, Plugin OK, Nextion OK. But now I've learned, that I should have checked the source of the Nextin for typos. If I want to send to "WZt" but the field was named by me "WWt" it could not work.
Never mind, sorry and thanks for your thoughts and tipps, and thanks for the plugin. Works absolutely perfect now.
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
Glad to hear you got it working.Works absolutely perfect now.
- Thomas
Re: Nextion display plugin
Hi,
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?
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Nextion display plugin
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.Wiki wrote: ↑29 Oct 2018, 17:40 Hi,
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?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Nextion display plugin
The Nextion display module defaults to 9600 baud. It does NOT automatically detect other baud rates.
So if you select anything other than 9600 in the plugin you will also need to change the baud setting in the display module. Nextion's Baud command syntax is found here:
https://nextion.itead.cc/resources/docu ... ction-set/
https://www.itead.cc/wiki/Nextion_Instruction_Set
- Thomas
So if you select anything other than 9600 in the plugin you will also need to change the baud setting in the display module. Nextion's Baud command syntax is found here:
https://nextion.itead.cc/resources/docu ... ction-set/
https://www.itead.cc/wiki/Nextion_Instruction_Set
- Thomas
Re: Nextion display plugin
Thank you for the information and the links.
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....
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....
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Nextion display plugin
I feel that the plug-in should have a baud rate setting.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Nextion display plugin
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 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.
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Nextion display plugin
Could it be combined with a WiFi SD card or isn't the nextion that simple to set up?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Nextion display plugin
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.
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.
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
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.
Ideally we would need a virtual com port on our developer PC that the Nextion IDE could use to redirect its com port to TCP for flashing. Something like this (randomly found with Google):
https://www.hw-group.com/software/hw-vs ... erial-port
It would be great if a Nextion plugin user that has experience with Ser2Net would chime in and offer some insight on this idea.
- Thomas
Ideally we would need a virtual com port on our developer PC that the Nextion IDE could use to redirect its com port to TCP for flashing. Something like this (randomly found with Google):
https://www.hw-group.com/software/hw-vs ... erial-port
It would be great if a Nextion plugin user that has experience with Ser2Net would chime in and offer some insight on this idea.
- Thomas
Re: Nextion display plugin
Wiki, is it possible to send me that HMI file or a printscreen of the Nextion Editor? I do something wrong, but i don't see the light.
Thanks in advance, Herman
Re: Nextion display plugin
I think, a printscreen would not be helpful.
Pls give some more input.
Pls give some more input.
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
Wiki,
I did the same as you, setup the Nextion plugin. And put in the first line: page0.WZt.txt="24.5"
Then i start Nextion Editor, I have selected a font. Then i select in in the Toolbox the first line, Text.
Give it as objname: WZt
Compile it and save is as WZt. After that i bring the two files to the Nextion. I see on the screen "newtxt"
When i do esp_ip/control?cmd=NEXTION,page0.WZt.txt="hallo" it respond with NEXTION075 : WRITE = page0.WZt.txt="hallo"
But i don't see "24.5" on the Nextion screen.
I do something wrong in the Nextion Editor part, and here i need some help.
Re: Nextion display plugin
What you have done is absolutely correct. Talking to the Nextion using the Nextion-plugin is really that simple - if you do have a working serial communication.
Check your wiring twice and triple, assure you have connected GND ESP and GND Nextion, use baudrate 9600, disable serial communication in ESPEasy Tools/Advanced.
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.
Check your wiring twice and triple, assure you have connected GND ESP and GND Nextion, use baudrate 9600, disable serial communication in ESPEasy Tools/Advanced.
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.
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
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.Wiki wrote: ↑01 Nov 2018, 11:32 What you have done is absolutely correct. Talking to the Nextion using the Nextion-plugin is really that simple - if you do have a working serial communication.
Check your wiring twice and triple, assure you have connected GND ESP and GND Nextion, use baudrate 9600, disable serial communication in ESPEasy Tools/Advanced.
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.
Re: Nextion display plugin
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.BertB wrote: ↑22 Jan 2017, 15:34
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
}
I also added some rules to the ESP.
on Nextion#idx=99 do
if [Nextion#value]=1
sendtohttp 192.168.0.243,8080,/json.htm?param=switchlight&type=
command&idx=304&switchcmd=On
else
sendtohttp 192.168.0.243,8080,/json.htm?param=switchlight&type=
command&idx=304&switchcmd=Off
endif
endon
on Nextion#idx=230 do
sendtohttp 192.168.0.243,8080,/json.htm?param=udevice&type=
command&idx=79&nvalue=0&svalue=[Nextion#value]
endon
With the code below, you can now also send values.
As for now I distinguish |u for update and |s for switch
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?
Re: Nextion display plugin
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.
But to get help you should provide more information about the infrastructure you are using.
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
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.
Re: Nextion display plugin
Is the Nextion connected to the same device which is switching the lights or are these two different devices? Or are the lights switched by three different devices?
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
OK, lets go.
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 your Wemos enable rules, too.
Define a rule on your Wemos:
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:
Code: Select all
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
Define a rule on your Wemos:
Code: Select all
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
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
Wiki, Thanks for the rules, after a lot of trying it works for 90%Wiki wrote: ↑14 Nov 2018, 14:48 OK, lets go.
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 your Wemos enable rules, too.Code: Select all
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
Define a rule on your Wemos:
These two rules should change the state of the switch in domoticz as well as the state of your button in Nextion.Code: Select all
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
On the Nextion i have a button on page0 with objname bt0 and vscope global, Touch Release Event Send Component ID active.
This is what i see on my Wemos, the second Sendto is a switch I made for control.
692784: EVENT: RelayState=0
1692798: ACT : SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=0
1692812: ACT : SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,0
1710719: EVENT: RelayState=1
1710735: ACT : SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=1
1710752: ACT : SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,1
It's sends a state but the color of the button didn't change, also the state of the switch didn't change.
When i send in the browser: http://192.168.178.127/control?cmd=NEXT ... .bt0.val=0 of http://192.168.178.127/control?cmd=NEXT ... .bt0.val=1
The colors are changing. Did you maybe have a solution for this behavior?
Re: Nextion display plugin
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:
If I have misunderstood how things are wired then please ignore my comments.
- Thomas
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:
Code: Select all
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
- Thomas
Re: Nextion display plugin
Hello ThomasB, thanks your answer. Instead of the ESP01 i use a Sonoff Pow for testing.ThomasB wrote: ↑17 Nov 2018, 19:07 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:If I have misunderstood how things are wired then please ignore my comments.Code: Select all
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
- Thomas
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¶m=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¶m=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
Maybe it's so a litle bit clear for you.
Re: Nextion display plugin
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.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
As one example, on the Nextion Wemos device you would replace this rule line:
Code: Select all
SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=0
Code: Select all
NEXTION,page0.bt0.val=0
Code: Select all
SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,0
SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,1
- Thomas
Re: Nextion display plugin
ThomasB, thanks for the tips. It let me learn more about rules.ThomasB wrote: ↑17 Nov 2018, 20:58I 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.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
As one example, on the Nextion Wemos device you would replace this rule line:with this:Code: Select all
SendToHTTP 192.168.178.127,80,/control?cmd=NEXTION,page0.bt0.val=0
Also, what is the reason for these two rules on the Wemos Nextion (IP 192.168.178.127) that are sent to itself?Code: Select all
NEXTION,page0.bt0.val=0
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.Code: Select all
SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,0 SendToHTTP 192.168.178.127,80,/control?cmd=GPIO,12,1
- Thomas
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
Then I can use the Nextion as a Remote Control.
Re: Nextion display plugin
OK, the rules on the ESP12/Sonoff seem to be correct.
On your Nextion the Touch Release event should look like something like this:
The term "i99" is interpreted by the Nextion plugin of ESPEasy as Nextion#idx
So on your Wemos you need these rules:
Should work...
On your Nextion the Touch Release event should look like something like this:
Code: Select all
if(bt0.val==0)
{
print "|s,i99,sOff"
printh 0a
}else
{
print "|s,i99,sOn"
printh 0x0a
}
So on your Wemos you need these rules:
Code: Select all
on Nextion#idx=99 do
if [Nextion#value]=1
SendToHTTP 192.168.178.126,80,/control?cmd=gpio,12,1
else
SendToHTTP 192.168.178.126,80,/control?cmd=gpio,12,0
endif
endon
On RelayState do
if %eventvalue%=0
NEXTION,page0.bt0.val=0
else
NEXTION,page0.bt0.val=1
endif
endon
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
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.
Code on Sonoff Pow:
Code on Wemos with Nextion:
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.
Code on Sonoff Pow:
Code: Select all
On Relay#State do
if [Relay#State]=0
SendToHTTP 192.168.178.53,8080,/json.htm?type=command¶m=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¶m=udevice&idx=1534&nvalue=1&svalue=1
SendToHTTP 192.168.178.127,80,/control?cmd=event,RelayState=1
endif
endon
Code: Select all
on Nextion#idx=99 do
if [Nextion#value]=1
SendToHTTP 192.168.178.126,80,/control?cmd=gpio,12,1
else
SendToHTTP 192.168.178.126,80,/control?cmd=gpio,12,0
endif
endon
On RelayState do
if %eventvalue%=0
NEXTION,page0.bt0.val=0
NEXTION,bt0.txt="Off"
else
NEXTION,page0.bt0.val=1
NEXTION,bt0.txt="On"
endif
endon
Re: Nextion display plugin
Well for me it looks like a misbehaviour of the dual state button - hard to say without knowing the protocol of the wemos, but possible.
Let's try to get full control of the buttons behaviour in Nextion by the wemos.
So replace the dual state button in Nextion by a normal one. If its the first button it will be named b0 (instead of bt0 as name of a dual state button)
Add a variable to the page. If its the first variable it will be named va0.
In the following example codes replace the object names I am assuming by the correct names.
In the touch release event of the button place the action:
Define the following rules in the wemos:
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.
Let's try to get full control of the buttons behaviour in Nextion by the wemos.
So replace the dual state button in Nextion by a normal one. If its the first button it will be named b0 (instead of bt0 as name of a dual state button)
Add a variable to the page. If its the first variable it will be named va0.
In the following example codes replace the object names I am assuming by the correct names.
In the touch release event of the button place the action:
Code: Select all
if(va0.val==0)
{
va0.val=1
print "|s,i99,sOn"
printh 0a
}else
{
va0.val=0
print "|s,i99,sOff"
printh 0x0a
}
Code: Select all
On Nextion#idx=99 do
if [Nextion#value]=1
SendToHTTP 192.168.178.126,80,/control?cmd=gpio,12,1
else
SendToHTTP 192.168.178.126,80,/control?cmd=gpio,12,0
endif
endon
On RelayState do
if %eventvalue%=1
NEXTION,page0.b0.txt="On"
NEXTION,page0.b0.bco=1024
NEXTION,page0.va0.val=1
else
NEXTION,page0.b0.txt="Off"
NEXTION,page0.b0.bco=48631
NEXTION,page0.va0.val=0
endif
endon
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
Re: Nextion display plugin
Thanks Wiki,
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.
Thanks for your help, it was a learning period for me.
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.
Thanks for your help, it was a learning period for me.
Re: Nextion display plugin
You're welcome, good to hear it works.
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.
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.
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Nextion display plugin
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".Wiki wrote: ↑21 Nov 2018, 18:19 You're welcome, good to hear it works.
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.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Nextion display plugin
+1: Hardware serial.
Hardware serial is needed for ESPEasy to reliably receive Nextion touch screen button presses. If the Nextion is only used as a display (touch feature not used) then soft serial is fine.
- Thomas
Hardware serial is needed for ESPEasy to reliably receive Nextion touch screen button presses. If the Nextion is only used as a display (touch feature not used) then soft serial is fine.
- Thomas
Re: Nextion display plugin
i used from the beginning a hard serial with GPIO13 and GPIO15.Wiki wrote: ↑21 Nov 2018, 18:19 You're welcome, good to hear it works.
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.
Who is online
Users browsing this forum: No registered users and 1 guest