Sonoff NSPanel by ITead - Smart Scene Wall Switch based on ESP32 and custom Nextion Touch Screen Panel Display (non-Pro variant)

Thanks. I’m only just starting with Nextion so lots to learn (eg I was unaware of the sleep statement). I did want to use the built-in sleep settings but I’ve given up (for now).

I’ve got something working which seems to do what I want. When the timer expires, it takes the nspanel to a blank page with nothing on it. In this way, when it’s woken up by a touch event nothing is activated but it goes to the “home” page. The sequence is roughly as so:

  • I have a timer on my front page that when it expires sets sleep=1,page Blank and my timer’s .en attribute to 0.
  • On the blank page I have a TouchCap which:
    – for the touch press event wakes the screen with sleep=0
    – for the touch release event simply redirects to page Home
  • The Home page Postinitialize event sets my timer’s .en attribute to 1.

There are probably better ways of doing this so any recommendations welcome.

I’ve a couple of issues I’m wondering how to resolve:

  • Is there any way of setting the .tim attribute using a variable so I can change it universally (I’m anticipating having the same timer on every page and I don’t want to have to edit each one when I change it)?
  • I’m using the nspanel physical buttons to switch on/off some lights. At the moment these work with the display blank. I’d prefer that, if the screen is blank, pressing either of these buttons would activate the screen (as I have a visual indicator of the state of the lights) and then another press is needed to switch the light on/off. If the screen is active, then only a single press should be needed.

I followed your approach and interestingly, when sending the display to sleep with usup=0, I need to send sleep=0 in order to wake it (sleep=0ÿÿÿ doesn’t work).

Thank you for all the pointers btw!

I need to send sleep=0 in order to wake it (sleep=0ÿÿÿ doesn’t work).

Yes, if you are sending instructions via ESPHome’s Nextion send_command() or send_command_printf(), then it already adds the termination string required by the Nextion (hex: “0xFF, 0xFF, 0xFF” = print(“ÿÿÿ”)), so don’t add it again (as per the HA automation YAML example above - now edited to make that clearer). That goes for ALL Nextion Instructions being sent from ESPHome or Home Assistant, not just sleep.

I fear that I may have broken my NSPanel. I tried to implement a custom UI via ESPHome but now the screen is blank apart from the words System Data ERROR! Has anyone had any experience with this?

This should not be a problem, you should still be able to flash an UI / tft file.

System data Error - Unofficial Nextion/TJC User Forum

I tried flashing directly to the Screen from Nextion Editor and was not successful. I have not been able to resolve this yet and since there is no SD card access not sure how to fix yet. Mine does not connect to the Wifi. Might be bricked

It was the same for me as well. ESPHome always failed with the upload. It was not able to upload the TFT file to the display.
I had to change to Tasmota, which was able to do the upload.

mine doesn’t upload a new hmi file unless I 1st flash it with a masto’s basic esphome config, there must be something in my yaml file preventing it uploading (it just restarts the ui and never gets to upload). a work around i use is to flash the basic demo config, calling for my new hmi file, this works and installs the new hmi, then i c&p my new esphome config and flash it and all works well. hope this helps.

my hmi and yaml are edited versions of marcfago’s work.

i want to add a page for swiping up or down but can’t work out how the swipe function works. if anyone can give me a simple explanation on how to implement new pages I’d appreciate it.
Thanks all for your work on the project. :grin:

I’ve also had the same problem. I’ve spent a lot of time trying multiple ways of getting round it and trying to find the cause. But I’ve come to the same conclusion as you. That the ESP has too much to do when it’s booting up.

I’ve found a way round it, at least for the amount of entries I’ve tried so far. By moving the action part of the code from the text_sensor: part of the ESP code to a lambda entry at the end of the code under the display: section I have been able to add more text_sensor entries without causing the NS panel to continuously reboot.

For example by changing this text_sensor entry from :-

    id: our_status
    entity_id: climate.wiser_our_bedroom
    attribute: hvac_action
    on_value:
      then:
        - wait_until:
            switch.is_on: nextion_init
        - lambda: id(disp1).set_component_text_printf("Rooms.status5", "%s", id(our_status).state.c_str());

To a text_sensor entry of

  - platform: homeassistant
    id: our_status
    entity_id: climate.wiser_our_bedroom
    attribute: hvac_action

and then putting this part of the code under the display section

id(disp1).set_component_text_printf("Rooms.status5", "%s", id(our_status).state.c_str());

and doing the same for the other text_sensor entries I have been able to add all the text_sensor entries I need for now.

This has the disadvantage that, although Home Assistant reacts immediately to the button press, the state of the NS panel button or icon doesn’t change state for about 3 seconds after pressing the button as it has to wait for Home Assistant to send it the state change.

