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

Haven’t really followed this thread in a while but it turns out that if you don’t use the AC/relay circuitry you can add i2c devices!

DFRobot i2c adc + mic = completely unnecessary loudness waveform.

2 Likes

Hi there those values are not used in the firmware and not correct you can ignore those temp values. if you want values to show on your panel just put a temp sensor entity from home assistant in the APP config like

image

if you want the temp value from the NSPanel in home assistant to use them as room temp you should look to see if those values are correct with ESPhome firmware because with tasmota these temp values are useless. or you need to find out how mutch off they are and set an offset or something.

acutally you can calibrate the temp sensor on tasmota with the following command, I guess it’s already mentioned a few times on this giant thread, play with the second parameter to get it right (however the temp sensor still sucks and has different values depending on the screen brightness)

adcparam 2,15880,10000,3950

If you want to have it in fahrenheit, you can change it with SetOption8

https://tasmota.github.io/docs/Commands/#setoptions

I’ve added the unit to the value with a customize yaml, but I think they also added an way to do to this in the UI with one of the recent versions.

sensor.nsp_kueche_analog_temperature1:
  unit_of_measurement: "°C"
  device_class: temperature
  state_class: measurement

I sent these values through Tasmota Console:
adcparam 2,14600,10000,3950
and now my NSPanel temperature sensor is calibrated and shows correctly the room temperature.

I think I have made some progress in getting reducing the number of sensors in ESP-Home.

I have now managed to create a sensor that holds the last clicked component.


(the above image is slightly fake since the state is removed again when releasing the button)

I haven’t done any changes in ESP-Home yet, this has been a few days of trail and error and now it’s very late friday and I need to step away from the computer.

I created a variable as text and global:
image

On the hotspot touch press event I added:

va0.txt="19"

If there is a way to get “me.component.id” then I would be very happy, but this is as far as I have come with hotspot 19.

on release event:

va0.txt=""

in ESP-Home I added a text sensor to read the variable:

text_sensor:
  - platform: nextion
    nextion_id: disp1
    name: $device_name last click va
    id: disp1_last_click_va
    update_interval: 100ms
    component_name: va0

And now I believe with this we can more all the button click actions to HA instead of doing it in ESP-Home.

nice :+1::+1:. I’m very nearly finished doing my version 2. I’ve done quite a bit of work with swapping images within the nextion editor rather than in the yaml too.

edit: i can read the current.pic value in the on press or on release like this.

if (p0.pic==1)
{
p0.pic=2
}

i use it to swap images on my scene and playlist buttons. i select a button and it swaps the off state image for that scene button and also changes all other scene buttons to off images.

Interesting.
But you can’t get the actual state right?
I mean if you activate a scene/light from elsewhere they will be out of sync?

I have an NS Panel flashed with Tasmota and wondering how I can adjust the timezone now that the clock have gone forward. (i’m living in the UK).

I tried the Timezone +1 command on the Tasmota console but the time is still an hour behind.

why not using dual-state buttons?

no you can’t get the state from ha but for instances that you don’t need a state but want an image changing on press etc, I’ve created scense that are only for these switches so it works for this user case.

I don’t use scenes. I have never bothered to learn the benefits of them.

But I can happily say that this workaround works perfectly fine.
I have now moved most of my yaml from ESP-Home to HA using the current page sensor and the variable to capture the last click.

So to recap. in ESP-Home add this:

sensor:
  - platform: nextion
    name: $device_name Current display page
    id: disp1_current_page
    variable_name: dp
    update_interval: 1s

text_sensor:
  - platform: nextion
    nextion_id: disp1
    name: $device_name last click va
    id: disp1_last_click_va
    update_interval: 100ms
    component_name: va0

In nextion on each page, add a variable and change it to global, and text.
In each component that you want to track the click on add touch press event:

va0.txt="20" // component ID or component name/description or whatever you want.
// It's used in HA automation later to trigger the action when this button is pressed.

In the Touch release event:

va0.txt=""

Upload the TFT and the ESP-Home yaml.
In HA you should now have two entities that displays the current page, and the clicked component.

Home Assistant automation yaml:

alias: ns panel kitchen actions
description: ''
trigger:
  - platform: state
    entity_id: sensor.ns_panel_last_click_va
condition: []
action:



# page 2 "Lights"
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.ns_panel_current_display_page
            state: '2.00'
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '17'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.kokslampa
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '18'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.sonoff_1000cb7905
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '19'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.taklampan
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '20'
                sequence:
                  - service: switch.toggle
                    data: {}
                    target:
                      entity_id: switch.hallen
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '21'
                sequence:
                  - service: switch.toggle
                    data: {}
                    target:
                      entity_id: switch.blitzwolf_1
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '22'
                sequence:
                  - service: switch.toggle
                    data: {}
                    target:
                      entity_id: switch.blitzwolf_2
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '23'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.matildas_lampa
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '24'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.davids_lampa
            default: []
    default: []




