Skip to content

Commit

Permalink
Remove Update TFT display - Baud rate
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardtfn committed Nov 24, 2024
1 parent 6e1c8b1 commit 00215ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 41 deletions.
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ between ESPHome and Nextion. Visit the updated [API documentation](docs/api.md)
3. **Notification unread switch replaced**
The "**Notification unread**" switch is now a binary sensor.

4. **Selector "Update TFT display - Baud rate" removed**
The baud rate selector has been removed as full support for all baud rates used by Nextion makes it redundant.
Communication now adapts automatically to the required baud rate, simplifying configuration.

### Customizations
Updated scripts require adjustments to these customizations:
- [Sleep & Wake-up buttons](docs/customization.md#sleep--wake-up-buttons)
Expand Down
11 changes: 11 additions & 0 deletions docs/tft_upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ This is another case where the message sounds more alarming than it actually is.
> [!TIP]
> If the TFT transfer has started, your panel might not respond to the reset button on the device's page in Home Assistant or to holding the hardware button for 15 seconds. In such cases, you can either power cycle your device using the room's relay on your electrical plate or use a pin to press the hardware restart button in a small hole behind the device. ![Image](pics/eu_reset_button.png)
### DNS Issues Causing Crashes
If the DNS server fails to resolve the file URL, the device may crash during the TFT upload process. To prevent this, ensure that a reliable DNS server is configured in your network settings. Alternatively, you can use a local HTTP server to host the TFT file, which can be set up using the `nextion_update_base_url`.

- **Solution**: Check your router settings and change the DNS server to a more reliable one, such as Google DNS (`8.8.8.8`) or Cloudflare (`1.1.1.1`). Hosting the file locally will also reduce dependency on external DNS resolution.

Check failure on line 31 in docs/tft_upload.md

View workflow job for this annotation

GitHub Actions / Markdown Lint

Line length

docs/tft_upload.md:31:201 MD013/line-length Line length [Expected: 200; Actual: 394] https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md013.md

### Baud Rate Mismatch Issues
A baud rate mismatch can prevent ESPHome from sending the update command to the Nextion display, resulting in the message "Nextion is not connected!" in the logs.

Check failure on line 35 in docs/tft_upload.md

View workflow job for this annotation

GitHub Actions / Markdown Lint

Line length

docs/tft_upload.md:35:201 MD013/line-length Line length [Expected: 200; Actual: 317] https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md013.md
- **Solution**: Try each available baud rate until you find the correct one. The baud rate can be configured under the device's page in Home Assistant (Settings > Devices & services > ESPHome). It is listed as a hidden entity under "Configuration" and named "Baud rate".

Check failure on line 37 in docs/tft_upload.md

View workflow job for this annotation

GitHub Actions / Markdown Lint

Line length

docs/tft_upload.md:37:201 MD013/line-length Line length [Expected: 200; Actual: 231] https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md013.md
### If Using Manual IP, Ensure DNS Server is Configured
At least one DNS server is required to enable TFT transfer directly from GitHub; otherwise, use `nextion_update_base_url`. If you are setting up a manual IP as a customization, please remember to add a valid DNS server for your panel.

Expand Down Expand Up @@ -138,3 +148,4 @@ Please share as much info as possible, like:

## Important Note
Remember, these steps are a guideline and might vary slightly based on your specific setup and previously installed system.

46 changes: 5 additions & 41 deletions esphome/nspanel_esphome_addon_upload_tft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ script:
static const char *const TAG = "addon_upload_tft.script.upload_tft";
// The upload process starts here
ESP_LOGD(TAG, "Starting the upload script");
ESP_LOGD(TAG, " Valid TFT: %s", YESNO((id(display_mode) > 0 and id(display_mode) < 4)));
ESP_LOGD(TAG, " Current baud rate: %" PRIu32 " bps", tf_uart->get_baud_rate());
ESP_LOGD(TAG, " Target upload baud rate: %s bps", tft_upload_baud_rate->state.c_str());
ESP_LOGD(TAG, " Valid TFT: %s", YESNO((id(display_mode) > 0 and id(display_mode) < 4)));
ESP_LOGD(TAG, " Baud rate: %" PRIu32 " bps", tf_uart->get_baud_rate());
ESP_LOGD(TAG, " Upload URL: %s", url.c_str());
disp1->set_tft_url(url.c_str());
Expand Down Expand Up @@ -338,26 +337,16 @@ script:
- lambda: return (id(display_mode) > 0 and id(display_mode) < 4);
timeout: 1s

### Attempt twice at the target baud rate
### Attempt twice at the current baud rate
- script.execute:
id: upload_tft_sequence_attempt
baud_rate: !lambda return stoi(tft_upload_baud_rate->state);
baud_rate: 0
- script.wait: upload_tft_sequence_attempt

### Attempt twice at the original baud rate
- if:
condition:
- lambda: return (stoi(tft_upload_baud_rate->state) != tf_uart->get_baud_rate());
then:
- script.execute:
id: upload_tft_sequence_attempt
baud_rate: 0
- script.wait: upload_tft_sequence_attempt

### Attempt twice at the Nextion's default baud rate (115200bps)
- if:
condition:
- lambda: return (stoi(tft_upload_baud_rate->state) != 115200 and tf_uart->get_baud_rate() != 115200);
- lambda: return (tf_uart->get_baud_rate() != 115200);
then:
- script.execute:
id: upload_tft_sequence_attempt
Expand Down Expand Up @@ -494,31 +483,6 @@ select:
disabled_by_default: false
icon: mdi:file-sync

- id: tft_upload_baud_rate
name: Update TFT display - Baud rate
platform: template
options:
- "2400"
- "4800"
- "9600"
- "19200"
- "31250"
- "38400"
- "57600"
- "115200"
- "230400"
- "250000"
- "256000"
- "512000"
- "921600"
initial_option: "921600"
optimistic: true
restore_value: true
internal: false
entity_category: config
disabled_by_default: true
icon: mdi:swap-horizontal

switch:
- id: tft_update_automatically
name: Update TFT automatically
Expand Down

0 comments on commit 00215ac

Please sign in to comment.