Esphome & nextion tft lcd

ok, can be done. in the editor need to set “isbr” to true.

1 Like

Question is now black (burned) :slight_smile:

Dear People, I have a problem with my esphome configuration with an nextion display. Actually I have it completely working, only I get an annoying message. I use a number of sensors that I want to show on page 3. Now I have the config so that this also happens. But if I am now on a different page then I get a warning (yellow) in my log from my esphome (see attachment). I expect to somehow have to point my sensors to page3 but I just don’t know how to do this. i hope you can help me with this.

CODE ESPHOME
uart:
rx_pin: D9
tx_pin: D10
baud_rate: 9600

display:

  • platform: nextion
    update_interval: 1s
    lambda: |-
    it.set_wait_for_ack(false);

                auto time_text = id(sntp_time).now().strftime("%X");
                it.set_component_text("text_time", time_text.c_str());
                auto date_text = id(sntp_time).now().strftime("%x");
                it.set_component_text("text_date", date_text.c_str());
                auto week_text = id(sntp_time).now().strftime("%W");
                it.set_component_text("weeknr", week_text.c_str());          
                auto time = id(sntp_time).now();
    
    
             it.set_component_text_printf("hour","%02d",time.hour);
             it.set_component_text_printf("minut","%02d",time.minute);     
             it.set_component_text_printf("outside","%2.1f", id(temp).state);
             it.set_component_text_printf("vocht","%2.1f", id(vocht).state);
             it.set_component_text_printf("rain","%2.1f", id(rain).state);       
             it.set_component_text_printf("lux","%2.1f", id(lux).state);
             it.set_component_text_printf("luxin","%2.1f", id(lux_woonkamer).state);
             it.set_component_text_printf("vochtin","%2.1f", id(hum_woonkamer).state);
             it.set_component_text_printf("inside","%2.1f", id(temp_woonkamer).state);  
    

time:

  • platform: sntp
    id: sntp_time

sensor:

  • platform: homeassistant
    id: temp
    entity_id: sensor.sensor_box_am2301_13_temperature

  • platform: homeassistant
    id: vocht
    entity_id: sensor.sensor_box_am2301_13_humidity

  • platform: homeassistant
    id: rain
    entity_id: sensor.tfa_80_0c_rain_total

  • platform: homeassistant
    id: lux
    entity_id: sensor.sensor_box_bh1750_illuminance

  • platform: wifi_signal
    name: “WiFi signal HMI”
    update_interval: 60s

  • platform: hdc1080
    temperature:
    name: “Temp_woonkamer”
    id: temp_woonkamer
    humidity:
    name: “Humidity_woonkamer”
    id: hum_woonkamer
    update_interval: 5s

  • platform: bh1750
    id: lux_woonkamer
    name: “BH1750_lux_woonkamer”
    address: 0x23
    measurement_time: 69
    update_interval: 5s

i2c:
sda: D2
scl: D1
scan: False

binary_sensor:

  • platform: nextion
    page_id: 1
    component_id: 3
    name: “hmi_rolluik_keuken_omhoog”

  • platform: nextion
    page_id: 1
    component_id: 6
    name: “hmi_rolluik_keuken_omlaag”

  • platform: nextion
    page_id: 1
    component_id: 4
    name: “hmi_rolluik_straat_omhoog”

  • platform: nextion
    page_id: 1
    component_id: 8
    name: “hmi_rolluik_straat_omlaag”

  • platform: nextion
    page_id: 1
    component_id: 5
    name: “hmi_voordeur_omhoog”

  • platform: nextion
    page_id: 1
    component_id: 7
    name: “hmi_voordeur_omlaag”

  • platform: nextion
    page_id: 4
    component_id: 3
    name: “100%nl”

  • platform: nextion
    page_id: 4
    component_id: 5
    name: “Qmusic”

  • platform: nextion
    page_id: 4
    component_id: 6
    name: “538”

  • platform: nextion
    page_id: 4
    component_id: 4
    name: “woonkamer_speaker_uit”

  • platform: nextion
    page_id: 4
    component_id: 10
    name: “volume_12”

  • platform: nextion
    page_id: 4
    component_id: 9
    name: “volume_14”

  • platform: nextion
    page_id: 4
    component_id: 8
    name: “volume_16”

  • platform: nextion
    page_id: 4
    component_id: 7
    name: “volume_18”

