HASwitchPlate in ESPHome

Hi,
I bought the HASwitchPlate hardware and enclosure, and love the look and feel of it. I wanted to use the hardware to do an ESPHome based project, vs using the firmware and MQTT.
I was able to get it connected to my Wi-Fi, but i keep getting the error that Nextion display is not connected to the UART. I use the pins rom the GitHub repository of the project, so not sure what the deal is.

Has anyone done a project with ESPHome using the HASwitchPlate hardware? If so, can you share config you used?

My intent is to have a configuration for the basic hardware first, have it work with OTA, and then add the Nextion OTA update to it, so I don’t need to remove the hardware from the case every time I update the GUI.
The documentation seems clear enough to do that, but until I get the Nextion to connect to the ESP, none of the other stuff matters. So any help is appreciated to get the hardware work as an ESPHome node.
Thanks,
H-

What is your yaml?

Alright, got it. Dug into the hardware and realized there is a GPIO controlling the power for the display.
In case someone needs it, I have it in 2 different yaml files:
The template yaml is HASwitchPlate.yaml, and the content are:


---

#Include the platform used for the hardware

esphome:

  name: $id

  platform: ESP8266

  board: esp01_1m

  on_boot:

    priority: -100.0

    then:

      - output.turn_on: nextion_power

#Include all base configuration

#Enable Logging

<<: !include ../logger.yaml

# Enable Home Assistant API

<<: !include ../api_nextion_update.yaml

<<: !include ../ota.yaml

<<: !include ../wifi_failover.yaml

uart:

  id: uart_nextion

  rx_pin: GPIO13

  tx_pin: GPIO2

  baud_rate: 115200

And the actual project yaml is:

#Name the Project here to identify the specific node
substitutions:
  project: Wall-Switch-01
  id: wall-switch-01

#Include the platform used for the hardware
<<: !include common/templates/HASwitchPlate.yaml
  
time:
  - platform: sntp
    id: sntp_time

#Map the display ON GPIO to GPIO12.
#The output gets turned on on_boot in the HASwitchPlate.yaml file
output:
  - platform: gpio
    pin: GPIO12
    id: nextion_power

I will clean up the parsing of the content within the yaml files once debug is done.
And I will figure out how to upload the display content via home assistant so i am not having to take the box apart. That comes next. That will finalize the template yaml for me, and I can focus the programming on the display interaction with HA and user, and everything else is repeatable for each switch I have.
I can update once I make progress if there is interest.

Thanks,
H-

1 Like

It would be really good if you could quote your code properly please. So is ut connecting now?

yes, it is connecting. Was an issue with power to the display. With the GPIO12 being set high on-boot, all works as expected.

I will, when I paste, for some reason it adds a line between each line of code, which makes the code twice as long…I deleted them here and I see it got screwed up.

I will start another thread on the OTA upload of the tft file. I assume this is something people would be interested in, but I cannot find any more info other than the Documentation…

1 Like

Indeed there is interest. Would you mind tagging me in when you do? There wad more stuff added to esphome’s nextion support very recently, so there may not be much info in the wild yet.

As for posting code, three backticks before and after. See point 11 here How to help us help you - or How to ask a good question