From 694ab4f98f7999060ca6c311c5c7e045b8da6298 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Tue, 9 Apr 2024 08:08:33 +0200 Subject: [PATCH] Merge component nspanel_ha_blueprint_upload_tft into nspanel_ha_blueprint --- .../upload_tft.cpp | 8 +++++-- .../upload_tft.h | 8 +++++-- .../__init__.py | 20 ----------------- esphome/nspanel_esphome_addon_upload_tft.yaml | 22 ++----------------- 4 files changed, 14 insertions(+), 44 deletions(-) rename components/{nspanel_ha_blueprint_upload_tft => nspanel_ha_blueprint}/upload_tft.cpp (89%) rename components/{nspanel_ha_blueprint_upload_tft => nspanel_ha_blueprint}/upload_tft.h (88%) delete mode 100644 components/nspanel_ha_blueprint_upload_tft/__init__.py diff --git a/components/nspanel_ha_blueprint_upload_tft/upload_tft.cpp b/components/nspanel_ha_blueprint/upload_tft.cpp similarity index 89% rename from components/nspanel_ha_blueprint_upload_tft/upload_tft.cpp rename to components/nspanel_ha_blueprint/upload_tft.cpp index 6229b1d..7b032bc 100644 --- a/components/nspanel_ha_blueprint_upload_tft/upload_tft.cpp +++ b/components/nspanel_ha_blueprint/upload_tft.cpp @@ -1,8 +1,10 @@ // upload_tft.cpp +#ifdef NSPANEL_HA_BLUEPRINT_ADDON_UPLOAD_TFT + #include "upload_tft.h" -namespace nspanel_ha_blueprint_upload_tft { +namespace nspanel_ha_blueprint { std::string construct_tft_url(const std::string& branch, const std::string& model, const std::string& defaultUrl, const std::string& baseUrl) { @@ -25,4 +27,6 @@ namespace nspanel_ha_blueprint_upload_tft { return text; } -} // namespace nspanel_ha_blueprint_upload_tft +} // namespace nspanel_ha_blueprint + +#endif // NSPANEL_HA_BLUEPRINT_ADDON_UPLOAD_TFT diff --git a/components/nspanel_ha_blueprint_upload_tft/upload_tft.h b/components/nspanel_ha_blueprint/upload_tft.h similarity index 88% rename from components/nspanel_ha_blueprint_upload_tft/upload_tft.h rename to components/nspanel_ha_blueprint/upload_tft.h index 4f02c69..339453d 100644 --- a/components/nspanel_ha_blueprint_upload_tft/upload_tft.h +++ b/components/nspanel_ha_blueprint/upload_tft.h @@ -2,9 +2,11 @@ #pragma once +#ifdef NSPANEL_HA_BLUEPRINT_ADDON_UPLOAD_TFT + #include -namespace nspanel_ha_blueprint_upload_tft { +namespace nspanel_ha_blueprint { /** * Constructs the TFT file URL based on branch, model, default URL, and base URL. @@ -27,4 +29,6 @@ namespace nspanel_ha_blueprint_upload_tft { */ std::string getNSPanelText(int displayMode, int charset); -} // namespace nspanel_ha_blueprint_upload_tft +} // namespace nspanel_ha_blueprint + +#endif // NSPANEL_HA_BLUEPRINT_ADDON_UPLOAD_TFT diff --git a/components/nspanel_ha_blueprint_upload_tft/__init__.py b/components/nspanel_ha_blueprint_upload_tft/__init__.py deleted file mode 100644 index 72a8c19..0000000 --- a/components/nspanel_ha_blueprint_upload_tft/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# __init__.py -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.core import coroutine_with_priority - -CODEOWNERS = ["@edwardtfn"] - -nspanel_ha_blueprint_upload_tft_ns = cg.esphome_ns.namespace( - 'nspanel_ha_blueprint_upload_tft' -) - -CONFIG_SCHEMA = cv.All( - cv.Schema({}), -) - - -@coroutine_with_priority(1.0) -async def to_code(config): - cg.add_define("USE_NSPANEL_HA_BLUEPRINT_UPLOAD_TFT") - cg.add_global(nspanel_ha_blueprint_upload_tft_ns.using) diff --git a/esphome/nspanel_esphome_addon_upload_tft.yaml b/esphome/nspanel_esphome_addon_upload_tft.yaml index b7c2c18..39db087 100644 --- a/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -14,16 +14,6 @@ substitutions: nextion_update_url: "${nextion_update_base_url}/main/hmi/nspanel_blank.tft" ############################################## -##### External components ##### -external_components: - - source: - type: git - url: https://github.com/Blackymas/NSPanel_HA_Blueprint - ref: v4.3.2 - components: - - nspanel_ha_blueprint_upload_tft - refresh: 300s - esphome: platformio_options: build_flags: @@ -62,10 +52,7 @@ api: // Trim trailing spaces auto endPos = clean_url.find_last_not_of(" \t"); if (std::string::npos != endPos) clean_url = clean_url.substr(0, endPos + 1); - if (clean_url.empty() or clean_url == "default") url = nspanel_ha_blueprint_upload_tft::construct_tft_url("v${version}", - tft_file_model->state, - "${nextion_update_url}", - "${nextion_update_base_url}"); + if (clean_url.empty() or clean_url == "default") url = construct_tft_url("v${version}", tft_file_model->state, "${nextion_update_url}", "${nextion_update_base_url}"); upload_tft->execute(url.c_str()); # yamllint enable rule:comments-indentation @@ -78,10 +65,7 @@ button: entity_category: config on_press: - lambda: |- - upload_tft->execute(nspanel_ha_blueprint_upload_tft::construct_tft_url("v${version}", - tft_file_model->state, - "${nextion_update_url}", - "${nextion_update_base_url}").c_str()); + upload_tft->execute(construct_tft_url("v${version}", tft_file_model->state, "${nextion_update_url}", "${nextion_update_base_url}").c_str()); display: - id: !extend disp1 @@ -104,8 +88,6 @@ globals: restore_value: false initial_value: 'esphome::nextion::Nextion::TFTUploadResult::UNKNOWN' -nspanel_ha_blueprint_upload_tft: - script: - id: nextion_status mode: restart