diff --git a/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml b/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml index 578e8a2..46e433f 100644 --- a/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -65,6 +65,20 @@ display: tft_url: ${nextion_update_url} exit_reparse_on_start: true +esphome: + on_boot: + - priority: 605.0 + then: + - lambda: |- + static const char *const TAG = "addon_upload_tft.esphome.on_boot"; + ESP_LOGD(TAG, "Restoring TFT file selectors"); + - select.set_index: + id: tft_file_branch + index: !lambda return id(tft_branch); + - select.set_index: + id: tft_file_model + index: !lambda return id(tft_model); + globals: - id: baud_rate_original type: uint @@ -76,11 +90,21 @@ globals: restore_value: false initial_value: ${upload_tft_baud_rate} + - id: tft_branch + type: uint + restore_value: true + initial_value: '0' + - id: tft_is_valid type: bool restore_value: false initial_value: 'false' + - id: tft_model + type: uint + restore_value: true + initial_value: '0' + - id: tft_upload_try type: uint restore_value: false @@ -188,12 +212,11 @@ script: - id: set_tft_file mode: restart - parameters: - model: string - branch: string then: - lambda: |- static const char *const TAG = "addon_upload_tft.script.set_tft_file"; + std::string model = tft_file_model->state; + std::string branch = tft_file_branch->state; ESP_LOGD(TAG, "A new TFT was selected:"); ESP_LOGD(TAG, " Model: %s", model.c_str()); ESP_LOGD(TAG, " Branch: %s", branch.c_str()); @@ -1196,7 +1219,7 @@ script: - script.wait: report_upload_progress select: - - id: tft_file + - id: tft_file_model name: ${device_name} Update TFT display - Model platform: template options: @@ -1210,14 +1233,14 @@ select: - "NSPanel US Landscape (CJK languages)" initial_option: "Use nextion_update_url" optimistic: true - restore_value: true + restore_value: false internal: false entity_category: config disabled_by_default: false icon: mdi:file-sync set_action: - - lambda: set_tft_file->execute(x.c_str(), tft_file_branch->state.c_str()); - - script.wait: set_tft_file + - lambda: if (tft_file_model->active_index().has_value()) id(tft_model) = tft_file_model->active_index().value(); + - script.execute: set_tft_file - id: tft_file_branch name: ${device_name} Update TFT display - Branch @@ -1228,14 +1251,14 @@ select: - "dev" initial_option: "main" optimistic: true - restore_value: true + restore_value: false internal: false entity_category: config disabled_by_default: true icon: mdi:file-sync set_action: - - lambda: set_tft_file->execute(tft_file->state.c_str(), x.c_str()); - - script.wait: set_tft_file + - lambda: if (tft_file_branch->active_index().has_value()) id(tft_branch) = tft_file_branch->active_index().value(); + - script.execute: set_tft_file sensor: - id: !extend display_mode diff --git a/advanced/esphome/nspanel_esphome_core.yaml b/advanced/esphome/nspanel_esphome_core.yaml index 8569527..d9ba2ef 100644 --- a/advanced/esphome/nspanel_esphome_core.yaml +++ b/advanced/esphome/nspanel_esphome_core.yaml @@ -22,6 +22,7 @@ external_components: - source: github://pr#6051 # Remove this when that PR is released (Hopefully v2024.1.0) components: - nextion + refresh: 300s ##### ESPHOME CONFIGURATION ##### esphome: @@ -34,7 +35,7 @@ esphome: - priority: 600.0 # This is where most sensors are set up. then: - lambda: |- - static const char *const TAG = "on_boot"; + static const char *const TAG = "esphome.on_boot"; ESP_LOGD(TAG, "After boot check-up starting"); set_baud_rate->execute(stoi(baud_rate->state), true); - select.set: diff --git a/advanced/esphome/nspanel_esphome_prebuilt.yaml b/advanced/esphome/nspanel_esphome_prebuilt.yaml index fd97b22..2bd75fa 100644 --- a/advanced/esphome/nspanel_esphome_prebuilt.yaml +++ b/advanced/esphome/nspanel_esphome_prebuilt.yaml @@ -62,7 +62,7 @@ script: select: - - id: !extend tft_file + - id: !extend tft_file_model platform: template options: - "NSPanel Blank" diff --git a/nspanel_esphome_prebuilt.bin b/nspanel_esphome_prebuilt.bin index 1d3e29c..b15ffd2 100644 Binary files a/nspanel_esphome_prebuilt.bin and b/nspanel_esphome_prebuilt.bin differ