I changed the code a bit, again.
Unfortunately I can still not put it in the ESPEasyPluginPlayGround.
For some reason I cannot upload any more pics, zo, there is a link below.
The changes are that it better communicates with the Nextion.
I adapted the Hollyberry HMI file.
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
}
Under Tough Release Event of down:
va0.val--
if(va0.val<0)
{
va0.val=0
}
cov va0.val,t3.txt,0
print "|u,i230,n,s"
print t3.txt
printh 0a
Under Tough Release Event of b0:
va0.val++
if(va0.val>30)
{
va0.val=30
}
cov va0.val,t3.txt,0
print "|u,i230,n,s"
print t3.txt
printh 0a
With this you get a thermostat that can up and down settings of t3, between 0 and 30.
After update it sends a message to the ESP.
Bt0 now is a toggle switch with which I switch a lamp. Just for testing.
B1 only sends the Component ID, but you cannot distinguish on or off.
Next I have made a textbox component in Domoticz, with idx 310. It gets all the messages from the ESPEasy via the HTML interface. Nice to have as a log device.
Sorry, can’t test it with mqtt or others.
I also have a kaku or coco switch with idx 304 and a zwave Thermostat setpoint with idx 79
This is how I have set up the device in ESPEasy:
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
The code is far far away from perfect, but per haps it persuades to make better code and more functionality.
https://www.dropbox.com/s/bbn4atau9uppf ... n.ino?dl=0