The advantage is that if Home Assistant doesn’t receive the button press information the NS panel state doesn’t change either.

Hopefully this information will save other people wasting time trying to cure the no boot problem. Or they may come up with a better cure!

1 Like

i will look into this later a little more… has anyone worked out the exact viewable screen yet and the touch offset (eu model)?? I’ve read this thread and see a post by masto regarding code in the program.s section “lcd_dev fffb 0002 0000 0020”. does this mean after putting this in we don’t have to offset the touch in our ui’s? ie can we now align everything as it should be within the nextion editor?.

Known issue, thsp does not work on NSPanel.

3 Likes

Swiping is another thing that doesn’t work the same on these as on a regular Nextion panel. Possibly when they altered it for capacitive touch they changed something.

In any case, folks have figured out ways to simulate swipe detection. There’s a link on the Wiki to a Discord discussion and example.

2 Likes

perfect, thanks masto your a star. i will try these fixes, i thought I’d read all i could before posting but somehow missed that :grin: I’ve been working on mine for a few days now and as i mentioned earlier it’s based on marc’s config and hmi. once I’m happy and have it all in order I’ll put it on github (and link in the wiki)with as much info as possible for others to use. thanks again for your hard work :+1:

For some reason the discord link doesn’t work for me (I get a NO TEXT CHANNELS error message), anything I should be doing?

Thanks for your feedback, shame about sleep not working properly but I’ve worked around it. Other than swipe, the next thing I want to try is a “long tap” option. As an example, under normal behaviour tapping on a light button would toggle it on and off using the release event. However, if I hold my finger on the button for an “extended period”, I’d like to go to a page specifically for the light where I could, say, change the brightness and colour.

I haven’t had time to look into it yet but my thinking is to use a timer started by the press event, for about a second, which, if it expires, would go to the light’s page. However, it would have to stop the release event from toggling the state of the light, is this possible? As I say, I haven’t looked into this yet so it might be easy/hard/impossible!

Hello everyone, Greetings, I’m new to this forum

first of all forgive my english (mr google)

I have an nspanel with ESPhome, and I am making a menu for it, for now everything is coming out, weather, lights (benches), temperatures, etc.

but I got stuck on a screen (attached image)

I have RGBW bulbs (flassed with tasmota) and I would need a sensor (or four) in home assistant, so that it would tell me what color level there is currently, example:

red = 128
green= 10
blue = 210
white = 128
I do not know how to do that.

It is to collect that data and through a send_comand tell each slider (when opening the screen) at what level it has to be.
(I know how to do that)

another question I have is the opposite, if I modify the sliders, I have a sensor in ESPHome that collects the new value, but… how do I tell home assistant that the value “red=210” be sent to the light bulb ?

forgive this shit.

and thank you very much in advance

1

I don’t know, I thought a link to a message would prompt you to join if necessary. Information has a way of spreading out across different sites and threads so I just try to link to the source when possible. Anyway, this is what it says.

  1. Create a touchcap which on press stored tch0 and started the timer
  2. On release does:
tm0.en=0
if(tch0==0)
// When this is zero we can interpret that as the real end of the drag event
{
  va0.val=va1.val-va2.val
  if(va0.val>125)
  {
    page page1
  }else if(va0.val<-125)
  {
    t11.txt="left"
  }
}
  1. The timer does
if(tch0!=0)
{
  va2.val=tch0
}

Disclaimer: I just copied and pasted that… I haven’t even read it, let alone know how it works. So I definitely can’t offer any further help with it.

Hello denes44,

May I ask, how can I upload HMI file through Tasmota? Could you provide the link?
Thank you in advance.

i want to add a page for swiping up or down

A very simple and efficient way of implementing swipes is to have ‘edge swipes’ (that work when you swipe from the bezel into the LCD panel).
Simply put a narrow ‘Hotspot’ component down the edge(s) of the display you want to swipe from.
I’ve calibrated my display and it registers an edge swipe within 4 to 5 pixels, so I’ve made the edge hotspots 7 pixels wide (to add some margin). Make sure to raise them to the top layer of each page. Then set the ‘Touch Press’ of the hotspot to what you want it to do (probably change page).
This is very efficient on screen real-estate because the entire rest of the screen can then have touch-active events linked to it (which I haven’t been able to reliably accomplish using Timer + TouchCap (tc0) - although I’m now combining the two approaches to give long-press button functionality too.)
The only thing you have to be careful of with this approach is not touch too close to the edge of the screen when pushing buttons (stay 1mm ~7px away from the edge unless swiping).

1 Like

This project has file (nxpanel.be) which can do it.