Merge component nspanel_ha_blueprint_upload_tft into nspanel_ha_blueprint

This commit is contained in:
Edward Firmo
2024-04-09 08:08:33 +02:00
parent 896f86ddab
commit 694ab4f98f
4 changed files with 14 additions and 44 deletions

View File

@@ -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

View File

@@ -2,9 +2,11 @@
#pragma once
#ifdef NSPANEL_HA_BLUEPRINT_ADDON_UPLOAD_TFT
#include <string>
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

View File

@@ -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)

View File

@@ -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