I’m waiting for this feature too, but at the moment it is not supported (to my knowledge).
This requires ‘sensor’ support, which is not available (yet, just ‘binary sensor’).
See here: Nextion Slider is unusable #412
As a work around I used 10 binary sensors (10 steps of the slider f.i.), if 10 steps are OK.
OK, there are two parts where you have to code, the Nextion side (for this you use the Nextion Editor) and the ESPHome side (where you configure using yaml).
Let’s start with the Nextion side:
In the example below I use one slider component which is called hShort.
Configure the slider with minval=0 and maxval=9.
When you select this component in the Nextion Editor you should see the ‘Event’ tab (at the bottom).
In my case I use the ‘Touch Release Event’ to send the value of the slider to ESPHome:
The first byte (all in HEX) (65) stands for ‘Touch Event’, the second (00) is the page ID, the next is the component ID (here from 17 to 20) and then comes the event type (01-press, 00-release). The end of the message is always FF FF FF.
So, actually I use here the Release Event to send a Press event to ESPHome to fire the according Binary Sensor (see yaml below).
On the ESPHome side the corresponding part looks like this:
As you can see, I use this to control a Roller Shutter. 10 steps for the slider are good enough for me for this purpose. Also the ‘Release Event’ is appropriate here.
If you want to control light (dim) you may want to play with the ‘Touch Move’ event on the Nextion side.
Let me know if this works, I didn’t try.
Also make sure that the component IDs which you use in the ‘printh’ message on the Nextion side matching those ones on the ESPHome side (Nextion: Hex, ESPHome: Decimal , f.i. 17 --> 23) and that you do not use them elswhere.
Good morning, I’m testing the next beta. And I have to say I’m delighted. Now with a single sensor, we can use the sliders. Update the TFT via wifi, wonderful. I’m super happy. This update takes the Nextion screen to another dimension. Best regards.