# page 8 "Lights2"
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.ns_panel_current_display_page
            state: '8.00'
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '17'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.skapen
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '18'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.dummy
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '19'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.dummy
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '20'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.dummy
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '21'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.dummy
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '22'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.dummy
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '23'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.dummy
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '24'
                sequence:
                  - service: light.toggle
                    data: {}
                    target:
                      entity_id: light.dummy
            default: []
    default: []



# page 13 "Thermostat"
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.ns_panel_current_display_page
            state: '13.00'
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '6'
                sequence:
                  - service: input_text.set_value
                    data:
                      value: climate.vardagsrum
                    target:
                      entity_id:
                        - input_text.ns_kitchen_temp
                  - service: esphome.ns_kitchen_send_command
                    data:
                      cmd: Thermostat.kitchen.pic=43
                  - service: esphome.ns_kitchen_send_command
                    data:
                      cmd: Thermostat.matilda.pic=51
                  - service: esphome.ns_kitchen_send_command
                    data:
                      cmd: Thermostat.david.pic=49
                  - service: esphome.ns_kitchen_send_command
                    data:
                      cmd: Thermostat.sovrum.pic=47
            default: []
          - choose:
              - conditions:
                  - condition: state
                    entity_id: sensor.ns_panel_last_click_va
                    state: '7'
                sequence:
                  - service: input_text.set_value
                    data:
                      value: climate.matilda
                    target:
                      entity_id:
                        - input_text.ns_kitchen_temp
                  - service: esphome.ns_kitchen_send_command
                    data:
                      cmd: Thermostat.kitchen.pic=42
                  - service: esphome.ns_kitchen_send_command
                    data:
                      cmd: Thermostat.matilda.pic=50
                  - service: esphome.ns_kitchen_send_command
                    data:
                      cmd: Thermostat.david.pic=49
                  - service: esphome.ns_kitchen_send_command
                    data:
                      cmd: Thermostat.sovrum.pic=47
            default: []
    default: []
mode: single

I’m not done yet but I figured this would be enough to see the pattern on how to do it.

Deleting all buttons from ESP-Home yaml went from 68.6 → 67.3% :muscle:

2 Likes

that’s great work :ok_hand:. I’m going to upload my finished project to GitHub and then have a play with this approach. does the 100ms update have any bad effects??

can you call. on_value in that text sensor?

I suppose you could, what are you planning?

But I don’t notice much difference with this compared to the traditional way with binary sensors.

But of course a real “fix” is probably better. Doing a proper sensor in the nextion integration will probably work much better.

I found some more stuff I could move and got down to 66.0% if I recall correctly

Hi,

Every time I try to change my TFT file on my NSPanel. The upload crash randomly, sometime at 27% or 64%.

Anybody know why it can happen ?

Also what is the maximum size for the TFT file ?

Thank you all

16mb is the max size.

edit: mine sometimes crashes when it trys to do the quick update (only uploads the changes). i just add a random image in the editor and it then forces it to do a full upload. there is an edit you can make in the nextion esphome components to make it always do the full update but i found it not to work (maybe my esphome component got updated :woman_shrugging:) but either adding an image or deleting one forces full anyway so i just do that.

1 Like

I’ve got something in my config that is not letting it connect to HA. it’s connected to wifi fine, i can flash it fine and it shows online in esphome. but nothing else. I’m not near 68.4% either. all code now in my config has worked fine before but now it sits in this state not connected for upto 20 minutes before it finally connects. time to hook it back up to the pc and hopefully find out whats going on.

That hasn’t happened to me.
Only breaching the limit and having to open it up again.

I did have an issue with when I added manual IP on it, by some reason it didn’t like that.

nextion buffer overflow

If you want to keep the number of ESPHome sensors to a minimum and offload the processing to Home Assistant, then you might be interested in a conceptually similar approach that is working very well for me using a Python script to provide a service so that you can program Home Assistant instructions directly into your HMI code (without any custom YAML programming in ESPHome or HA). I use just 4 ESPHome sensors:

  • 2 text/string sensors that each Nextion page uses to tell HA what data it wants (and which HA data to assign to which Nextion variables);
  • 1 text/string that Nextion events use to send instructions to HA as to what actions they want HA to perform (switching lights, running scripts etc.); and
  • 1 trigger sensor that tells the Home Assistant automation when to run the Python script and which instructions (coded in the above strings) to execute.
    (There is some standard boilerplate code that does all the background work to send and execute your strings of coded instructions - just use a page from an example HMI as a template.)

Check the GitHub page if you are interested:

Even if you aren’t interested in the Python service approach, the example HMI files have a very robust implementation of ‘swipe’ and ‘press’ gestures (that work reliably even on pages completely covered in hotspots, and the gestures automatically disable for any touches that start on a slider - to prevent conflicts).

6 Likes