Hi,
I have a Nextion display (using the hardware from HASwitchPlate) and want to setup a project to use OTA to upload the tft file to the Nextion display through ESPHome.
I have reviewed the documentation, and it seems straight forward, but I am getting something unexpected. First the code:
This is the template I am using:
---
#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
The only include you should focus on is the /api_nextion_update.yaml. This is where the service is added per documentation (at least that’s how I understood it).
---
# Home Assistant API
api:
services:
- service: update_nextion
then:
- lambda: 'id(HASwitchPlateNextion)->upload_tft();'
In my project file, I have the following:
#Name the Project here to dentify 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
globals:
- id: first_page # First page of the display?
type: bool
restore_value: no
- id: display_on # Is display on?
type: bool
restore_value: no
display:
- platform: nextion
id: HASwitchPlateNextion
uart_id: uart_nextion
update_interval: 3s
tft_url: http://homeassistant.local:8123/local/tft/nextion_touch.tft
lambda: |-
it.set_wait_for_ack(false);
auto time_text = id(sntp_time).now().strftime("%H:%M");
auto date = id(sntp_time).now().strftime("%b. %d");
it.set_component_text("time", time_text.c_str());
it.set_component_text("time", "timenow");
The project compiles, but I get this error:
Building /data/wall-switch-01/.pioenvs/wall-switch-01/firmware.bin
RAM: [===== ] 50.3% (used 41244 bytes from 81920 bytes)
Flash: [====== ] 55.8% (used 571180 bytes from 1023984 bytes)
Creating BIN file "/data/wall-switch-01/.pioenvs/wall-switch-01/firmware.bin" using "/root/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" and "/data/wall-switch-01/.pioenvs/wall-switch-01/firmware.elf"
========================= [SUCCESS] Took 10.44 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of wall-switch-01.local
INFO -> 192.168.30.37
INFO Uploading /data/wall-switch-01/.pioenvs/wall-switch-01/firmware.bin (575328 bytes)
ERROR Error binary size: Error: ESP does not have enough space to store OTA file. Please try flashing a minimal firmware (remove everything except ota)
The nextion_touch.tft is 1.65MB in size. So I understand the a 1MB ESP with 55.8% used already will not be able to load 1.65MB additional.
The question is one layer down. I have done OTA of large files before in typical MCU projects, never in ESPHome and HA. Assuming my implementation above is the right one based on the documentation here, I would have thought that the file for the tft would only get loaded when the update is triggered (I don’t know where to trigger it from yet, but will get to it once I figure this one out).
Once triggered, the OTA would happen in smaller packets given it is through a UART, AND I cannot imagine anyone updating a color tft would have a small file to fit into an ESP running other code on it.
So my questions are:
- Did I have the implementation right?
- Is my assumption on how the OTA works right given it is a graphics tft?
- If the answers to the above are Yes, is this a limitation that we can only update a nextion display vi ESPHome if the .tft file is smaller than the free space on the ESP?
EDIT: The project works as expected when I remove this line:
tft_url: http://homeassistant.local:8123/local/tft/nextion_touch.tft
@nickrout : making you aware