7 Commits

Author SHA1 Message Date
Edward Firmo
be1c8a264e Do not test IDF v5 2023-12-05 18:08:01 +01:00
Edward Firmo
f6d8d069cc Upload TFT UI on the panel 2023-12-05 18:06:55 +01:00
Edward Firmo
2909ce6cc8 Upload TFT UI on panel 2023-12-05 18:03:34 +01:00
Edward Firmo
ba6f0264a6 This file will be moved to advanced folder soon
To avoid a breaking change
2023-12-05 17:14:49 +01:00
Edward Firmo
15e1976715 Remove extra line 2023-12-05 17:10:59 +01:00
Edward Firmo
88bb6ff176 Merge branch 'beta' of https://github.com/Blackymas/NSPanel_HA_Blueprint into beta 2023-12-05 16:59:01 +01:00
Edward Firmo
cbdc47170f TFT Upload routine clean-up
Solves #1378
Solves #1383
2023-12-05 16:58:54 +01:00
14 changed files with 185 additions and 69 deletions

View File

@@ -109,18 +109,18 @@ jobs:
yaml_file: "./.test/esphome_advanced_climate_cool_esp_idf.yaml"
version: beta
build_climate_cool_advanced_esp_idf5:
name: esp-idf v5 & Bluetooth proxy
runs-on: "ubuntu-latest"
needs:
- build_climate_cool_advanced_esp_idf
steps:
- uses: actions/checkout@v4.1.0
- name: Build core+advanced+climate_cool+esp_idf5
uses: esphome/build-action@v1.8.0
with:
yaml_file: "./.test/esphome_advanced_climate_cool_esp_idf5.yaml"
version: beta
#build_climate_cool_advanced_esp_idf5:
# name: esp-idf v5 & Bluetooth proxy
# runs-on: "ubuntu-latest"
# needs:
# - build_climate_cool_advanced_esp_idf
# steps:
# - uses: actions/checkout@v4.1.0
# - name: Build core+advanced+climate_cool+esp_idf5
# uses: esphome/build-action@v1.8.0
# with:
# yaml_file: "./.test/esphome_advanced_climate_cool_esp_idf5.yaml"
# version: beta
build_climate_heat_advanced_customization:
name: Customizations

View File

@@ -106,7 +106,7 @@ packages:
- 4.1.4 patch:
- Supports new `weather.get_forecasts` introduced by Home Assistant 2023.12.0
- Manual line break on multiline text with `\r`
- Upload TFT user's interface on the panel
 
## Details of noteworthy changes

View File

