diff --git a/esphome/nspanel_esphome_addon_upload_tft.yaml b/esphome/nspanel_esphome_addon_upload_tft.yaml index d3bf37b64..3112efb4e 100644 --- a/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -44,21 +44,6 @@ api: variables: url: string then: - - script.execute: - id: upload_tft - url: !lambda |- - std::string clean_url = url; - // Convert to lowercase - std::transform(clean_url.begin(), clean_url.end(), clean_url.begin(), - [](unsigned char c){ return std::tolower(c); }); - // 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 = construct_tft_url("v${version}", tft_file_model->state, "${nextion_update_url}", - "${nextion_update_base_url}"); - return url.c_str(); - - lambda: |- std::string clean_url = url; // Convert to lowercase @@ -82,11 +67,9 @@ button: entity_category: config on_press: then: - - script.execute: - id: upload_tft - url: !lambda |- - return construct_tft_url("v${version}", tft_file_model->state, "${nextion_update_url}", - "${nextion_update_base_url}").c_str(); + - lambda: |- + 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 @@ -140,11 +123,10 @@ script: mode: restart then: - lambda: |- - static const char *const TAG = "script.nextion_status"; - ESP_LOGD(TAG, "Nextion status:"); - ESP_LOGD(TAG, " Is detected: %s", YESNO(disp1->is_detected())); - ESP_LOGD(TAG, " Is setup: %s", YESNO(disp1->is_setup())); - ESP_LOGD(TAG, " Queue size: %d", disp1->queue_size()); + ESP_LOGD("script.nextion_status", "Nextion status:"); + ESP_LOGD("script.nextion_status", " Is detected: %s", YESNO(disp1->is_detected())); + ESP_LOGD("script.nextion_status", " Is setup: %s", YESNO(disp1->is_setup())); + ESP_LOGD("script.nextion_status", " Queue size: %d", disp1->queue_size()); - id: nextion_upload mode: single diff --git a/esphome/nspanel_esphome_core_boot.yaml b/esphome/nspanel_esphome_core_boot.yaml index d734144e4..ebc211e1d 100644 --- a/esphome/nspanel_esphome_core_boot.yaml +++ b/esphome/nspanel_esphome_core_boot.yaml @@ -215,68 +215,41 @@ script: id: boot_log category: Boot log_message: Display settings - - script.execute: - id: set_variable_value - variable: brightness_dim - val: !lambda return int(display_dim_brightness->state); - - script.execute: - id: set_component_value - page: settings - component: dimslider - val: !lambda return int(display_dim_brightness->state); - - script.execute: - id: set_variable_value - variable: brightness_sleep - val: !lambda return int(display_sleep_brightness->state); - - script.execute: - id: set_variable_value - variable: brightness - val: !lambda return int(display_brightness->state); - - script.execute: - id: set_component_value - page: settings - component: brightslider - val: !lambda return int(display_brightness->state); - - script.execute: - id: set_brightness - brightness: !lambda return display_brightness->state; - - script.execute: - id: boot_progress - step: ${BOOT_STEP_BOOT} - step_name: Boot - - script.execute: boot_event + - lambda: |- + set_variable_value->execute("brightness_dim", int(display_dim_brightness->state)); + set_variable_value->execute("brightness_sleep", int(display_sleep_brightness->state)); + set_variable_value->execute("brightness", int(display_brightness->state)); + set_component_value->execute("settings", "dimslider", int(display_dim_brightness->state)); + set_component_value->execute("settings", "brightslider", int(display_brightness->state)); + set_brightness->execute(display_brightness->state); + boot_progress->execute(${BOOT_STEP_BOOT}, "Boot"); + boot_event->execute(); - id: !extend dump_config then: - - if: - condition: - - lambda: return is_boot_complete(); - then: - - lambda: |- - ESP_LOGCONFIG("${project_tag}", " Boot steps: %" PRIu8 "/%" PRIu8 " (100%%)", get_boot_steps_completed(), - TOTAL_BOOT_STEPS); - else: - - lambda: |- - ESP_LOGW("${project_tag}", " Boot steps: %" PRIu8 "/%" PRIu8 " (%" PRIu8 "%%)", get_boot_steps_completed(), - TOTAL_BOOT_STEPS, get_boot_progress_percentage()); - ESP_LOGW("${project_tag}", " State: %s", - ((wifi_component->is_connected()) and api_server->is_connected()) ? "Pending" : "DISCONNECTED"); - ESP_LOGCONFIG("${project_tag}", "Requesting new boot parameters from Blueprint"); - - script.execute: boot_event + - lambda: |- + if (is_boot_complete()) + ESP_LOGCONFIG("${project_tag}", " Boot steps: %" PRIu8 "/%" PRIu8 " (100%%)", + get_boot_steps_completed(), TOTAL_BOOT_STEPS); + else { + ESP_LOGW("${project_tag}", " Boot steps: %" PRIu8 "/%" PRIu8 " (%" PRIu8 "%%)", + get_boot_steps_completed(), TOTAL_BOOT_STEPS, get_boot_progress_percentage()); + ESP_LOGW("${project_tag}", " State: %s", + ((wifi_component->is_connected()) and api_server->is_connected()) ? "Pending" : "DISCONNECTED"); + ESP_LOGCONFIG("${project_tag}", "Requesting new boot parameters from Blueprint"); + boot_event->execute(); + } - id: !extend page_changed then: - - if: - condition: - - text_sensor.state: - id: current_page - state: boot - then: - - script.execute: page_boot + - lambda: |- + if (current_page->state == "boot") + page_boot->execute(); - id: !extend stop_all then: - - script.stop: boot_log - - script.stop: boot_event - - script.stop: boot_progress + - lambda: |- + boot_log->stop(); + boot_event->stop(); + boot_progress->stop(); ... diff --git a/esphome/nspanel_esphome_core_datetime.yaml b/esphome/nspanel_esphome_core_datetime.yaml index 3e188704a..017c42c22 100644 --- a/esphome/nspanel_esphome_core_datetime.yaml +++ b/esphome/nspanel_esphome_core_datetime.yaml @@ -149,8 +149,9 @@ script: - id: !extend stop_all then: - - script.stop: refresh_datetime - - script.stop: set_timezone + - lambda: |- + refresh_datetime->stop(); + set_timezone->stop(); ##### Keeps time display updated ##### time: @@ -164,56 +165,26 @@ time: - seconds: 30 # Watchdog - Every minute, at second 30 then: - - if: - condition: - - not: - - wifi.connected: - then: - - logger.log: - format: Retrying Wi-Fi connection - level: WARN - - lambda: wifi_component->retry_connect(); - - if: - condition: - - not: - - api.connected: - - not: - - text_sensor.state: - id: current_page - state: blank - - not: - - text_sensor.state: - id: current_page - state: boot - - not: - - text_sensor.state: - id: current_page - state: confirm - - not: - - text_sensor.state: - id: current_page - state: home - - not: - - text_sensor.state: - id: current_page - state: qrcode - - not: - - text_sensor.state: - id: current_page - state: screensaver - - not: - - text_sensor.state: - id: current_page - state: settings - then: - - logger.log: - format: API disconnected. Falling back to Home page. - level: WARN - - script.execute: - id: goto_page - page: home - - lambda: reset_boot_steps(); - - script.execute: refresh_wifi_icon + - lambda: |- + if (not wifi_component->is_connected()) { + ESP_LOGW("time_provider.on_time", "Retrying Wi-Fi connection"); + wifi_component->retry_connect(); + } + if ( + !api_server->is_connected() and + current_page->state != "blank" and + current_page->state != "boot" and + current_page->state != "confirm" and + current_page->state != "home" and + current_page->state != "qrcode" and + current_page->state != "screensaver" and + current_page->state != "settings" + ) { + ESP_LOGW("time_provider.on_time", "API disconnected. Falling back to Home page."); + goto_page->execute("home"); + reset_boot_steps(); + } + refresh_wifi_icon->execute(); - minutes: /10 seconds: 5 @@ -222,8 +193,8 @@ time: on_time_sync: then: - - script.execute: refresh_datetime - lambda: |- + refresh_datetime->execute(); ESP_LOGI("time.on_time_sync", "System clock synchronized"); ESP_LOGI("time.on_time_sync", "Timezone: %s", time_provider->get_timezone().c_str()); ...