Don't retry upload unless is a nextion failure
This commit is contained in:
@@ -115,6 +115,11 @@ globals:
|
||||
restore_value: false
|
||||
initial_value: '"${nextion_update_url}"'
|
||||
|
||||
- id: tft_upload_result
|
||||
type: esphome::nextion::Nextion::TFTUploadResult
|
||||
restore_value: false
|
||||
initial_value: 'esphome::nextion::Nextion::TFTUploadResult::Unknown'
|
||||
|
||||
script:
|
||||
- id: nextion_uart_command
|
||||
mode: queued
|
||||
@@ -149,11 +154,8 @@ script:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "addon_upload_tft.script.nextion_upload";
|
||||
ESP_LOGD(TAG, "Starting TFT upload...");
|
||||
esphome::nextion::Nextion::TFTUploadResult upload_result = disp1->upload_tft();
|
||||
if (upload_result == esphome::nextion::Nextion::TFTUploadResult::OK)
|
||||
App.safe_reboot();
|
||||
else
|
||||
ESP_LOGE(TAG, "TFT upload failed: %s", esphome::nextion::Nextion::TFTUploadResultToString(upload_result));
|
||||
id(tft_upload_result) = disp1->upload_tft();
|
||||
ESP_LOGD(TAG, "TFT upload: %s", esphome::nextion::Nextion::TFTUploadResultToString(id(tft_upload_result)));
|
||||
|
||||
- id: open_upload_dialog
|
||||
mode: restart
|
||||
@@ -486,6 +488,7 @@ script:
|
||||
- lambda: |-
|
||||
char update_msg[128];
|
||||
sprintf(update_msg, "Attempt #%d at %" PRIu32 " bps", id(tft_upload_attempt), tf_uart->get_baud_rate());
|
||||
id(tft_upload_result) = esphome::nextion::Nextion::TFTUploadResult::Unknown;
|
||||
report_upload_progress->execute(update_msg);
|
||||
- script.wait: report_upload_progress
|
||||
- wait_until:
|
||||
@@ -496,9 +499,21 @@ script:
|
||||
- script.wait: nextion_upload
|
||||
- lambda: |-
|
||||
char update_msg[128];
|
||||
sprintf(update_msg, "Attempt #%d at %" PRIu32 " bps failed!", id(tft_upload_attempt), tf_uart->get_baud_rate());
|
||||
sprintf(update_msg, "Attempt #%d at %" PRIu32 " bps returned: %s", id(tft_upload_attempt),
|
||||
tf_uart->get_baud_rate(), esphome::nextion::Nextion::TFTUploadResultToString(id(tft_upload_result)));
|
||||
report_upload_progress->execute(update_msg);
|
||||
- script.wait: report_upload_progress
|
||||
- if:
|
||||
condition:
|
||||
not:
|
||||
- lambda: return id(tft_upload_result) == esphome::nextion::Nextion::TFTUploadResult::Unknown;
|
||||
- lambda: return id(tft_upload_result) == esphome::nextion::Nextion::TFTUploadResult::UploadInProgress;
|
||||
- lambda: return id(tft_upload_result) == esphome::nextion::Nextion::TFTUploadResult::NextionError_PreparationFailed;
|
||||
- lambda: return id(tft_upload_result) == esphome::nextion::Nextion::TFTUploadResult::NextionError_InvalidResponse;
|
||||
then:
|
||||
- delay: 5s
|
||||
- lambda: |-
|
||||
App.safe_reboot();
|
||||
|
||||
select:
|
||||
- id: tft_file_branch
|
||||
|
||||
Reference in New Issue
Block a user