ESPHome + nextion + homeasistant get nan value

Hello :slight_smile:

i want to create display for some sensors from HA using nextion display and esp8266 d1 mini v2 and esphome api.

I wrote my yaml code by modifying:
GitHub - bruxy70/Home-Assistant-ESPHome-Weather-Station: Nextion display with ESP8266 microcontroller (Wemos D1 mini) showing Home Assistant temperature sensors and weather forecast

but i recive value “nan” from HA sensor. Accordin to my reserch that kind of value apear when esphome node wasn’t added to HA integrations but i did it and nothing heppends…

hire is my extra minimalistic yaml code for esphome node:

esphome:
  name: nextion-display-1
  platform: ESP8266
  board: esp01_1m

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

# Enable Home Assistant API
api:
  password: "****" #passoword was set in HA configuration.yaml
ota:
  password: "*****"  #this pass was auto generated

wifi:
  ssid: "****"
  password: "*****"
  fast_connect: true
  manual_ip:
    static_ip: 192.168.0.173
    gateway: 192.168.0.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Nextion-Display-1"
    password: "M9ZCdnlzkfnP"

captive_portal:

uart:
    rx_pin: GPIO3
    tx_pin: GPIO1
    baud_rate: 9600

sensor:
  - platform: homeassistant # outside temperature
    id: temp_outside
    entity_id: sensor.a4c138360801_humidity   #there was temp sensor but i try another one... i didn't change sensor ID
      
    
display:
  - platform: nextion
    id: myTempNexition
    update_interval: 1s
    lambda: |-                                                #I try different way to display variable
      it.set_component_value("tempoutside",id(temp_outside).state);                   #it's not working even nan value
      it.set_component_text_printf("tempoutside","%f",id(temp_outside).state);    #it's show nan walue
      it.set_component_text_printf("text","text_testowy");                                      #it's show text_testowy on diplay corretly 

and there is log form esphome node in VERBOSE mode:

INFO Reading configuration /config/esphome/nextion-display-1.yaml...
INFO Detected timezone 'Europe/Warsaw'
INFO Starting log output from 192.168.0.173 using esphome API
INFO Successfully connected to 192.168.0.173
[17:58:05][I][app:099]: ESPHome version 2021.10.3 compiled on Oct 27 2021, 17:33:19
[17:58:05][C][wifi:490]: WiFi:
[17:58:05][C][wifi:352]:   Local MAC: 48:3F:DA:48:FB:4F
[17:58:05][C][wifi:353]:   SSID: [redacted]
[17:58:05][C][wifi:354]:   IP Address: 192.168.0.173
[17:58:05][C][wifi:356]:   BSSID: [redacted]
[17:58:05][C][wifi:357]:   Hostname: 'nextion-display-1'
[17:58:05][C][wifi:359]:   Signal strength: -59 dB ▂▄▆█
[17:58:05][C][wifi:363]:   Channel: 11
[17:58:05][C][wifi:364]:   Subnet: 255.255.255.0
[17:58:05][C][wifi:365]:   Gateway: 192.168.0.1
[17:58:05][C][wifi:366]:   DNS1: 0.0.0.0
[17:58:05][C][wifi:367]:   DNS2: 0.0.0.0
[17:58:05][C][uart.arduino_esp8266:095]: UART Bus:
[17:58:05][C][uart.arduino_esp8266:096]:   TX Pin: GPIO1
[17:58:05][C][uart.arduino_esp8266:097]:   RX Pin: GPIO3
[17:58:05][C][uart.arduino_esp8266:099]:   RX Buffer Size: 256
[17:58:05][C][uart.arduino_esp8266:101]:   Baud Rate: 9600 baud
[17:58:05][C][uart.arduino_esp8266:102]:   Data Bits: 8
[17:58:05][C][uart.arduino_esp8266:103]:   Parity: NONE
[17:58:05][C][uart.arduino_esp8266:104]:   Stop bits: 1
[17:58:05][C][uart.arduino_esp8266:106]:   Using hardware serial interface.
[17:58:05][C][logger:233]: Logger:
[17:58:05][C][logger:234]:   Level: VERBOSE
[17:58:05][C][logger:235]:   Log Baud Rate: 0
[17:58:05][C][logger:236]:   Hardware UART: UART0
[17:58:05][C][nextion:117]: Nextion:
[17:58:05][C][nextion:118]:   Device Model:     NX3224T028_011R
[17:58:05][C][nextion:119]:   Firmware Version: 163
[17:58:05][C][nextion:120]:   Serial Number:    DE6784385F572138
[17:58:05][C][nextion:121]:   Flash Size:       4194304
[17:58:05][C][nextion:122]:   Wake On Touch:    True
[17:58:05][C][captive_portal:150]: Captive Portal:
[17:58:05][C][ota:082]: Over-The-Air Updates:
[17:58:05][C][ota:083]:   Address: 192.168.0.173:8266
[17:58:05][C][ota:086]:   Using Password.
[17:58:05][C][api:134]: API Server:
[17:58:05][C][api:135]:   Address: 192.168.0.173:6053
[17:58:05][C][api:139]:   Using noise encryption: NO
[17:58:05][C][sntp:044]: SNTP Time:
[17:58:05][C][sntp:045]:   Server 1: '0.pool.ntp.org'
[17:58:05][C][sntp:046]:   Server 2: '1.pool.ntp.org'
[17:58:05][C][sntp:047]:   Server 3: '2.pool.ntp.org'
[17:58:05][C][sntp:048]:   Timezone: 'CET-1CEST,M3.5.0,M10.5.0/3'
[17:58:05][C][homeassistant.sensor:030]: Homeassistant Sensor 'temp_outside'
[17:58:05][C][homeassistant.sensor:030]:   State Class: ''
[17:58:05][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[17:58:05][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[17:58:05][C][homeassistant.sensor:031]:   Entity ID: 'sensor.a4c138360801_humidity'
[17:58:06][D][api:098]: Accepted 192.168.0.189
[17:58:06][V][api.connection:720]: Hello from client: 'Home Assistant 2021.10.6 (192.168.0.189)'
[17:58:06][D][api:098]: Accepted 192.168.0.189
[17:58:06][V][api.connection:720]: Hello from client: 'Home Assistant 2021.10.6 (192.168.0.189)'
[17:58:07][D][api:098]: Accepted 192.168.0.189
[17:58:07][V][api.connection:720]: Hello from client: 'Home Assistant 2021.10.6 (192.168.0.189)'
[17:58:08][D][api:098]: Accepted 192.168.0.189
[17:58:08][V][api.connection:720]: Hello from client: 'Home Assistant 2021.10.6 (192.168.0.189)'
[17:58:08][D][api:098]: Accepted 192.168.0.189
[17:58:08][V][api.connection:720]: Hello from client: 'Home Assistant 2021.10.6 (192.168.0.189)'
[17:58:09][D][api:098]: Accepted 192.168.0.189
[17:58:09][V][api.connection:720]: Hello from client: 'Home Assistant 2021.10.6 (192.168.0.189)'
[17:58:10][D][api:098]: Accepted 192.168.0.189
[17:58:11][V][api.connection:720]: Hello from client: 'Home Assistant 2021.10.6 (192.168.0.189)'

it’s stop after recive this messages and after 1min this message repeat. On display still I see nan value…

problem solved :smiley:

I just add

api:

to configuration.yaml

If it’s an ESPHome device, you could also add an inexpensive DHT22/AM2302 temperature and humidity sensor and provide the data within the ESPHome device.

But I want read data from more than one point in home.

It’s my new “HMI” project. Anyway it’s work good now :slight_smile:
image