From 64ab3fa4b9c0286e2721c50e83f39c32c267c802 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Wed, 7 Feb 2024 00:30:57 +0100 Subject: [PATCH] Remove `tft_branch` selector. --- .../nspanel_esphome_addon_upload_tft.yaml | 63 ++++--------------- advanced/esphome/nspanel_esphome_core.yaml | 7 ++- 2 files changed, 17 insertions(+), 53 deletions(-) diff --git a/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml b/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml index 11befdb..c2e869c 100644 --- a/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -72,10 +72,8 @@ esphome: - lambda: |- // Hide TFT file selectors when using arduino #ifdef ARDUINO - tft_file_branch->set_internal(true); tft_file_model->set_internal(true); #elif defined(ESP_PLATFORM) - tft_file_branch->set_internal(false); tft_file_model->set_internal(false); #endif @@ -90,21 +88,11 @@ 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_attempt type: uint restore_value: false @@ -205,22 +193,6 @@ script: App.feed_wdt(); } - - id: !extend restore_settings - mode: restart - then: - - lambda: |- - static const char *const TAG = "addon_upload_tft.script.restore_settings"; - - // ESP_LOGD(TAG, "Restoring TFT file branch selector to index %u", id(tft_branch)); - // auto tft_file_branch_call = id(tft_file_branch).make_call(); - // tft_file_branch_call.set_index(id(tft_branch)); - // tft_file_branch_call.perform(); - - // ESP_LOGD(TAG, "Restoring TFT file model selector to index %u", id(tft_model)); - // auto tft_file_model_call = id(tft_file_model).make_call(); - // tft_file_model_call.set_index(id(tft_model)); - // tft_file_model_call.perform(); - - id: set_tft_file mode: restart then: @@ -231,15 +203,13 @@ script: #elif defined(ESP_PLATFORM) static const char *const TAG = "addon_upload_tft.script.set_tft_file.esp_idf"; #endif - std::string branch = tft_file_branch->state; + std::string branch = "v${version}"; + if (branch.find("beta") != std::string::npos) branch = "beta"; + else if (branch.find("dev") != std::string::npos) branch = "dev"; std::string model = tft_file_model->state; ESP_LOGD(TAG, "TFT URL set:"); ESP_LOGD(TAG, " Branch: %s", branch.c_str()); ESP_LOGD(TAG, " Model: %s", model.c_str()); - // if (id(is_restored_settings) and tft_file_branch->active_index().has_value()) - // id(tft_branch) = tft_file_branch->active_index().value(); - // if (id(is_restored_settings) and tft_file_model->active_index().has_value()) - // id(tft_model) = tft_file_model->active_index().value(); if (id(is_uploading_tft)) ESP_LOGW(TAG, " TFT Upload in progress."); @@ -515,24 +485,17 @@ script: - lambda: |- App.safe_reboot(); -select: - - id: tft_file_branch - name: Update TFT display - Branch - platform: template - options: - - "v${version}" - - "beta" - - "dev" - initial_option: "v${version}" - optimistic: true - restore_value: false - internal: true - entity_category: config - disabled_by_default: true - icon: mdi:file-sync - on_value: - - script.execute: set_tft_file + - id: !extend watchdog + then: + - lambda: |- + if (!id(is_uploading_tft)) { + static const char *const TAG = "addon_upload_tft.script.watchdog"; + ESP_LOGI(TAG, "Add-on Upload TFT:"); + ESP_LOGI(TAG, " File model: %s", tft_file_model->state.c_str()); + ESP_LOGD(TAG, " Valid TFT: %s", YESNO(id(tft_is_valid))); + } +select: - id: tft_file_model name: Update TFT display - Model platform: template diff --git a/advanced/esphome/nspanel_esphome_core.yaml b/advanced/esphome/nspanel_esphome_core.yaml index a591d73..37d53e3 100644 --- a/advanced/esphome/nspanel_esphome_core.yaml +++ b/advanced/esphome/nspanel_esphome_core.yaml @@ -1861,10 +1861,11 @@ script: return (major1 == major2) && (minor1 == minor2); }; - ESP_LOGD(TAG, "ESPHome version: ${version}"); - ESP_LOGD(TAG, "TFT version: %s", version_tft->state.c_str()); + ESP_LOGD(TAG, "Versions:"); + ESP_LOGD(TAG, " ESPHome: ${version}"); + ESP_LOGD(TAG, " TFT: %s", version_tft->state.c_str()); if (not compareVersions("${version}", version_tft->state.c_str())) ESP_LOGE(TAG, "TFT version mismatch!"); - ESP_LOGD(TAG, "Blueprint version: %s", version_blueprint->state.c_str()); + ESP_LOGD(TAG, " Blueprint: %s", version_blueprint->state.c_str()); if (not compareVersions("${version}", version_blueprint->state.c_str())) ESP_LOGE(TAG, "Blueprint version mismatch!"); auto ha_event = new esphome::api::CustomAPIDevice();