From b5c4c6e019eb453df2fd1d16f7baf076ae8d34b3 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 24 Nov 2024 00:14:52 +0100 Subject: [PATCH 1/9] display_component_send change to queued --- esphome/nspanel_esphome_core_hw_display.yaml | 123 +++++++++---------- 1 file changed, 60 insertions(+), 63 deletions(-) diff --git a/esphome/nspanel_esphome_core_hw_display.yaml b/esphome/nspanel_esphome_core_hw_display.yaml index fe318f2a..b412cc36 100644 --- a/esphome/nspanel_esphome_core_hw_display.yaml +++ b/esphome/nspanel_esphome_core_hw_display.yaml @@ -339,7 +339,7 @@ script: display_component_update_visibility->execute(display_component, visible); - id: display_component_send - mode: parallel + mode: queued parameters: display_component: DisplayComponent* then: @@ -348,56 +348,47 @@ script: - lambda: return (display_component->page_id == current_page_id); timeout: 2s - lambda: |- - ESP_LOGD("script.display_component_send", "Rendering page %s, component %s", - page_names[display_component->page_id], display_component->component); - display_component_send_text->execute(display_component); - display_component_send_color->execute(display_component); - display_component_send_font->execute(display_component); - display_component_send_visibility->execute(display_component); + if (display_component->page_id == current_page_id) { + ESP_LOGD("script.display_component_send", "Rendering page %s, component %s", + page_names[display_component->page_id], display_component->component); + display_component_send_text->execute(display_component); + display_component_send_color->execute(display_component); + display_component_send_font->execute(display_component); + display_component_send_visibility->execute(display_component); + } - id: display_component_send_color - mode: parallel + mode: queued parameters: display_component: DisplayComponent* then: - - wait_until: - condition: - - lambda: return (display_component->page_id == current_page_id or display_component->color_is_updated); - timeout: 2s - - script.execute: nextion_queue_add - if: condition: - - lambda: return (display_component->page_id == current_page_id and !display_component->color_is_updated); + - lambda: return display_component->page_id == current_page_id; + - lambda: return not display_component->color_is_updated; then: + - script.execute: nextion_queue_add - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); - - lambda: |- - if (display_component->page_id == current_page_id and !display_component->color_is_updated) { - disp1->set_component_font_color(display_component->component, display_component->color); - display_component->color_is_updated = true; - } - nextion_queue_del->execute(); + - lambda: |- + if (display_component->page_id == current_page_id and !display_component->color_is_updated) { + disp1->set_component_font_color(display_component->component, display_component->color); + display_component->color_is_updated = true; + } + nextion_queue_del->execute(); - id: display_component_send_font - mode: parallel + mode: queued parameters: display_component: DisplayComponent* then: - if: condition: - - lambda: return (display_component->font != UINT8_MAX or display_component->font_is_updated); + - lambda: return display_component->page_id == current_page_id; + - lambda: return display_component->font != UINT8_MAX; + - lambda: return not display_component->font_is_updated; then: - - wait_until: - condition: - - lambda: |- - return (display_component->page_id == current_page_id and !display_component->font_is_updated); - timeout: 2s - script.execute: nextion_queue_add - - if: - condition: - - lambda: |- - return (display_component->page_id == current_page_id and !display_component->font_is_updated); - then: - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); - lambda: |- if (display_component->page_id == current_page_id and !display_component->font_is_updated) { disp1->set_component_font(display_component->component, display_component->font); @@ -406,51 +397,43 @@ script: nextion_queue_del->execute(); - id: display_component_send_text - mode: parallel + mode: queued parameters: display_component: DisplayComponent* then: - - wait_until: - condition: - - lambda: return (display_component->page_id == current_page_id or display_component->text_is_updated); - timeout: 2s - - script.execute: nextion_queue_add - if: condition: - - lambda: return (display_component->page_id == current_page_id and !display_component->text_is_updated); + - lambda: return display_component->page_id == current_page_id; + - lambda: return not display_component->text_is_updated; then: + - script.execute: nextion_queue_add - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); - - lambda: |- - if (display_component->page_id == current_page_id and !display_component->text_is_updated) { - disp1->set_component_text(display_component->component, display_component->text); - display_component->text_is_updated = true; - } - nextion_queue_del->execute(); + - lambda: |- + if (display_component->page_id == current_page_id and !display_component->text_is_updated) { + disp1->set_component_text(display_component->component, display_component->text); + display_component->text_is_updated = true; + } + nextion_queue_del->execute(); - id: display_component_send_visibility - mode: parallel + mode: queued parameters: display_component: DisplayComponent* then: - - wait_until: - condition: - - lambda: |- - return (display_component->page_id == current_page_id) or display_component->visible_is_updated; - timeout: 2s - - script.execute: nextion_queue_add - if: condition: - - lambda: |- - return (display_component->page_id == current_page_id and !display_component->visible_is_updated); + - lambda: return display_component->page_id == current_page_id; + - lambda: return not display_component->visible_is_updated; then: + - script.execute: nextion_queue_add - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); - - lambda: |- - if (display_component->page_id == current_page_id and !display_component->visible_is_updated) { - disp1->send_command_printf("vis %s,%i", display_component->component, - display_component->visible ? 1 : 0); - display_component->visible_is_updated = true; - } - nextion_queue_del->execute(); + - lambda: |- + if (display_component->page_id == current_page_id and !display_component->visible_is_updated) { + disp1->send_command_printf("vis %s,%i", display_component->component, + display_component->visible ? 1 : 0); + display_component->visible_is_updated = true; + } + nextion_queue_del->execute(); - id: display_component_update_color mode: parallel @@ -659,18 +642,32 @@ script: - id: nextion_queue_delay_factor_increment mode: restart then: - - delay: 15s - lambda: |- + screen_power->turn_off(); ESP_LOGE("script.nextion_queue_delay_factor_increment", "Nextion reported a buffer overflow"); ESP_LOGE("script.nextion_queue_delay_factor_increment", "Increasing the delay factor..."); - number.increment: id: nextion_queue_delay_factor cycle: false + - if: + condition: + - lambda: return global_preferences->sync(); + then: + - lambda: |- + ESP_LOGE("script.nextion_queue_delay_factor_increment", + "Restarting ESP to avoid getting out of sync with Nextion"); + - delay: 2s + - lambda: arch_restart(); - id: nextion_queue_reset mode: restart then: - lambda: |- + display_component_send->stop(); + display_component_send_color->stop(); + display_component_send_font->stop(); + display_component_send_text->stop(); + display_component_send_visibility->stop(); set_component_font->stop(); set_component_font_color->stop(); set_component_pic->stop(); From 823c9d8f32dfe0c02cadf5dea5d1eb716a2d620e Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 24 Nov 2024 11:37:50 +0100 Subject: [PATCH 2/9] Remove Nextion queue It wasn't adding any value --- esphome/nspanel_esphome_core_boot.yaml | 2 +- esphome/nspanel_esphome_core_hw_display.yaml | 202 +++++------------- esphome/nspanel_esphome_core_page_blank.yaml | 2 +- esphome/nspanel_esphome_core_page_boot.yaml | 2 +- .../nspanel_esphome_core_page_buttons.yaml | 2 +- .../nspanel_esphome_core_page_entities.yaml | 2 +- ...spanel_esphome_core_page_media_player.yaml | 2 +- 7 files changed, 54 insertions(+), 160 deletions(-) diff --git a/esphome/nspanel_esphome_core_boot.yaml b/esphome/nspanel_esphome_core_boot.yaml index 1932e065..c2027559 100644 --- a/esphome/nspanel_esphome_core_boot.yaml +++ b/esphome/nspanel_esphome_core_boot.yaml @@ -23,7 +23,7 @@ display: on_setup: then: - lambda: |- - send_command->execute("esphome=0"); + disp1->send_command("esphome=0"); set_brightness->execute(100); nextion_init->publish_state(disp1->is_setup()); diff --git a/esphome/nspanel_esphome_core_hw_display.yaml b/esphome/nspanel_esphome_core_hw_display.yaml index b412cc36..3c490549 100644 --- a/esphome/nspanel_esphome_core_hw_display.yaml +++ b/esphome/nspanel_esphome_core_hw_display.yaml @@ -22,7 +22,7 @@ api: cmd: string then: - lambda: |- - send_command->execute(cmd.c_str()); + disp1->send_command(cmd.c_str()); # Component action - action: component @@ -104,7 +104,7 @@ display: on_buffer_overflow: then: - - script.execute: nextion_queue_delay_factor_increment + - script.execute: display_delay_increment on_page: then: @@ -212,11 +212,6 @@ globals: restore_value: true initial_value: "'.'" - - id: nextion_queue - type: uint8_t - restore_value: false - initial_value: '0' - json: # Can be replaced by web_server number: @@ -284,14 +279,15 @@ number: val: !lambda return static_cast(x); - script.execute: page_screensaver - - id: nextion_queue_delay_factor - name: Display queue delay factor + - id: display_delay + name: Display delay platform: template entity_category: config min_value: 0 - max_value: 25 - initial_value: 5 - step: 1 + max_value: 250 + initial_value: 35 + step: 5 + unit_of_measurement: msec restore_value: true optimistic: true internal: false @@ -367,14 +363,12 @@ script: - lambda: return display_component->page_id == current_page_id; - lambda: return not display_component->color_is_updated; then: - - script.execute: nextion_queue_add - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- if (display_component->page_id == current_page_id and !display_component->color_is_updated) { disp1->set_component_font_color(display_component->component, display_component->color); display_component->color_is_updated = true; } - nextion_queue_del->execute(); - id: display_component_send_font mode: queued @@ -387,14 +381,12 @@ script: - lambda: return display_component->font != UINT8_MAX; - lambda: return not display_component->font_is_updated; then: - - script.execute: nextion_queue_add - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- if (display_component->page_id == current_page_id and !display_component->font_is_updated) { disp1->set_component_font(display_component->component, display_component->font); display_component->font_is_updated = true; } - nextion_queue_del->execute(); - id: display_component_send_text mode: queued @@ -406,14 +398,12 @@ script: - lambda: return display_component->page_id == current_page_id; - lambda: return not display_component->text_is_updated; then: - - script.execute: nextion_queue_add - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- if (display_component->page_id == current_page_id and !display_component->text_is_updated) { disp1->set_component_text(display_component->component, display_component->text); display_component->text_is_updated = true; } - nextion_queue_del->execute(); - id: display_component_send_visibility mode: queued @@ -425,15 +415,13 @@ script: - lambda: return display_component->page_id == current_page_id; - lambda: return not display_component->visible_is_updated; then: - - script.execute: nextion_queue_add - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- if (display_component->page_id == current_page_id and !display_component->visible_is_updated) { disp1->send_command_printf("vis %s,%i", display_component->component, display_component->visible ? 1 : 0); display_component->visible_is_updated = true; } - nextion_queue_del->execute(); - id: display_component_update_color mode: parallel @@ -491,6 +479,26 @@ script: if (!display_component->visible_is_updated) display_component_send_visibility->execute(display_component); + - id: display_delay_increment + mode: restart + then: + - lambda: |- + screen_power->turn_off(); + ESP_LOGE("script.display_delay_increment", "Nextion reported a buffer overflow"); + ESP_LOGE("script.display_delay_increment", "Increasing the delay factor..."); + - number.increment: + id: display_delay + cycle: false + - if: + condition: + - lambda: return global_preferences->sync(); + then: + - lambda: |- + ESP_LOGE("script.display_delay_increment", + "Restarting ESP to avoid getting out of sync with Nextion"); + - delay: 2s + - lambda: arch_restart(); + - id: display_wrapped_text mode: queued max_runs: 15 @@ -541,7 +549,7 @@ script: // Report Nextion status nextion_init->publish_state(nextion_init->state and disp1->is_setup()); ESP_LOGCONFIG(TAG, "Nextion:"); - ESP_LOGCONFIG(TAG, " Delay factor: %" PRIu8, static_cast(nextion_queue_delay_factor->state)); + ESP_LOGCONFIG(TAG, " Delay factor: %" PRIu8, static_cast(display_delay->state)); ESP_LOGCONFIG(TAG, " Queue size: %d", disp1->queue_size()); if (disp1->is_setup()) ESP_LOGCONFIG(TAG, " Is setup: True"); @@ -588,7 +596,7 @@ script: id(display_charset) = json["charset"].as(); ESP_LOGI(TAG, " Display mode: %" PRIu8, id(display_mode)); ESP_LOGI(TAG, " Display charset: %" PRIu8, id(display_charset)); - send_command->execute("tm_esphome.en=0"); + disp1->send_command("tm_esphome.en=0"); boot_progress->execute(${BOOT_STEP_HW_DISPLAY}, "HW Display"); } else { // Generic event @@ -624,59 +632,6 @@ script: # Extended by: # - nspanel_esphome_core_hw_display_timers.yaml - - id: nextion_queue_add - mode: queued - then: - - lambda: |- - id(nextion_queue)++; - if (id(nextion_queue) > 128) - nextion_queue_reset->execute(); - - - id: nextion_queue_del - mode: queued - then: - - lambda: |- - if (id(nextion_queue) > 0) - id(nextion_queue)--; - - - id: nextion_queue_delay_factor_increment - mode: restart - then: - - lambda: |- - screen_power->turn_off(); - ESP_LOGE("script.nextion_queue_delay_factor_increment", "Nextion reported a buffer overflow"); - ESP_LOGE("script.nextion_queue_delay_factor_increment", "Increasing the delay factor..."); - - number.increment: - id: nextion_queue_delay_factor - cycle: false - - if: - condition: - - lambda: return global_preferences->sync(); - then: - - lambda: |- - ESP_LOGE("script.nextion_queue_delay_factor_increment", - "Restarting ESP to avoid getting out of sync with Nextion"); - - delay: 2s - - lambda: arch_restart(); - - - id: nextion_queue_reset - mode: restart - then: - - lambda: |- - display_component_send->stop(); - display_component_send_color->stop(); - display_component_send_font->stop(); - display_component_send_text->stop(); - display_component_send_visibility->stop(); - set_component_font->stop(); - set_component_font_color->stop(); - set_component_pic->stop(); - set_component_picc->stop(); - set_component_text->stop(); - set_component_value->stop(); - set_component_visibility->stop(); - id(nextion_queue) = 0; - - id: page_changed parameters: new_page_id: uint8_t @@ -696,9 +651,6 @@ script: ESP_LOGI("display.disp1.on_page", "Page changed from \"%s\" to \"%s\"", page_names[previous_page_id], page_names[new_page_id]); - // Clear the buffer when a new page opens - nextion_queue_reset->execute(); - // Reset entity_id when it does not apply if (not is_page_in_group(ENTITY_ID_PAGE_MASK, new_page_id)) { detailed_entity->publish_state(""); @@ -730,16 +682,6 @@ script: display_component_send->execute(display_component); } - - id: send_command - mode: queued - parameters: - cmd: string - then: - - lambda: |- - nextion_queue_add->execute(); - disp1->send_command(cmd.c_str()); - nextion_queue_del->execute(); - - id: set_baud_rate mode: restart parameters: @@ -778,11 +720,10 @@ script: parameters: brightness: uint8_t then: + - delay: !lambda return display_delay->state; - lambda: |- - nextion_queue_add->execute(); disp1->set_backlight_brightness(brightness / 100.0f); current_brightness->update(); - nextion_queue_del->execute(); - id: set_component_font mode: parallel @@ -791,15 +732,10 @@ script: component: string font: uint8_t then: - - script.execute: nextion_queue_add - - wait_until: - condition: - - lambda: return (page_id == current_page_id); - timeout: 2s - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- - disp1->set_component_font(component.c_str(), font); - nextion_queue_del->execute(); + if (page_id == current_page_id) + disp1->set_component_font(component.c_str(), font); - id: set_component_font_color mode: parallel @@ -808,16 +744,10 @@ script: component: string color: uint16_t then: - - script.execute: nextion_queue_add - - wait_until: - condition: - - lambda: return (page_id == current_page_id); - timeout: 2s - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- if (page_id == current_page_id) disp1->set_component_font_color(component.c_str(), color); - nextion_queue_del->execute(); - id: set_component_picc mode: parallel @@ -826,16 +756,10 @@ script: component: string picc: uint8_t then: - - script.execute: nextion_queue_add - - wait_until: - condition: - - lambda: return (page_id == current_page_id); - timeout: 2s - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- if (page_id == current_page_id) disp1->set_component_picc(component.c_str(), picc); - nextion_queue_del->execute(); - id: set_component_foreground_color mode: parallel @@ -853,16 +777,10 @@ script: component: string pic: uint8_t then: - - script.execute: nextion_queue_add - - wait_until: - condition: - - lambda: return (page_id == current_page_id); - timeout: 2s - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- if (page_id == current_page_id) disp1->set_component_pic(component.c_str(), pic); - nextion_queue_del->execute(); - id: set_component_text mode: parallel @@ -871,16 +789,10 @@ script: component: string text: string then: - - script.execute: nextion_queue_add - - wait_until: - condition: - - lambda: return (page_id == current_page_id); - timeout: 2s - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- if (page_id == current_page_id) disp1->set_component_text(component.c_str(), text.c_str()); - nextion_queue_del->execute(); - id: set_component_value mode: parallel @@ -889,16 +801,10 @@ script: component: string val: int then: - - script.execute: nextion_queue_add - - wait_until: - condition: - - lambda: return (page_id == current_page_id); - timeout: 2s - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- if (page_id == current_page_id) disp1->set_component_value(component.c_str(), val); - nextion_queue_del->execute(); - id: set_component_visibility mode: parallel @@ -907,19 +813,10 @@ script: component: string show: bool then: - - script.execute: nextion_queue_add - - wait_until: - condition: - - lambda: return (page_id == current_page_id); - timeout: 2s - - if: - condition: - - lambda: return (page_id == current_page_id); - then: - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); - - lambda: |- - disp1->send_command_printf("vis %s,%i", component.c_str(), show ? 1 : 0); - - script.execute: nextion_queue_del + - delay: !lambda return display_delay->state; + - lambda: |- + if (page_id == current_page_id) + disp1->send_command_printf("vis %s,%i", component.c_str(), show ? 1 : 0); - id: !extend set_var_number then: @@ -939,11 +836,9 @@ script: variable: string val: int then: - - script.execute: nextion_queue_add - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- disp1->send_command_printf("%s=%i", variable.c_str(), val); - nextion_queue_del->execute(); - id: !extend stop_all then: @@ -958,7 +853,6 @@ script: event_from_display->stop(); goto_page_id->stop(); page_changed->stop(); - send_command->stop(); set_baud_rate->stop(); set_brightness->stop(); set_component_font_color->stop(); diff --git a/esphome/nspanel_esphome_core_page_blank.yaml b/esphome/nspanel_esphome_core_page_blank.yaml index 48279445..bc6d5786 100644 --- a/esphome/nspanel_esphome_core_page_blank.yaml +++ b/esphome/nspanel_esphome_core_page_blank.yaml @@ -30,7 +30,7 @@ script: mode: restart then: - lambda: |- - send_command->execute("tm_esphome.en=0"); + disp1->send_command("tm_esphome.en=0"); set_component_text->execute(${PAGE_ID_BLANK}, "esp_version", "FW: ${version}"); // ESPHome version #ifdef ARDUINO set_component_text->execute(${PAGE_ID_BLANK}, "framework", "Arduino"); diff --git a/esphome/nspanel_esphome_core_page_boot.yaml b/esphome/nspanel_esphome_core_page_boot.yaml index 40e28e03..7321c588 100644 --- a/esphome/nspanel_esphome_core_page_boot.yaml +++ b/esphome/nspanel_esphome_core_page_boot.yaml @@ -62,7 +62,7 @@ script: then: - lambda: |- page_boot_exit->execute(); - send_command->execute("esphome=0"); + disp1->send_command("esphome=0"); set_component_text->execute(${PAGE_ID_BOOT}, "esp_version", "FW: ${version}"); // ESPHome version #ifdef ARDUINO set_component_text->execute(${PAGE_ID_BOOT}, "sys_framework", "Framework: Arduino"); diff --git a/esphome/nspanel_esphome_core_page_buttons.yaml b/esphome/nspanel_esphome_core_page_buttons.yaml index a9af1d3a..5fc1104d 100644 --- a/esphome/nspanel_esphome_core_page_buttons.yaml +++ b/esphome/nspanel_esphome_core_page_buttons.yaml @@ -119,7 +119,7 @@ script: - repeat: count: 8 then: - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- const uint8_t index = (page_number-1)*8 + iteration; if (buttonpage_buttons[index].visible) { diff --git a/esphome/nspanel_esphome_core_page_entities.yaml b/esphome/nspanel_esphome_core_page_entities.yaml index 7684001c..640a11f5 100644 --- a/esphome/nspanel_esphome_core_page_entities.yaml +++ b/esphome/nspanel_esphome_core_page_entities.yaml @@ -54,7 +54,7 @@ script: - repeat: count: 8 then: - - delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue); + - delay: !lambda return display_delay->state; - lambda: |- disp1->send_command_printf("value%02" PRIu32 ".xcen=%" PRIu8, iteration, id(page_entity_value_horizontal_alignment)); diff --git a/esphome/nspanel_esphome_core_page_media_player.yaml b/esphome/nspanel_esphome_core_page_media_player.yaml index 0830d5c4..de838514 100644 --- a/esphome/nspanel_esphome_core_page_media_player.yaml +++ b/esphome/nspanel_esphome_core_page_media_player.yaml @@ -149,7 +149,7 @@ api: display_component_update_visibility->execute(media_player_time_total, true); display_component_update_visibility->execute(media_player_time_progress, true); } else { - send_command->execute("prg_timer.en=0"); + disp1->send_command("prg_timer.en=0"); display_component_update_visibility->execute(media_player_time_current, false); display_component_update_visibility->execute(media_player_time_total, false); display_component_update_visibility->execute(media_player_time_progress, false); From 6e1c8b1b44c844ed598b74823487e6872d55b020 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 24 Nov 2024 11:58:15 +0100 Subject: [PATCH 3/9] Add instructions about DNS failing --- docs/tft_upload.md | 110 +++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 74 deletions(-) diff --git a/docs/tft_upload.md b/docs/tft_upload.md index 7c7e9f26..c0bcd9ba 100644 --- a/docs/tft_upload.md +++ b/docs/tft_upload.md @@ -1,70 +1,44 @@ -# Troubleshooting TFT transfer +# Troubleshooting TFT Transfer > [!IMPORTANT] -> If you have already installed the version "nspanel-lovelace-ui" from joBr99 on your NSPanel, an intermediate step is necessary - otherwise, -> it is not possible to install this or any other version. +> If you have already installed the version "nspanel-lovelace-ui" from joBr99 on your NSPanel, an intermediate step is necessary - otherwise, it is not possible to install this or any other version. > > See [Common Issues | TFT Upload when NSPanel Lovelace UI has been installed](howto.md) ## Common Issues and Troubleshooting -The following is a list of common issues affecting the TFT upload, along with suggested solutions. -These issues are not specific to the NSPanel HA Blueprint project but are common to Nextion displays and ESPHome. +The following is a list of common issues affecting the TFT upload, along with suggested solutions. These issues are not specific to the NSPanel HA Blueprint project but are common to Nextion displays and ESPHome. ### Resolving "System data ERROR!" on Display ![System Data ERROR](pics/us_system_data_error_upside_down.jpg) #### Don't Panic! -The "System data ERROR!" message, sometimes displayed upside-down, appears when a TFT upload is incomplete. -While it may seem alarming, this message simply indicates that the TFT file on the display is invalid. -A successful TFT upload will resolve this issue. +The "System data ERROR!" message, sometimes displayed upside-down, appears when a TFT upload is incomplete. While it may seem alarming, this message simply indicates that the TFT file on the display is invalid. A successful TFT upload will resolve this issue. ### Resolving "Model does not match" on Display ![Model Does Not Match](pics/model_does_not_match.jpg) -This is one more case where the message sounds more alarming than it actually is. -Often, a simple reboot of the panel is enough to restore the previous TFT file. -This issue typically arises from a corrupt TFT file or server response issues. -For troubleshooting, refer to the following sections: +This is another case where the message sounds more alarming than it actually is. Often, a simple reboot of the panel is enough to restore the previous TFT file. This issue typically arises from a corrupt TFT file or server response issues. For troubleshooting, refer to the following sections: - [Using a Local Source (Home Assistant)](#using-a-local-source-home-assistant) - [HTTP Instead of HTTPS](#http-instead-of-https) - Especially important when using the `arduino` framework. - [Check the File Size by Downloading to Your Computer](#check-the-file-size-by-downloading-to-your-computer) > [!TIP] -> If the TFT transfer has started, your panel might not respond to the reset button on the -> device's page in Home Assistant or to holding the hardware button for 15 seconds. -> In such cases, you can either power cycle your device using the room's relay on your electrical plate -> or use a pin to press the hardware restart button in a small hole behind the device. -> ![Image](pics/eu_reset_button.png) +> If the TFT transfer has started, your panel might not respond to the reset button on the device's page in Home Assistant or to holding the hardware button for 15 seconds. In such cases, you can either power cycle your device using the room's relay on your electrical plate or use a pin to press the hardware restart button in a small hole behind the device. ![Image](pics/eu_reset_button.png) -### If using manual IP, make sure you have a DNS server configured -At least one DNS server is required to enable TFT transfer direcly from GitHub, otherwise use `nextion_update_base_url`. -If you are setting up a manual IP as a customization, please remember to add a valid DNS server for your panel. +### If Using Manual IP, Ensure DNS Server is Configured +At least one DNS server is required to enable TFT transfer directly from GitHub; otherwise, use `nextion_update_base_url`. If you are setting up a manual IP as a customization, please remember to add a valid DNS server for your panel. ### Using the `nspanel_blank.tft` File to Assist -Many TFT upload problems are associated with the Nextion Active Reparse Mode, -which is used in some implementations like the original Sonoff firmware or other popular custom firmwares. -Installing any TFT file from this project will disable this mode. -However, the size of a typical TFT file (7 to 12 Mb) can be challenging for devices with limited memory, -such as the ESP32 in your panel, especially over a serial interface. +Many TFT upload problems are associated with the Nextion Active Reparse Mode, used in some implementations like the original Sonoff firmware or other popular custom firmwares. Installing any TFT file from this project will disable this mode. However, the size of a typical TFT file (7 to 12 Mb) can be challenging for devices with limited memory, such as the ESP32 in your panel, especially over a serial interface. -To facilitate the process, we've created the `nspanel_blank.tft` file. -Although it's not a fully functional TFT file, it's sufficient to disable the Reparse Mode and is significantly smaller (less than 300kb). +To facilitate the process, we've created the `nspanel_blank.tft` file. Although it's not a fully functional TFT file, it's sufficient to disable the Reparse Mode and is significantly smaller (less than 300kb). If you encounter issues, try installing the `nspanel_blank.tft` file first to make it easier to subsequently install larger, fully functional TFT files. -If you encounter any issues, try installing the `nspanel_blank.tft` file first. This should make it easier to subsequently install larger, fully functional TFT files. +### Enabling TFT Upload Components +If the components necessary for uploading a TFT file are not available in the device's page under **Settings** > **Devices & services** > **ESPHome**, and you cannot simply enable the entity on its settings, try removing the device integration from there, restart your Home Assistant instance, and then add the device again. It should be automatically detected as a new integration, but if not, click the **Add integration** button, select **ESPHome**, add the device hostname or IP address, and follow the steps required. -### Enabling TFT upload components -If the components necessary for uploading a TFT file are not available in the device's page under **Settings** > **Devices & services** > **ESPHome**, -and you cannot simply enable the entity on it's settings, please try removing the device integration from there, restart your Home Assistant instance and then add the device again. -It should be automatically detected as a new integration, but if this is not happening, -click the **Add integration** button, select **ESPHome**, add the device hostname or IP address and follow the steps required. - -### Wait a Bit Before Starting the TFT Upload +### Wait Before Starting the TFT Upload - **Issue**: The Nextion display might not connect to ESPHome immediately after boot. -- **Solution**: Wait up to 2 minutes for the boot script to complete. -If you are already using a TFT from this project, the display of ESPHome version and the framework used (`arduino` vs `esp-idf`) is an indication that a communication was established. -If you haven't installed any TFT yet, look for Nextion related messages on ESPHome logs. -- **Additional Guidance**: Knowing when the device is fully booted and ready to accept the TFT upload can prevent many issues. -Observe any changes in the display or logs indicators to ensure the device is ready. +- **Solution**: Wait up to 2 minutes for the boot script to complete. If you are already using a TFT from this project, the display of ESPHome version and the framework used (`arduino` vs `esp-idf`) is an indication that communication was established. If you haven't installed any TFT yet, look for Nextion-related messages in ESPHome logs. ### Using a Local Source (Home Assistant) - **Issue**: Problems with downloading the TFT from GitHub. @@ -79,8 +53,7 @@ Observe any changes in the display or logs indicators to ensure the device is re substitutions: nextion_update_base_url: "http://homeassistant.local:8123/local/nspanel/" ``` -4. Ensure your files are organized by version in sub-folders (e.g., `/v4.4.0/`), as the system appends the version - to the base URL automatically. +4. Ensure your files are organized by version in sub-folders (e.g., `/v4.4.0/`), as the system appends the version to the base URL automatically. ### HTTP Instead of HTTPS - **Issue**: HTTPS connections may be problematic with ESP, especially when using the `arduino` framework. @@ -90,13 +63,10 @@ Observe any changes in the display or logs indicators to ensure the device is re - HTTP provides more stable connections for ESP devices in this context. - Replace `https` with `http` in your URLs, and ensure your server supports non-secure connections. -By following these steps, you can avoid issues with GitHub downloads and enjoy a more reliable file transfer process. - ### Remove Customizations - **Issue**: Customizations like `bluetooth_proxy` and `ble_tracker` may interfere with the upload. - **Solution**: Temporarily remove any customizations to free up memory. -- **How to Remove Customizations**: Identify any additional features you've added and remove them from your configuration file. -Pay special attention to memory-intensive customizations. +- **How to Remove Customizations**: Identify any additional features you've added and remove them from your configuration file. Pay special attention to memory-intensive customizations. ### Use IP Address Instead of DNS - **Issue**: DNS may cause connection problems. @@ -106,27 +76,20 @@ Pay special attention to memory-intensive customizations. ### Check the File Size by Downloading to Your Computer - **Issue**: Ensuring the file size matches the GitHub version. - **Solution**: Use the same URL you provided to ESPHome to download the file on your computer and compare sizes. -- **Verification Steps**: Download the file, then right-click and select 'Properties' to check the size. -Compare this with the size listed on GitHub or from the file you downlodaded directly from GitHub. +- **Verification Steps**: Download the file, then right-click and select 'Properties' to check the size. Compare this with the size listed on GitHub. ### Power Cycle Your Panel - **Issue**: General troubleshooting. -- **Solution**: Turn off the power supply, wait for a moment, and then power it back on. -If your panel is already installed in the wall, you can often power cycle it by switching the relay connected to your panel in your electricity relay's panel. -- **How Long to Wait**: It's recommended to wait at least 30 seconds before turning the power back on. -This duration helps ensure that the system resets to a clean state. +- **Solution**: Turn off the power supply, wait for a moment, and then power it back on. If your panel is already installed in the wall, you can often power cycle it by switching the relay connected to your panel in your electricity relay's panel. +- **How Long to Wait**: Wait at least 30 seconds before turning the power back on to ensure the system resets to a clean state. > [!TIP] -> If you don't have easy access to your relay's panel, an alternative is to -> use a pin to press the hardware restart button, located in a small hole behind the device. -> Although this action does not replicate a full power cycle, it might resolve the issue in some cases. -> ![Hardware Reset Button](pics/eu_reset_button.png) +> If you don't have easy access to your relay's panel, use a pin to press the hardware restart button, located in a small hole behind the device. Although this action does not replicate a full power cycle, it might resolve the issue in some cases. ![Hardware Reset Button](pics/eu_reset_button.png) -### Consider changing the framework -- **Issue**: You might be facing some situation where the transfer engine used by your framework cannot handle it properly. +### Consider Changing the Framework +- **Issue**: The transfer engine used by your framework cannot handle it properly. - **Solution**: Temporarily switch between the frameworks. -- **Additional Guidance**: This project supports both `arduino` (ESPHome default) or `esp-idf` (this project default) frameworks. -The upload TFT engines have some differences, so changing the framework may solve some issue. +- **Additional Guidance**: This project supports both `arduino` (ESPHome default) and `esp-idf` (this project default) frameworks. The upload TFT engines have some differences, so changing the framework may solve some issues. You can set the framework you want by adding this to your ESPHome yaml: @@ -144,19 +107,18 @@ esp32: type: arduino ``` -### Flash your panel again -- **Issue**: Your firmware might be missing some important library, you may be using an outdated version or the ESP may be out of memory. +### Flash Your Panel Again +- **Issue**: Your firmware might be missing some important library, you may be using an outdated version, or the ESP may be out of memory. - **Solution**: Remove all add-ons and non-essential customization and flash your panel again. - **Step-by-Step Guide**: - 1. Look your yaml file and commment out all the customization (typically on a section name "My customizations") and any of the remote files other than `nspanel_esphome.yaml`. - 2. Flash your panel with the new cleaner yaml. You can do this over the air/wirelessly, although it is recommended to use serial when changing between frameworks - 3. Try to update the TFT file again + 1. Look at your yaml file and comment out all the customization (typically in a section named "My customizations") and any of the remote files other than `nspanel_esphome.yaml`. + 2. Flash your panel with the new cleaner yaml. You can do this over the air/wirelessly, although it is recommended to use serial when changing between frameworks. + 3. Try to update the TFT file again. 4. Add the add-ons and removed customization back and then flash it again. -### Try an alternative http service -- **Issue**: Your current http server may be overloaded. -- **Solution**: Try another http server installed in your computer. -There are many options available for free to run under you local Windows, MAC or Linux machine. +### Try an Alternative HTTP Service +- **Issue**: Your current HTTP server may be overloaded. +- **Solution**: Try another HTTP server installed on your computer. Many free options are available to run on your local Windows, MAC, or Linux machine. - **Examples**: Just to name some: | Solution | Website | Supported OSs | Pros | Cons | |----------|---------|---------------|------|------| @@ -169,10 +131,10 @@ There are many options available for free to run under you local Windows, MAC or After troubleshooting, if issues persist, consult the [Issues](https://github.com/Blackymas/NSPanel_HA_Blueprint/issues) and feel free to create a new one asking for more personalized assistance. Please share as much info as possible, like: -1. Describing (or a picture of) what is in your screen -2. Are updating from a previous version of this same project, or coming from another NSPanel customization (which one?) or customizing for the first time a panel with original Sonoff settings? -3. Please share the ESPHome logs from when your panel starts to the moment the upload fails. -4. Describe what you have already tried. +1. Description (or a picture) of what is on your screen. +2. Are you updating from a previous version of this project, coming from another NSPanel customization (which one?), or customizing a panel with the original Sonoff settings for the first time? +3. ESPHome logs from when your panel starts to the moment the upload fails. +4. A description of what you have already tried. -## Important note +## Important Note Remember, these steps are a guideline and might vary slightly based on your specific setup and previously installed system. From 00215ace0560822e44d3eb32c855786252a462bf Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 24 Nov 2024 12:17:05 +0100 Subject: [PATCH 4/9] Remove `Update TFT display - Baud rate` --- ReleaseNotes.md | 4 ++ docs/tft_upload.md | 11 +++++ esphome/nspanel_esphome_addon_upload_tft.yaml | 46 ++----------------- 3 files changed, 20 insertions(+), 41 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index df0de1b6..38e225aa 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -65,6 +65,10 @@ between ESPHome and Nextion. Visit the updated [API documentation](docs/api.md) 3. **Notification unread switch replaced** The "**Notification unread**" switch is now a binary sensor. +4. **Selector "Update TFT display - Baud rate" removed** + The baud rate selector has been removed as full support for all baud rates used by Nextion makes it redundant. + Communication now adapts automatically to the required baud rate, simplifying configuration. + ### Customizations Updated scripts require adjustments to these customizations: - [Sleep & Wake-up buttons](docs/customization.md#sleep--wake-up-buttons) diff --git a/docs/tft_upload.md b/docs/tft_upload.md index c0bcd9ba..2ee74071 100644 --- a/docs/tft_upload.md +++ b/docs/tft_upload.md @@ -25,6 +25,16 @@ This is another case where the message sounds more alarming than it actually is. > [!TIP] > If the TFT transfer has started, your panel might not respond to the reset button on the device's page in Home Assistant or to holding the hardware button for 15 seconds. In such cases, you can either power cycle your device using the room's relay on your electrical plate or use a pin to press the hardware restart button in a small hole behind the device. ![Image](pics/eu_reset_button.png) +### DNS Issues Causing Crashes +If the DNS server fails to resolve the file URL, the device may crash during the TFT upload process. To prevent this, ensure that a reliable DNS server is configured in your network settings. Alternatively, you can use a local HTTP server to host the TFT file, which can be set up using the `nextion_update_base_url`. + +- **Solution**: Check your router settings and change the DNS server to a more reliable one, such as Google DNS (`8.8.8.8`) or Cloudflare (`1.1.1.1`). Hosting the file locally will also reduce dependency on external DNS resolution. + +### Baud Rate Mismatch Issues +A baud rate mismatch can prevent ESPHome from sending the update command to the Nextion display, resulting in the message "Nextion is not connected!" in the logs. + +- **Solution**: Try each available baud rate until you find the correct one. The baud rate can be configured under the device's page in Home Assistant (Settings > Devices & services > ESPHome). It is listed as a hidden entity under "Configuration" and named "Baud rate". + ### If Using Manual IP, Ensure DNS Server is Configured At least one DNS server is required to enable TFT transfer directly from GitHub; otherwise, use `nextion_update_base_url`. If you are setting up a manual IP as a customization, please remember to add a valid DNS server for your panel. @@ -138,3 +148,4 @@ Please share as much info as possible, like: ## Important Note Remember, these steps are a guideline and might vary slightly based on your specific setup and previously installed system. + diff --git a/esphome/nspanel_esphome_addon_upload_tft.yaml b/esphome/nspanel_esphome_addon_upload_tft.yaml index 70354f35..0e65c6a1 100644 --- a/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -264,9 +264,8 @@ script: static const char *const TAG = "addon_upload_tft.script.upload_tft"; // The upload process starts here ESP_LOGD(TAG, "Starting the upload script"); - ESP_LOGD(TAG, " Valid TFT: %s", YESNO((id(display_mode) > 0 and id(display_mode) < 4))); - ESP_LOGD(TAG, " Current baud rate: %" PRIu32 " bps", tf_uart->get_baud_rate()); - ESP_LOGD(TAG, " Target upload baud rate: %s bps", tft_upload_baud_rate->state.c_str()); + ESP_LOGD(TAG, " Valid TFT: %s", YESNO((id(display_mode) > 0 and id(display_mode) < 4))); + ESP_LOGD(TAG, " Baud rate: %" PRIu32 " bps", tf_uart->get_baud_rate()); ESP_LOGD(TAG, " Upload URL: %s", url.c_str()); disp1->set_tft_url(url.c_str()); @@ -338,26 +337,16 @@ script: - lambda: return (id(display_mode) > 0 and id(display_mode) < 4); timeout: 1s - ### Attempt twice at the target baud rate + ### Attempt twice at the current baud rate - script.execute: id: upload_tft_sequence_attempt - baud_rate: !lambda return stoi(tft_upload_baud_rate->state); + baud_rate: 0 - script.wait: upload_tft_sequence_attempt - ### Attempt twice at the original baud rate - - if: - condition: - - lambda: return (stoi(tft_upload_baud_rate->state) != tf_uart->get_baud_rate()); - then: - - script.execute: - id: upload_tft_sequence_attempt - baud_rate: 0 - - script.wait: upload_tft_sequence_attempt - ### Attempt twice at the Nextion's default baud rate (115200bps) - if: condition: - - lambda: return (stoi(tft_upload_baud_rate->state) != 115200 and tf_uart->get_baud_rate() != 115200); + - lambda: return (tf_uart->get_baud_rate() != 115200); then: - script.execute: id: upload_tft_sequence_attempt @@ -494,31 +483,6 @@ select: disabled_by_default: false icon: mdi:file-sync - - id: tft_upload_baud_rate - name: Update TFT display - Baud rate - platform: template - options: - - "2400" - - "4800" - - "9600" - - "19200" - - "31250" - - "38400" - - "57600" - - "115200" - - "230400" - - "250000" - - "256000" - - "512000" - - "921600" - initial_option: "921600" - optimistic: true - restore_value: true - internal: false - entity_category: config - disabled_by_default: true - icon: mdi:swap-horizontal - switch: - id: tft_update_automatically name: Update TFT automatically From bc814e30513fe09e83ad01875765414b49c533ab Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 24 Nov 2024 13:05:29 +0100 Subject: [PATCH 5/9] Lint --- docs/tft_upload.md | 57 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/docs/tft_upload.md b/docs/tft_upload.md index 2ee74071..6d072a5d 100644 --- a/docs/tft_upload.md +++ b/docs/tft_upload.md @@ -23,32 +23,49 @@ This is another case where the message sounds more alarming than it actually is. - [Check the File Size by Downloading to Your Computer](#check-the-file-size-by-downloading-to-your-computer) > [!TIP] -> If the TFT transfer has started, your panel might not respond to the reset button on the device's page in Home Assistant or to holding the hardware button for 15 seconds. In such cases, you can either power cycle your device using the room's relay on your electrical plate or use a pin to press the hardware restart button in a small hole behind the device. ![Image](pics/eu_reset_button.png) +> If the TFT transfer has started, your panel might not respond to the reset button on the device's page in Home Assistant or to holding the hardware button for 15 seconds. +In such cases, you can either power cycle your device using the room's relay on your electrical plate or use a pin to press the hardware restart button in a small hole behind the device. +> +>![Image](pics/eu_reset_button.png) ### DNS Issues Causing Crashes -If the DNS server fails to resolve the file URL, the device may crash during the TFT upload process. To prevent this, ensure that a reliable DNS server is configured in your network settings. Alternatively, you can use a local HTTP server to host the TFT file, which can be set up using the `nextion_update_base_url`. +If the DNS server fails to resolve the file URL, the device may crash during the TFT upload process. To prevent this, ensure that a reliable DNS server is configured in your network settings. +Alternatively, you can use a local HTTP server to host the TFT file, which can be set up using the `nextion_update_base_url`. -- **Solution**: Check your router settings and change the DNS server to a more reliable one, such as Google DNS (`8.8.8.8`) or Cloudflare (`1.1.1.1`). Hosting the file locally will also reduce dependency on external DNS resolution. +- **Solution**: Check your router settings and change the DNS server to a more reliable one, such as Google DNS (`8.8.8.8`) or Cloudflare (`1.1.1.1`). +Hosting the file locally will also reduce dependency on external DNS resolution. ### Baud Rate Mismatch Issues A baud rate mismatch can prevent ESPHome from sending the update command to the Nextion display, resulting in the message "Nextion is not connected!" in the logs. -- **Solution**: Try each available baud rate until you find the correct one. The baud rate can be configured under the device's page in Home Assistant (Settings > Devices & services > ESPHome). It is listed as a hidden entity under "Configuration" and named "Baud rate". +- **Solution**: Try each available baud rate until you find the correct one. + The baud rate can be configured under the device's page in Home Assistant (Settings > Devices & services > ESPHome). + It is listed as a hidden entity under "Configuration" and named "Baud rate". ### If Using Manual IP, Ensure DNS Server is Configured -At least one DNS server is required to enable TFT transfer directly from GitHub; otherwise, use `nextion_update_base_url`. If you are setting up a manual IP as a customization, please remember to add a valid DNS server for your panel. +At least one DNS server is required to enable TFT transfer directly from GitHub; otherwise, use `nextion_update_base_url`. +If you are setting up a manual IP as a customization, please remember to add a valid DNS server for your panel. ### Using the `nspanel_blank.tft` File to Assist -Many TFT upload problems are associated with the Nextion Active Reparse Mode, used in some implementations like the original Sonoff firmware or other popular custom firmwares. Installing any TFT file from this project will disable this mode. However, the size of a typical TFT file (7 to 12 Mb) can be challenging for devices with limited memory, such as the ESP32 in your panel, especially over a serial interface. +Many TFT upload problems are associated with the Nextion Active Reparse Mode, used in some implementations like the original Sonoff firmware or other popular custom firmwares. +Installing any TFT file from this project will disable this mode. +However, the size of a typical TFT file (7 to 12 Mb) can be challenging for devices with limited memory, such as the ESP32 in your panel, especially over a serial interface. -To facilitate the process, we've created the `nspanel_blank.tft` file. Although it's not a fully functional TFT file, it's sufficient to disable the Reparse Mode and is significantly smaller (less than 300kb). If you encounter issues, try installing the `nspanel_blank.tft` file first to make it easier to subsequently install larger, fully functional TFT files. +To facilitate the process, we've created the `nspanel_blank.tft` file. +Although it's not a fully functional TFT file, it's sufficient to disable the Reparse Mode and is significantly smaller (less than 300kb). +If you encounter issues, try installing the `nspanel_blank.tft` file first to make it easier to subsequently install larger, fully functional TFT files. ### Enabling TFT Upload Components -If the components necessary for uploading a TFT file are not available in the device's page under **Settings** > **Devices & services** > **ESPHome**, and you cannot simply enable the entity on its settings, try removing the device integration from there, restart your Home Assistant instance, and then add the device again. It should be automatically detected as a new integration, but if not, click the **Add integration** button, select **ESPHome**, add the device hostname or IP address, and follow the steps required. +If the components necessary for uploading a TFT file are not available in the device's page under **Settings** > **Devices & services** > **ESPHome**, +and you cannot simply enable the entity on its settings, try removing the device integration from there, restart your Home Assistant instance, and then add the device again. +It should be automatically detected as a new integration, but if not, click the **Add integration** button, select **ESPHome**, +add the device hostname or IP address, and follow the steps required. ### Wait Before Starting the TFT Upload - **Issue**: The Nextion display might not connect to ESPHome immediately after boot. -- **Solution**: Wait up to 2 minutes for the boot script to complete. If you are already using a TFT from this project, the display of ESPHome version and the framework used (`arduino` vs `esp-idf`) is an indication that communication was established. If you haven't installed any TFT yet, look for Nextion-related messages in ESPHome logs. +- **Solution**: Wait up to 2 minutes for the boot script to complete. If you are already using a TFT from this project, + the display of ESPHome version and the framework used (`arduino` vs `esp-idf`) is an indication that communication was established. + If you haven't installed any TFT yet, look for Nextion-related messages in ESPHome logs. ### Using a Local Source (Home Assistant) - **Issue**: Problems with downloading the TFT from GitHub. @@ -76,7 +93,8 @@ If the components necessary for uploading a TFT file are not available in the de ### Remove Customizations - **Issue**: Customizations like `bluetooth_proxy` and `ble_tracker` may interfere with the upload. - **Solution**: Temporarily remove any customizations to free up memory. -- **How to Remove Customizations**: Identify any additional features you've added and remove them from your configuration file. Pay special attention to memory-intensive customizations. +- **How to Remove Customizations**: Identify any additional features you've added and remove them from your configuration file. + Pay special attention to memory-intensive customizations. ### Use IP Address Instead of DNS - **Issue**: DNS may cause connection problems. @@ -90,16 +108,21 @@ If the components necessary for uploading a TFT file are not available in the de ### Power Cycle Your Panel - **Issue**: General troubleshooting. -- **Solution**: Turn off the power supply, wait for a moment, and then power it back on. If your panel is already installed in the wall, you can often power cycle it by switching the relay connected to your panel in your electricity relay's panel. +- **Solution**: Turn off the power supply, wait for a moment, and then power it back on. + If your panel is already installed in the wall, you can often power cycle it by switching the relay connected to your panel in your electricity relay's panel. - **How Long to Wait**: Wait at least 30 seconds before turning the power back on to ensure the system resets to a clean state. > [!TIP] -> If you don't have easy access to your relay's panel, use a pin to press the hardware restart button, located in a small hole behind the device. Although this action does not replicate a full power cycle, it might resolve the issue in some cases. ![Hardware Reset Button](pics/eu_reset_button.png) +> If you don't have easy access to your relay's panel, use a pin to press the hardware restart button, located in a small hole behind the device. +> Although this action does not replicate a full power cycle, it might resolve the issue in some cases. +> +>![Hardware Reset Button](pics/eu_reset_button.png) ### Consider Changing the Framework - **Issue**: The transfer engine used by your framework cannot handle it properly. - **Solution**: Temporarily switch between the frameworks. -- **Additional Guidance**: This project supports both `arduino` (ESPHome default) and `esp-idf` (this project default) frameworks. The upload TFT engines have some differences, so changing the framework may solve some issues. +- **Additional Guidance**: This project supports both `arduino` (ESPHome default) and `esp-idf` (this project default) frameworks. + The upload TFT engines have some differences, so changing the framework may solve some issues. You can set the framework you want by adding this to your ESPHome yaml: @@ -130,19 +153,23 @@ esp32: - **Issue**: Your current HTTP server may be overloaded. - **Solution**: Try another HTTP server installed on your computer. Many free options are available to run on your local Windows, MAC, or Linux machine. - **Examples**: Just to name some: + | Solution | Website | Supported OSs | Pros | Cons | |----------|---------|---------------|------|------| | NGINX | [nginx.org](https://nginx.org/en/) | Linux, Windows, macOS | High performance, efficient for static content, good for high concurrency | Configuration can be complex for beginners | | IIS | [Microsoft Web Platform](https://www.microsoft.com/web/downloads/platform.aspx) | Windows | Integrated with Windows, GUI for setup, good for Windows environments | Limited to Windows OS | | Apache | [httpd.apache.org](https://httpd.apache.org/) | Linux, Windows, macOS | Highly reliable and flexible, wide OS compatibility, extensive customization | Can be less efficient under high load than NGINX | | XAMPP | [apachefriends.org](https://www.apachefriends.org/index.html) | Linux, Windows, macOS | All-in-one package, easy to install, ideal for beginners | Not optimized for high-traffic sites, more suited for development than production | + ## Additional Tips and Resources -After troubleshooting, if issues persist, consult the [Issues](https://github.com/Blackymas/NSPanel_HA_Blueprint/issues) and feel free to create a new one asking for more personalized assistance. +After troubleshooting, if issues persist, consult the [Issues](https://github.com/Blackymas/NSPanel_HA_Blueprint/issues) +and feel free to create a new one asking for more personalized assistance. Please share as much info as possible, like: 1. Description (or a picture) of what is on your screen. -2. Are you updating from a previous version of this project, coming from another NSPanel customization (which one?), or customizing a panel with the original Sonoff settings for the first time? +2. Are you updating from a previous version of this project, coming from another NSPanel customization (which one?), + or customizing a panel with the original Sonoff settings for the first time? 3. ESPHome logs from when your panel starts to the moment the upload fails. 4. A description of what you have already tried. From 202f1f30786056c2da81e527bceb1104ab2be72c Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 24 Nov 2024 18:48:27 +0100 Subject: [PATCH 6/9] Lint --- docs/tft_upload.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/tft_upload.md b/docs/tft_upload.md index 6d072a5d..7e72b9a3 100644 --- a/docs/tft_upload.md +++ b/docs/tft_upload.md @@ -1,30 +1,34 @@ # Troubleshooting TFT Transfer > [!IMPORTANT] -> If you have already installed the version "nspanel-lovelace-ui" from joBr99 on your NSPanel, an intermediate step is necessary - otherwise, it is not possible to install this or any other version. +> If you have already installed the version "nspanel-lovelace-ui" from joBr99 on your NSPanel, an intermediate step is necessary - otherwise, +> it is not possible to install this or any other version. > > See [Common Issues | TFT Upload when NSPanel Lovelace UI has been installed](howto.md) ## Common Issues and Troubleshooting -The following is a list of common issues affecting the TFT upload, along with suggested solutions. These issues are not specific to the NSPanel HA Blueprint project but are common to Nextion displays and ESPHome. +The following is a list of common issues affecting the TFT upload, along with suggested solutions. +These issues are not specific to the NSPanel HA Blueprint project but are common to Nextion displays and ESPHome. ### Resolving "System data ERROR!" on Display ![System Data ERROR](pics/us_system_data_error_upside_down.jpg) #### Don't Panic! -The "System data ERROR!" message, sometimes displayed upside-down, appears when a TFT upload is incomplete. While it may seem alarming, this message simply indicates that the TFT file on the display is invalid. A successful TFT upload will resolve this issue. +The "System data ERROR!" message, sometimes displayed upside-down, appears when a TFT upload is incomplete. +While it may seem alarming, this message simply indicates that the TFT file on the display is invalid. A successful TFT upload will resolve this issue. ### Resolving "Model does not match" on Display ![Model Does Not Match](pics/model_does_not_match.jpg) -This is another case where the message sounds more alarming than it actually is. Often, a simple reboot of the panel is enough to restore the previous TFT file. This issue typically arises from a corrupt TFT file or server response issues. For troubleshooting, refer to the following sections: +This is another case where the message sounds more alarming than it actually is. Often, a simple reboot of the panel is enough to restore the previous TFT file. +This issue typically arises from a corrupt TFT file or server response issues. For troubleshooting, refer to the following sections: - [Using a Local Source (Home Assistant)](#using-a-local-source-home-assistant) - [HTTP Instead of HTTPS](#http-instead-of-https) - Especially important when using the `arduino` framework. - [Check the File Size by Downloading to Your Computer](#check-the-file-size-by-downloading-to-your-computer) > [!TIP] > If the TFT transfer has started, your panel might not respond to the reset button on the device's page in Home Assistant or to holding the hardware button for 15 seconds. -In such cases, you can either power cycle your device using the room's relay on your electrical plate or use a pin to press the hardware restart button in a small hole behind the device. +> In such cases, you can either power cycle your device using the room's relay on your electrical plate or use a pin to press the hardware restart button in a small hole behind the device. > >![Image](pics/eu_reset_button.png) From 17612fbdf30171ca2feb7141ecfaad5508e0dfb2 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 24 Nov 2024 19:17:37 +0100 Subject: [PATCH 7/9] Performance guide --- ReleaseNotes.md | 5 +++++ docs/README.md | 1 + docs/performance.md | 49 ++++++++++++++++++++++++++++++++++++++++++ nspanel_blueprint.yaml | 4 ++-- 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 docs/performance.md diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 38e225aa..8de0cd09 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -69,6 +69,11 @@ between ESPHome and Nextion. Visit the updated [API documentation](docs/api.md) The baud rate selector has been removed as full support for all baud rates used by Nextion makes it redundant. Communication now adapts automatically to the required baud rate, simplifying configuration. +5. **New "Display delay" control** + A new control called **Display delay** has been introduced to manage the delay between commands sent to the Nextion display. + This helps avoid buffer overflows, which can lead to a device restart if not managed properly. + You can find more details in the [Performance Settings for NSPanel Project](docs/performance.md#2-esphome-performance-setting-display-delay). + ### Customizations Updated scripts require adjustments to these customizations: - [Sleep & Wake-up buttons](docs/customization.md#sleep--wake-up-buttons) diff --git a/docs/README.md b/docs/README.md index cfbaa0ba..ad70a339 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,6 +3,7 @@ - [First Steps | Installation and Setup](install.md) - [Blueprint | Setup and explanation of the Blueprint](blueprint.md) - [HowTo | All important things you should know](howto.md) +- [Performance Guide](performance.md) - [Version compatibility matrix](version_compatibility.md) ## Common issues diff --git a/docs/performance.md b/docs/performance.md new file mode 100644 index 00000000..c8574d12 --- /dev/null +++ b/docs/performance.md @@ -0,0 +1,49 @@ +# Performance Settings for NSPanel Project + +This document provides an overview of the performance settings available in the NSPanel project. +Proper tuning of these settings can enhance the responsiveness of the system while avoiding issues like WLAN overload or +buffer overflow in the Nextion display. +Below, we'll discuss the two primary performance settings: one on the blueprint side and another on the ESPHome side. + +## 1. Blueprint Performance Setting: Command Delay to Prevent Overload + +On the blueprint side, the performance setting is used to define a delay before each service call is sent to the display. +This delay helps prevent consecutive calls from overloading both the WLAN and the NSPanel. + +### Where to Find It +- **Location:** This setting is found in the automation created with the Blueprint to control your panel. +- **Advanced Settings:** Scroll down to the "Advanced Settings" section of the configuration list. +- **Name:** The setting is named **"Command Delay to Prevent Overload"**. + +Adjusting this delay can help manage the network load and ensure that the commands are spaced out properly, +allowing the NSPanel and WLAN to process them without being overwhelmed. + +## 2. ESPHome Performance Setting: Display Delay + +On the ESPHome side, the performance setting involves configuring a delay when sending commands to the Nextion display. +This delay is critical in preventing the "Buffer overload" issue that can occur on the Nextion display. + +### Where to Find It +- **Location:** This setting can be found on the ESPHome device's page under `Settings > Devices & Services > ESPHome`. +- **Configuration Group:** Look for the setting under the "Configuration" group. +- **Name:** The setting is named **"Display delay"**. + +Note that this setting may be hidden or disabled in some systems. You may need to enable it before you can adjust its value. + +### Purpose +The **Display Delay** setting prevents buffer overload on the Nextion display, +which occurs when too many commands are received and cannot be processed in time. If the buffer overloads, +the Nextion queue will fall out of sync, leading to a device restart. +Each time this restart occurs, the delay will automatically increase one step in the delay interval (measured in milliseconds). + +## Combining Delays: Impact on Responsiveness +The two delay settings (Blueprint and ESPHome) are combined, which can lead to a slower response time on the panel. +You can reduce these intervals to improve the panel's responsiveness. +However, it's important to note that reducing the **Display Delay** on the ESPHome side too much can lead to buffer overflows, causing instability. + +### Recommendations +- **Fine-Tune the Blueprint Delay** to manage WLAN and command pacing effectively. +- **Adjust ESPHome Display Delay Carefully**: Lowering it too much can lead to buffer issues. + Start with a conservative value and decrease it slowly while monitoring performance. + +Maintaining a balance between the two settings is essential to ensure a responsive and stable NSPanel experience. diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index ed88dd66..99867869 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -3732,12 +3732,12 @@ blueprint: Adjusts the delay between sequential commands to the Nextion display, preventing overload and synchronization issues. While increasing delay enhances stability, it may slow down page rendering. - default: 10 + default: 5 selector: number: min: 0 max: 250 - step: 1 + step: 5 unit_of_measurement: milliseconds mode: box tft_path: From 523d319151f69a949270795305699087537c19dc Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 24 Nov 2024 19:26:04 +0100 Subject: [PATCH 8/9] Clean-up performance guide --- ReleaseNotes.md | 10 +++++----- docs/performance.md | 20 +++++++++++++++----- nspanel_blueprint.yaml | 7 ++++--- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 8de0cd09..5ff7e81d 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -49,7 +49,7 @@ All actions now use a unified method to transfer information, reducing overhead between ESPHome and Nextion. Visit the updated [API documentation](docs/api.md) for details. #### Key API Changes: -1. **Deprecated actions** +1. **Deprecated actions** | Deprecated action | Replacement | Previous use | | :--------------------------------- | :----------------------- | :----------------------------- | @@ -59,17 +59,17 @@ between ESPHome and Nextion. Visit the updated [API documentation](docs/api.md) | `component_text`, `icon`, etc. | [`component`](docs/api.md#component-action-component) | Set display components | -2. **Sensor `blueprint_status` removed** +2. **Sensor `blueprint_status` removed** Boot info is now transferred via events. -3. **Notification unread switch replaced** +3. **Notification unread switch replaced** The "**Notification unread**" switch is now a binary sensor. -4. **Selector "Update TFT display - Baud rate" removed** +4. **Selector "Update TFT display - Baud rate" removed** The baud rate selector has been removed as full support for all baud rates used by Nextion makes it redundant. Communication now adapts automatically to the required baud rate, simplifying configuration. -5. **New "Display delay" control** +5. **New "Display delay" control** A new control called **Display delay** has been introduced to manage the delay between commands sent to the Nextion display. This helps avoid buffer overflows, which can lead to a device restart if not managed properly. You can find more details in the [Performance Settings for NSPanel Project](docs/performance.md#2-esphome-performance-setting-display-delay). diff --git a/docs/performance.md b/docs/performance.md index c8574d12..2af161cf 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -1,8 +1,7 @@ # Performance Settings for NSPanel Project This document provides an overview of the performance settings available in the NSPanel project. -Proper tuning of these settings can enhance the responsiveness of the system while avoiding issues like WLAN overload or -buffer overflow in the Nextion display. +Proper tuning of these settings can enhance the responsiveness of the system while avoiding issues like WLAN overload or buffer overflow in the Nextion display. Below, we'll discuss the two primary performance settings: one on the blueprint side and another on the ESPHome side. ## 1. Blueprint Performance Setting: Command Delay to Prevent Overload @@ -15,6 +14,18 @@ This delay helps prevent consecutive calls from overloading both the WLAN and th - **Advanced Settings:** Scroll down to the "Advanced Settings" section of the configuration list. - **Name:** The setting is named **"Command Delay to Prevent Overload"**. +### Input Details +- **Name:** Command Delay to Prevent Overload +- **Description:** Sets the time delay between sequential commands sent to the Nextion display. + This delay prevents overload and synchronization issues, which could cause system instability. + Increasing the delay improves stability but may slow down page rendering. Adjust carefully to balance stability and responsiveness. +- **Default Value:** 5 milliseconds +- **Selector Settings:** + - **Range:** Minimum of 0 milliseconds, maximum of 250 milliseconds. + - **Step Size:** 5 milliseconds per step. + - **Unit of Measurement:** Milliseconds + - **Mode:** Box + Adjusting this delay can help manage the network load and ensure that the commands are spaced out properly, allowing the NSPanel and WLAN to process them without being overwhelmed. @@ -31,9 +42,8 @@ This delay is critical in preventing the "Buffer overload" issue that can occur Note that this setting may be hidden or disabled in some systems. You may need to enable it before you can adjust its value. ### Purpose -The **Display Delay** setting prevents buffer overload on the Nextion display, -which occurs when too many commands are received and cannot be processed in time. If the buffer overloads, -the Nextion queue will fall out of sync, leading to a device restart. +The **Display Delay** setting prevents buffer overload on the Nextion display, which occurs when too many commands are received and cannot be processed in time. +If the buffer overloads, the Nextion queue will fall out of sync, leading to a device restart. Each time this restart occurs, the delay will automatically increase one step in the delay interval (measured in milliseconds). ## Combining Delays: Impact on Responsiveness diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 99867869..dc60f9b2 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -3729,9 +3729,10 @@ blueprint: delay: name: Command Delay to Prevent Overload description: > - Adjusts the delay between sequential commands to the Nextion display, - preventing overload and synchronization issues. - While increasing delay enhances stability, it may slow down page rendering. + Sets the time delay between sequential commands sent to the Nextion display. + This delay prevents overload and synchronization issues, which could cause system instability. + Increasing the delay improves stability but may make page rendering slower. + Adjust carefully to balance stability and responsiveness. default: 5 selector: number: From 67f9349cec4cea9c3c99c58b24928a6dc503a9d0 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 24 Nov 2024 19:28:59 +0100 Subject: [PATCH 9/9] Lint --- docs/performance.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/performance.md b/docs/performance.md index 2af161cf..d88fc258 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -9,7 +9,7 @@ Below, we'll discuss the two primary performance settings: one on the blueprint On the blueprint side, the performance setting is used to define a delay before each service call is sent to the display. This delay helps prevent consecutive calls from overloading both the WLAN and the NSPanel. -### Where to Find It +### Where to Find It - Automations - **Location:** This setting is found in the automation created with the Blueprint to control your panel. - **Advanced Settings:** Scroll down to the "Advanced Settings" section of the configuration list. - **Name:** The setting is named **"Command Delay to Prevent Overload"**. @@ -34,7 +34,7 @@ allowing the NSPanel and WLAN to process them without being overwhelmed. On the ESPHome side, the performance setting involves configuring a delay when sending commands to the Nextion display. This delay is critical in preventing the "Buffer overload" issue that can occur on the Nextion display. -### Where to Find It +### Where to Find It - Integrations - **Location:** This setting can be found on the ESPHome device's page under `Settings > Devices & Services > ESPHome`. - **Configuration Group:** Look for the setting under the "Configuration" group. - **Name:** The setting is named **"Display delay"**.