@@ -140,20 +140,6 @@ script:
static const char *const TAG = "script.upload_tft";
ESP_LOGD(TAG, "Starting...");
nextion_init->publish_state(false);
disp1->set_backlight_brightness(1);
disp1->hide_component("255");
stop_all->execute();
std::vector<uint8_t> buffer_;
bool is_updating_ = false;
bool upload_first_chunk_sent_ = false;
int content_length_ = 0;
int tft_size_ = 0;
auto delay_seconds_ = [](int seconds) {
ESP_LOGD(TAG, "Wait %i seconds", seconds);
for (int i = 0; i < (seconds*4); i++) {
@@ -166,6 +152,54 @@ script:
}
};
std::string framework = "Unknown";
#ifdef ARDUINO
framework = "Arduino";
#elif defined(ESP_PLATFORM)
framework = "ESP-IDF";
#endif
if (disp1->is_setup()) {
disp1->set_backlight_brightness(1);
disp1->set_component_text_printf("confirm.title", "Upload TFT\\r%s", framework.c_str());
disp1->set_component_text_printf("confirm.body", "Preparing...");
disp1->goto_page("confirm");
disp1->hide_component("bt_close");
disp1->hide_component("bt_accept");
disp1->hide_component("bt_clear");
disp1->hide_component("bt_close");
delay_seconds_(1);
display_wrapped_text->execute("confirm.body", "Informing the blueprint that panel is unavailable...", 18);
disp1->hide_component("bt_close");
}
nextion_init->publish_state(false);
if (disp1->is_setup()) {
delay_seconds_(1);
display_wrapped_text->execute("confirm.body", "Stopping scripts...", 18);
}
stop_all->execute();
if (disp1->is_setup()) delay_seconds_(1);
std::vector<uint8_t> buffer_;
bool is_updating_ = false;
bool upload_first_chunk_sent_ = false;
int content_length_ = 0;
int tft_size_ = 0;
auto set_baud_rate_ = [](int baud_rate) {
#ifdef USE_ARDUINO
auto *uart = reinterpret_cast<uart::ESP32ArduinoUARTComponent *>(tf_uart);
#endif
#ifdef USE_ESP_IDF
auto *uart = reinterpret_cast<uart::IDFUARTComponent *>(tf_uart);
#endif
uart->set_baud_rate(baud_rate);
uart->setup();
};
auto send_nextion_command = [](const std::string &command) -> bool
{
static const char *const TAG = "script.upload_tft.send_nextion_command";
@@ -365,8 +399,8 @@ script:
{
static const char *const TAG = "script.upload_tft.upload_tft_arduino";
ESP_LOGD(TAG, "Nextion TFT upload requested");
ESP_LOGD(TAG, "url: %s", url.c_str());
ESP_LOGD(TAG, "baud_rate: %i", update_baud_rate_);
ESP_LOGD(TAG, " url: %s", url.c_str());
ESP_LOGD(TAG, " baud_rate: %i", update_baud_rate_);
if (is_updating_) {
ESP_LOGD(TAG, "Currently updating");
@@ -442,8 +476,9 @@ script:
// Tells the Nextion the content length of the tft file and baud rate it will be sent at
// Once the Nextion accepts the command it will wait until the file is successfully uploaded
// If it fails for any reason a power cycle of the display will be needed
sprintf(command, "whmi-wris %d,%" PRIu32 ",1", content_length_, update_baud_rate_);
sprintf(command, "whmi-wris %d,%d,1", content_length_, update_baud_rate_);
ESP_LOGD(TAG, "Clear serial receive buffer: %d", id(tf_uart).available());
// Clear serial receive buffer
uint8_t d;
while (id(tf_uart).available()) {
@@ -452,16 +487,16 @@ script:
send_nextion_command(command);
if (update_baud_rate_ != id(tf_uart).get_baud_rate())
{
id(tf_uart).set_baud_rate(update_baud_rate_);
id(tf_uart).setup();
if (update_baud_rate_ != id(tf_uart).get_baud_rate()) {
set_baud_rate_(update_baud_rate_);
//id(tf_uart).set_baud_rate(update_baud_rate_);
//id(tf_uart).setup();
//delay_seconds_(2);
}
std::string response;
ESP_LOGD(TAG, "Waiting for upgrade response");
recv_ret_string_(response, 2000, true); // This can take some time to return
std::string response;
recv_ret_string_(response, 5000, true); // This can take some time to return
// The Nextion display will, if it's ready to accept data, send a 0x05 byte.
ESP_LOGD(TAG, "Upgrade response is [%s]",
format_hex_pretty(reinterpret_cast<const uint8_t *>(response.data()), response.size()).c_str());
@@ -630,8 +665,8 @@ script:
auto upload_tft_ = [&](const std::string &url, unsigned int update_baud_rate_) -> bool {
static const char *const TAG = "script.upload_tft.upload_tft_esp_idf";
ESP_LOGD(TAG, "Nextion TFT upload requested");
ESP_LOGD(TAG, "url: %s", url.c_str());
ESP_LOGD(TAG, "baud_rate: %i", update_baud_rate_);
ESP_LOGD(TAG, " url: %s", url.c_str());
ESP_LOGD(TAG, " baud_rate: %i", update_baud_rate_);
if (is_updating_) {
ESP_LOGW(TAG, "Currently updating");
@@ -713,10 +748,10 @@ script:
send_nextion_command(command);
if (update_baud_rate_ != id(tf_uart).get_baud_rate())
{
id(tf_uart).set_baud_rate(update_baud_rate_);
id(tf_uart).setup();
if (update_baud_rate_ != id(tf_uart).get_baud_rate()) {
set_baud_rate_(update_baud_rate_);
//id(tf_uart).set_baud_rate(update_baud_rate_);
//id(tf_uart).setup();
}
std::string response;
@@ -761,36 +796,43 @@ script:
};
#endif
unsigned int upload_tries = 0;
while (upload_tries < 5) {
upload_tries++;
ESP_LOGD(TAG, "Try #%i", upload_tries);
if (upload_tft_(url, 921600)) id(restart_nspanel).press();
ESP_LOGD(TAG, "Turn off Nextion");
id(screen_power).turn_off();
delay_seconds_(2);
ESP_LOGD(TAG, "Turn on Nextion");
id(screen_power).turn_on();
delay_seconds_(5);
ESP_LOGD(TAG, "Try #1 at 921600 bps");
if (disp1->is_setup()) {
display_wrapped_text->execute("confirm.body", "Try #1 at 921600 bps", 18);
delay_seconds_(1);
}
unsigned int new_baud_rate;
if (id(tf_uart).get_baud_rate() == 115200) {
new_baud_rate = 921600;
} else {
new_baud_rate = 115200;
if (upload_tft_(url, 921600)) id(restart_nspanel).press();
ESP_LOGW(TAG, "Try #1 failed");
if (disp1->is_setup()) display_wrapped_text->execute("confirm.body", "Try #1 failed", 18);
delay_seconds_(5);
ESP_LOGD(TAG, "Try #2 at 921600 bps");
if (upload_tft_(url, 921600)) id(restart_nspanel).press();
ESP_LOGW(TAG, "Try #2 failed");
if (disp1->is_setup()) display_wrapped_text->execute("confirm.body", "Try #2 failed", 18);
delay_seconds_(5);
ESP_LOGD(TAG, "Try #3 at 115200 bps");
if (upload_tft_(url, 115200)) id(restart_nspanel).press();
ESP_LOGW(TAG, "Try #3 failed");
if (disp1->is_setup()) {
display_wrapped_text->execute("confirm.body", "Try #3 failed. Restarting display.", 18);
delay_seconds_(3);
}
ESP_LOGD(TAG, "Trying again at %i bps", new_baud_rate);
if (upload_tft_(url, new_baud_rate)) {
id(restart_nspanel).press();
}
ESP_LOGE(TAG, "TFT upload failed.");
ESP_LOGD(TAG, "Turn off Nextion");
id(screen_power).turn_off();
delay_seconds_(2);
ESP_LOGD(TAG, "Turn on Nextion");
id(screen_power).turn_on();
ESP_LOGD(TAG, "Restarting esphome");
delay_seconds_(10);
ESP_LOGD(TAG, "Try #4 at 115200 bps");
if (upload_tft_(url, 115200)) id(restart_nspanel).press();
ESP_LOGE(TAG, "TFT upload failed");
ESP_LOGD(TAG, "Turn off Nextion");
id(screen_power).turn_off();
delay_seconds_(2);
ESP_LOGD(TAG, "Turn on Nextion");
id(screen_power).turn_on();
ESP_LOGD(TAG, "Restarting ESPHome");
delay_seconds_(2);
id(restart_nspanel).press();
ESP_LOGD(TAG, "Finished!");
ESP_LOGD(TAG, "Finished!");

Binary file not shown.

View File

@@ -109,7 +109,7 @@ Text body
Send Component ID : disabled
Associated Keyboard: none
Text : Please confirm
Max. Text Size : 22
Max. Text Size : 254
Events
Touch Press Event

Binary file not shown.

View File

@@ -109,7 +109,7 @@ Text body
Send Component ID : disabled
Associated Keyboard: none
Text : Please confirm
Max. Text Size : 22
Max. Text Size : 254
Events
Touch Press Event

Binary file not shown.

View File

@@ -109,7 +109,7 @@ Text body
Send Component ID : disabled
Associated Keyboard: none
Text : Please confirm
Max. Text Size : 22
Max. Text Size : 254
Events
Touch Press Event

View File

@@ -0,0 +1,37 @@
#####################################################################################################
##### NSPANEL ESPHOME created by Blackymas - https://github.com/Blackymas/NSPanel_HA_Blueprint #####
##### ESPHome Add-on for Climate control - Cool #####
##### PLEASE only make changes if it is necessary and also the required knowledge is available. #####
##### For normal use with the Blueprint, no changes are necessary. #####
#####################################################################################################
##### ATTENTION: This will add climate elements to the core system and requires the core part. #####
#####################################################################################################
substitutions:
### Local thermostat defaults ###
# https://esphome.io/components/climate/thermostat.html
cooler_relay: "0" # Select 1 for "Relay 1", 2 for "Relay 2" or "0" to a dummy switch/disabled
# https://esphome.io/components/climate/index.html#base-climate-configuration
temp_min: "15"
temp_max: "45"
##### DO NOT CHANGE THIS #####
addon_climate_cool: "true"
addon_climate_heat: "false"
##############################
climate:
- id: !extend thermostat_embedded
min_cooling_off_time: ${min_off_time}s
min_cooling_run_time: ${min_run_time}s
cool_action:
- switch.turn_on: relay_${cooler_relay}
preset:
- name: "Off"
default_target_temperature_high: ${temp_min} ${temp_units}
mode: "off"
- name: Home
default_target_temperature_high: 21 ${temp_units}
packages:
base_climate_package: !include advanced/esphome/nspanel_esphome_addon_climate_base.yaml

View File

@@ -0,0 +1,37 @@
#####################################################################################################
##### NSPANEL ESPHOME created by Blackymas - https://github.com/Blackymas/NSPanel_HA_Blueprint #####
##### ESPHome Add-on for Climate control - Heat #####
##### PLEASE only make changes if it is necessary and also the required knowledge is available. #####
##### For normal use with the Blueprint, no changes are necessary. #####
#####################################################################################################
##### ATTENTION: This will add climate elements to the core system and requires the core part. #####
#####################################################################################################
substitutions:
### Local thermostat defaults ###
# https://esphome.io/components/climate/thermostat.html
heater_relay: "0" # Select 1 for "Relay 1", 2 for "Relay 2" or "0" to a dummy switch/disabled
# https://esphome.io/components/climate/index.html#base-climate-configuration
temp_min: "5"
temp_max: "25"
##### DO NOT CHANGE THIS #####
addon_climate_cool: "false"
addon_climate_heat: "true"
##############################
climate:
- id: !extend thermostat_embedded
min_heating_off_time: ${min_off_time}s
min_heating_run_time: ${min_run_time}s
heat_action:
- switch.turn_on: relay_${heater_relay}
preset:
- name: "Off"
default_target_temperature_low: ${temp_min} ${temp_units}
mode: "off"
- name: Home
default_target_temperature_low: 21 ${temp_units}
packages:
base_climate_package: !include advanced/esphome/nspanel_esphome_addon_climate_base.yaml

Binary file not shown.

Binary file not shown.

Binary file not shown.