switch:

  • platform: restart
    name: “Reset HMI”

  • platform: shutdown
    name: “Uitschakelen HMI”

output:

  • platform: esp8266_pwm
    pin: D8
    id: pwm_output

light:

  • platform: monochromatic
    output: pwm_output
    name: “buzzer”

WARNINGS
[23:58:09][D][nextion:209]: Got touch page=3 component=1 type=PRESS
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!

Please format all your code correctly.

What do you mean ?

Hi!
I’m trying to display the state of the binary sensor ON and OFF, I can’t display it on the screen, I’ve tried various options but unsuccessfully.

sensor:
  - platform: homeassistant   # Kitchen window
    id: win_kitchen
    entity_id: sensor.window_kitchen

and

display:
  - platform: nextion
    id: teplomer
    update_interval: 5s
    lambda: |-
               it.set_component_text_printf("winkitchen","%",id(win_kitchen).state);

I try %s (String of characters) but nothing. How to print binary state of sensor?
Log of esphome [00:15:32][W][homeassistant.sensor:014]: Can’t convert ‘ON’ to number!

P.S. It is work i understand

text_sensor:
  - platform: homeassistant   # Kitchen window
    id: win_kitchen
    entity_id: sensor.window_kitchen

and 
   it.set_component_text_printf("winkitch","%s",id(win_kitchen).state.c_str());            

I try to get mine to work but I got error from the esphome log screen “received unknown filler end bytes from Nextion!”. What did I do wrong? I check all the examples but unable to get it to work with esphome.

On the esphome long it showed message of “Sending command ‘t0.txt=Hellooo’ failed because no ACK was received … : Waiting for ACK timed out!” but nothing on the display. I flip the tx and rx but still same result.

I’m plugging my nextion PR for esphome.

It has a ton of improvements, including tft Ota. We are working hard on getting this merged.

7 Likes

Been following what your are doing and thanks for that.
Will the documentation also be updated?

There is a PR for it and will be updated once we get closer to merging. I actually am planning on updating it soon though.

2 Likes

Hi!
Did you solve this?

Hi, long time no see. After a few updates of a lot of stuff further my text sensor is not properly filled anymore in the display. Also I get errors but I do not know what they mean. Anyone able to direct?

[12:40:46][C][api:143]:   Using noise encryption: NO
[12:40:46][C][homeassistant.text_sensor:023]: Homeassistant Text Sensor 't10_text'
[12:40:46][C][homeassistant.text_sensor:024]:   Entity ID: 'sensor.nextiont0_text'
[12:40:46][C][homeassistant.text_sensor:023]: Homeassistant Text Sensor 'dim_text'
[12:40:46][C][homeassistant.text_sensor:024]:   Entity ID: 'sensor.nextiondim_text'
[12:40:46][C][homeassistant.text_sensor:023]: Homeassistant Text Sensor 'uart_text'
[12:40:46][C][homeassistant.text_sensor:024]:   Entity ID: 'sensor.nextion_uart'
[12:40:49][E][nextion:1107]: This command is deprecated
[12:40:49][V][component:199]: Component nextion.display took a long time for an operation (0.08 s).
[12:40:49][V][component:200]: Components should block for at most 20-30ms.
[12:40:49][W][nextion:395]: Nextion reported variable name invalid!
[12:40:54][E][nextion:1107]: This command is deprecated
[12:40:54][V][component:199]: Component nextion.display took a long time for an operation (0.08 s).
[12:40:54][V][component:200]: Components should block for at most 20-30ms.
[12:40:54][W][nextion:395]: Nextion reported variable name invalid!
[12:40:59][E][nextion:1107]: This command is deprecated
[12:40:59][V][component:199]: Component nextion.display took a long time for an operation (0.08 s).
[12:40:59][V][component:200]: Components should block for at most 20-30ms.
[12:40:59][W][nextion:395]: Nextion reported variable name invalid!
[12:41:04][E][nextion:1107]: This command is deprecated
[12:41:04][V][component:199]: Component nextion.display took a long time for an operation (0.08 s).
[12:41:04][V][component:200]: Components should block for at most 20-30ms.
[12:41:04][W][nextion:395]: Nextion reported variable name invalid!
[12:41:09][E][nextion:1107]: This command is deprecated
[12:41:09][V][component:199]: Component nextion.display took a long time for an operation (0.08 s).
[12:41:09][V][component:200]: Components should block for at most 20-30ms.
[12:41:09][W][nextion:395]: Nextion reported variable name invalid!

