Nextion display text label shows "nan"

Hello,
i am trying to send the temperature from a HA sensor via ESP to my NEXTION display.
The problem is that it shown in the Text label NAN.
Sending static text works fine.

Do you have any idea what I can do?

I´m using the following ESP:

And here my Homeassistant ESP Yaml File

esphome:
  name: nextion_32
  platform: ESP32
  board: esp32dev

wifi:
  ssid: !secret wlan_esp_ssid
  password: !secret wlan_esp_password
  fast_connect: true

# Enable logging
logger:
  baud_rate: 0     # Disable UART logging (pins GPIO1/3 are used for Nextion communication)

# Enable Home Assistant API
api:
  password: !secret ota_pw

ota:
  password: !secret ota_pw
  
  
uart:
    rx_pin: GPIO3
    tx_pin: GPIO1
    baud_rate: 9600

time:
  - platform: sntp
    id: sntp_time

sensor:
  - platform: homeassistant # outside temperature
    id: temp_outside
    entity_id: sensor.netatmo_stonenetti_draussen_temperature

    
display:
  - platform: nextion
    id: myTempNexition
    update_interval: 5s
    lambda: |-
      // Do not wait for ack (this delays the whole procedure a lot, and has no use)
      it.set_wait_for_ack(false);
      
      it.set_component_text_printf("tempoutside","%.0f",id(temp_outside).state);
      it.set_component_text_printf("tempinside","test");
    

Screenshot form the NEXTION Editor config:

Screenshot form the NEXTION display:

The log of my ESP looks following:

INFO Successfully connected to nextion_32.local
[22:08:03][I][app:105]: ESPHome version 1.15.3 compiled on Dec 16 2020, 21:56:10
[22:08:03][C][wifi:443]: WiFi:
[22:08:03][C][wifi:303]:   SSID: 'XXXX[redacted]
[22:08:03][C][wifi:304]:   IP Address: XXXXX
[22:08:03][C][wifi:306]:   BSSID: XXXXX[redacted]
[22:08:03][C][wifi:307]:   Hostname: 'nextion_32'
[22:08:03][C][wifi:311]:   Signal strength: -60 dB ▂▄▆█
[22:08:03][C][wifi:315]:   Channel: X
[22:08:03][C][wifi:316]:   Subnet: XXX
[22:08:03][C][wifi:317]:   Gateway: XXX
[22:08:03][C][wifi:318]:   DNS1: XXX
[22:08:03][C][wifi:319]:   DNS2: XXX
[22:08:03][C][uart_esp32:088]: UART Bus:
[22:08:03][C][uart_esp32:090]:   TX Pin: GPIO1
[22:08:03][C][uart_esp32:093]:   RX Pin: GPIO3
[22:08:03][C][uart_esp32:094]:   RX Buffer Size: 256
[22:08:03][C][uart_esp32:096]:   Baud Rate: 9600 baud
[22:08:03][C][uart_esp32:097]:   Data Bits: 8
[22:08:03][C][uart_esp32:098]:   Parity: NONE
[22:08:03][C][uart_esp32:099]:   Stop bits: 1
[22:08:03][C][logger:185]: Logger:
[22:08:03][C][logger:186]:   Level: DEBUG
[22:08:03][C][logger:187]:   Log Baud Rate: 0
[22:08:03][C][logger:188]:   Hardware UART: UART0
[22:08:03][C][ota:029]: Over-The-Air Updates:
[22:08:03][C][ota:030]:   Address: nextion_32.local:3232
[22:08:03][C][ota:032]:   Using Password.
[22:08:03][C][api:095]: API Server:
[22:08:03][C][api:096]:   Address: nextion_32.local:6053
[22:08:03][C][sntp:039]: SNTP Time:
[22:08:03][C][sntp:040]:   Server 1: '0.pool.ntp.org'
[22:08:03][C][sntp:041]:   Server 2: '1.pool.ntp.org'
[22:08:03][C][sntp:042]:   Server 3: '2.pool.ntp.org'
[22:08:03][C][sntp:043]:   Timezone: 'CET-1CEST-2,M3.4.0/2,M10.5.0/3'
[22:08:03][C][homeassistant.sensor:024]: Homeassistant Sensor 'temp_outside'
[22:08:03][C][homeassistant.sensor:024]:   Unit of Measurement: ''
[22:08:03][C][homeassistant.sensor:024]:   Accuracy Decimals: 1
[22:08:03][C][homeassistant.sensor:025]:   Entity ID: 'sensor.netatmo_stonenetti_draussen_temperature'

Are you certain that your temperature sensor is working? I have an almost identical setup and I see the following in my log each time the temp is updated on the display:

[18:47:46][D][sensor:092]: 'node02temp': Sending state 66.70000  with 1 decimals of accuracy

I was having the same issue and found that the temp sensor I am using (AM2302) would stop working after a reboot. I have to power cycle the sensor after the node reboots to get it to work.

@dwertz is exactly right, the esp does not know what tempoutside is because it has not received a value.

Hi all. Thanks for the reply yes the senor is working in HA:
Bildschirmfoto 2020-12-17 um 13.54.06
Bildschirmfoto 2020-12-17 um 13.53.57

Did you integrate the esphome device into homeassiatant?
If it is not in home assistant it will not send any date and it will be nan.

6 Likes

You are my hero today!!
Thanks a lot this was my stupid mistake. Now it´s running fine.

Had the same some time ago and did take me some time to figure it out

1 Like

Totally missed this as well. Took me a day to find out… :wink: You’re a life saver!

PS It would be so useful if it was possible to integrate devices automatically from the ESPHome interface and not having to manually do this using HA integration and needing to copy paste encryption keys!

I had a same issure and it did not fixe even aftre i turned on HA intigration on esp device. Then I re auth the esphome device with encription key again and Nextion works fine