From d7d249308a3275044cb2b552ce325b5952afe034 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 28 Dec 2023 02:16:21 +0100 Subject: [PATCH] Reboot with Wi-Fi timeout --- advanced/esphome/nspanel_esphome_core.yaml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/advanced/esphome/nspanel_esphome_core.yaml b/advanced/esphome/nspanel_esphome_core.yaml index 1dce795..e4ae029 100644 --- a/advanced/esphome/nspanel_esphome_core.yaml +++ b/advanced/esphome/nspanel_esphome_core.yaml @@ -739,6 +739,12 @@ display: ##### START - GLOBALS CONFIGURATION ##### globals: + ##### Wi-Fi timeout ##### + - id: wifi_timeout + type: uint + restore_value: false + initial_value: '15' + ##### Is uploading TFT ##### - id: is_uploading_tft type: bool @@ -828,7 +834,7 @@ globals: - id: mui_time_format type: std::string - restore_value: false + restore_value: true initial_value: '"%H:%M"' - id: home_time_color type: uint @@ -848,7 +854,7 @@ globals: ##### Relay icons ##### - id: home_relay1_icon type: std::string - restore_value: false + restore_value: true initial_value: '' - id: home_relay1_icon_color type: uint16_t @@ -857,7 +863,7 @@ globals: - id: home_relay2_icon type: std::string - restore_value: false + restore_value: true initial_value: '' - id: home_relay2_icon_color type: uint16_t @@ -3011,8 +3017,14 @@ script: disp1->send_command_printf("api=%i", id(is_blueprint_updated) ? 1 : 0); if (!wifi_connected) { - ESP_LOGD(TAG, "Retrying Wi-Fi connection"); - wifi_component->retry_connect(); + if (id(wifi_timeout) > 0) { + id(wifi_timeout)--; + ESP_LOGD(TAG, "Retrying Wi-Fi connection"); + wifi_component->retry_connect(); + } else { + ESP_LOGE(TAG, "Restarting ESP due to a Wi-Fi timeout..."); + App.safe_reboot(); + } } if (api_connected) { if (not id(is_blueprint_updated)) {