What command is deprecated?

I believe this is relevant:

uart:
  rx_pin: D7
  tx_pin: D5
  baud_rate: 9600

display:
  - platform: nextion
    lambda: |-
      it.set_wait_for_ack(false);
      it.set_component_text("t10", id(t10_text).state.c_str());

text_sensor:
  - platform: homeassistant
    id: t10_text
    entity_id: sensor.nextiont0_text
  - platform: homeassistant
    id: dim_text
    entity_id: sensor.nextiondim_text
  - platform: homeassistant
    id: uart_text
    entity_id: sensor.nextion_uart

There must be more code.
The log says you are asking for a variable from nextion that does not exist.

This is all regarding nextion

uart:
  rx_pin: D7
  tx_pin: D5
  baud_rate: 9600

display:
  - platform: nextion
    lambda: |-
      it.set_wait_for_ack(false);
      it.set_component_text("t10", id(t10_text).state.c_str());

text_sensor:
  - platform: homeassistant
    id: t10_text
    entity_id: sensor.nextiont0_text
  - platform: homeassistant
    id: dim_text
    entity_id: sensor.nextiondim_text 
  - platform: homeassistant
    id: uart_text
    entity_id: sensor.nextion_uart

binary_sensor:
  - platform: nextion
    page_id: 0
    component_id: 3
    name: "Nextion.Button.Doorbel"
    id: Nextion_Button_Doorbel
  - platform: nextion
    page_id: 1
    component_id: 2
    name: "Nextion.Button.Package delivered"
  - platform: nextion
    page_id: 1
    component_id: 3
    name: "Nextion.Button.Package not delivered"
  - platform: nextion
    page_id: 2
    component_id: 1
    name: "Nextion.Button.mailbox"
  - platform: nextion
    page_id: 2
    component_id: 2
    name: "Nextion.Button.binbox"
  - platform: nextion
    page_id: 2
    component_id: 3
    name: "Nextion.Button.other"
  - platform: nextion
    page_id: 0
    component_id: 2
    name: "Nextion.Button.watchme"
  - platform: nextion
    page_id: 6
    component_id: 5
    name: "Nextion.Button.delivered37"
  - platform: nextion
    page_id: 6
    component_id: 6
    name: "Nextion.Button.delivered8"
    
switch:
  - platform: uart
    name: "dim1"
    data: 'dim=1'
  - platform: uart
    name: "dim20"
    data: 'dim=20'
  - platform: uart
    name: "dim100"
    data: 'dim=100'
  - platform: uart
    name: "dimsave"
    data: [0xFF, 0xFF, 0xFF]

These are the nextion variables, make sure all is still in the tft/hmi file

100% all is in. It used to work when I made it at that time. No errors then.

But what does these mean:
[13:53:56][E][nextion:1107]: This command is deprecated
[13:53:56][V][component:199]: Component nextion.display took a long time for an operation (0.08 s).
[13:53:56][V][component:200]: Components should block for at most 20-30ms.
[13:53:56][W][nextion:395]: Nextion reported variable name invalid!

First three don’t know for sure.
The last one is that the ESP is asking for a variable that is not there or not global.

My guess is that the fourth one is the reason for the other three.

Ok, but how do I discover what command is deprecated then?