Esphome & nextion tft lcd

Is it possible to send a text to a nextion display connected to a D1 mini with esphome on it?

I mean to use it as a “frontdoor message” e.g. when the mailman arrives a d I want to send an instant message (via node red e.g.) like “please put package in front of door”?

Or is it mot meant to work like this?

yes, you can do that. You would have to design the Nextion HMI to have a text field on screen, then via serial from the ESP8266 (D1 mini, etc.) you would send the proper command to the Nextion display with the text as the payload to be displayed.

Check out the Home Assistant Switch Plate (HASP) Project. While it doesn’t use ESPHome, the concepts are the same.

As it turns out, the HASP already has functionality to do exactly what @sender describes as an example automation. Check out the project page here, this might be pretty much read-to-go including a 3D printed enclosure and PCB design.

Also there are some nextion examples here https://esphome.io/guides/diy.html

1 Like

hi, thanks all for the quick reply. That example automation link (https://github.com/aderusha/HASwitchPlate/blob/f4a4d1570f12bc944d3adbde575159892282ff18/Home_Assistant/hasp-examples/plate01/hasp_plate01_p0_messagedisplay.yaml#L28-L49). Is that code meant to paste in an esphome config?

Assume I am a beginner in displays with esphome and an intermediate homeassistant user (at least I think I’m intermediate:-)).

What I am looking for is a “cut and paste” config for esphome on a D1 mini… I bought:

That code was for the HASP project (my baby, so I’m a little biased :D).

Understand :slight_smile:.

I would really be greatfull for an esphome yaml starter :slight_smile:

1 Like

Do you mean for esphome generally, or just for nextion?

Both, esphome with nextion to send messages to it via homeassistant/node red :heart_eyes:

1 Like

Take a look at the examples I pointed to.

You kinda got to understand the nextion system too. There some good tutorials on YT.

Nick, thanks for responding. The thing is that if I understood it including examples I would not be asking for help here. The example are all “not half exactly” what I am looking for… I needs some help and guidance, not links to other places (with partial documentation).

1 Like

Yeah I understand that, but otoh no one is simply going to just write it for you.

So you understand the nextion system, including creation of HMI files? That has to be understood, and this is not the nextion forum.

Cheers for this, didnt know these existed

1 Like

Ok, I give up. And not easy. spent hours of reading. trying and youtubing. there is just not so much “usable” info available.

I have the display connected to a flashed D1 min. It lits up, but I am fully diffused by the “nextion editor”
Do no know how to create a view and connect to a text sensor (or whatever) from home assistant.
also I have never successfully been able to upload file via SD card to the nextion. it always says

baud: 9600
SD Card Update.....
No Find File

Oh why is everything so frikkin hard!

any ideas to have simple-usable-text-screen connected via D1 Mini and esphome to send messages to?

EDIT: some life after "file - tft file ouput- copy to SD and in nextion.

I have:

> uart:
>   rx_pin: RX
>   tx_pin: TX
>   baud_rate: 9600
> 
> 
> display:
>   - platform: nextion
> 
> binary_sensor:
>   - platform: nextion
>     page_id: 0
>     component_id: 2
>     name: "Nextion Component 2 Touch"

I have:

I shows the display on the nextion and I can press it (turns green)

But I see noting in home assistant:

It might have to do with “all other options from binary sensor” but I don’t get that well:

I have had problems trying to get ESP Home to work with the Nextion and to HA.

I ended up using a Wemos D1 and used this web site for reference.

And this one as well.

1 Like

Cameron, can you share your esphome config then?

As I said it didn’t work.

---
substitutions:
  device: esp_eliott_nextion
  name: ESP Eliott Nextion
  reboot_timeout: 14d
  update_interval: 60s
  ip_address: 192.168.85.48

esphome:
  name: ${device}
  platform: ESP8266
  board: d1_mini
  on_boot:
    priority: -180
    then:
      - lambda: |-
          id(page1).publish_state(true);
          id(page2).publish_state(false);

<<: !include common/common.yaml

time:
  - platform: sntp
    id: sntp_time
    timezone: europe/london

# Uart port definition - This works OK, but also HW UART0 works if Logs are disabled or changed to UART1

uart:
  rx_pin: D7  # Blue
  tx_pin: D6  # Yellow
  baud_rate: 9600

display:
  - platform: nextion
    id: nextiondisplay
    update_interval: 3s
    lambda: |-
            it.set_wait_for_ack(false);

            auto date = id(sntp_time).now().strftime("%b. %d");
            auto time = id(sntp_time).now().strftime("%I:%M");

            if (id(page1).state) {
                  it.set_component_text("Clock.time", time.c_str());
            }
            if (id(page2).state) {
                  it.send_command_printf("Switch.lamp.val=%d",id(eliott_lamp).state);
                  it.send_command_printf("Switch.light.val=%d",id(eliott_light).state);

## --------------------  BINARY SENSORS  --------------------
#  binary sensors here are both from Nextion and HA. ESPHOME currently can read only binary sensors from Nextion

binary_sensor:
# Because currently it is not possible to read (sensor) values from Nextion, page navigation is done with binary sensors

  # 1. page - Clock
  - platform: nextion
    page_id: 0
    component_id: 2
    id: page1
    on_press:
      then:
        - component.update: nextiondisplay
        #- script.execute: autobrightness

  # 2. page - Switch
  - platform: nextion
    page_id: 1
    component_id: 2
    id: page2
    on_press:
      then:
        - component.update: nextiondisplay

  - platform: homeassistant   # Eliott Bedroom Lamp state
    id: eliott_lamp
    entity_id: switch.spare_plug
    on_state:
      then:
        - lambda: 'id(nextiondisplay).send_command_printf("Switch.lamp.val=%d",id(eliott_lamp).state);'

  - platform: homeassistant   # Eliott Bedroom Light state
    id: eliott_light
    entity_id: switch.hive_plug
    on_state:
      then:
        - lambda: 'id(nextiondisplay).send_command_printf("Switch.light.val=%d",id(eliott_light).state);'

#
#PAGE 1 - Switch
#
  # Eliott Bedroom Lamp toggle
  - platform: nextion
    page_id: 1
    component_id: 1
    id: lamp
    # filters:
    #   - delayed_off: 20ms
    #   - delayed_on: 20ms
    on_press:
      then:
        - logger.log: "Switch On"
        - homeassistant.service:
            service: switch.turn_on
            data:
              entity_id: switch.spare_plug

    on_release:
      then:
        - logger.log: "Switch Off"
        - homeassistant.service:
            service: switch.turn_off
            data:
              entity_id: switch.spare_plug

  # Eliott Bedroom Light toggle
  - platform: nextion
    page_id: 1
    component_id: 9
    id: light
    # filters:
    #   - delayed_off: 20ms
    #   - delayed_on: 20ms
    on_press:
      then:
        - logger.log: "Switch Light On"
        - homeassistant.service:
            service: switch.turn_on
            data:
              entity_id: switch.hive_plug

    on_release:
      then:
        - logger.log: "Switch Light Off"
        - homeassistant.service:
            service: switch.turn_off
            data:
              entity_id: switch.hive_plug
1 Like

What did you mean with this then? Sorry, don’t get me wrong but what did you mean with your post?

I did not use ESP Home for the Nextion I used the second web link and modded it to link with HA and Node red.

1 Like

Ok, thank you for that.

My question in this topic is how to get this working with esphome and the builtin api etc.

1 Like