From b086ccc16d359ffbcf0ab6f91fcb716ddc2e99a4 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:21:19 +0100 Subject: [PATCH] Support to Fahrenheit with `esp-idf` --- .../nspanel_esphome_addon_upload_tft.yaml | 40 +++++++++---------- advanced/esphome/nspanel_esphome_core.yaml | 15 +++---- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml b/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml index e30f46d..09e821c 100644 --- a/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -22,28 +22,28 @@ substitutions: api: services: - ##### SERVICE TO UPDATE THE TFT FILE from URL ##### - ##### It will use the default url if url is empty or "default" - - service: upload_tft_url - variables: - url: string - then: - - lambda: |- - static const char *const TAG = "service.upload_tft_url"; - ESP_LOGVV(TAG, "Starting..."); + ##### SERVICE TO UPDATE THE TFT FILE from URL ##### + ##### It will use the default url if url is empty or "default" + - service: upload_tft_url + variables: + url: string + then: + - lambda: |- + static const char *const TAG = "service.upload_tft_url"; + ESP_LOGVV(TAG, "Starting..."); - 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); - } + 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 = tft_list->state; - upload_tft->execute(url.c_str()); + if ( clean_url.empty() or clean_url == "default") url = tft_list->state; + upload_tft->execute(url.c_str()); button: ##### UPDATE TFT DISPLAY ##### diff --git a/advanced/esphome/nspanel_esphome_core.yaml b/advanced/esphome/nspanel_esphome_core.yaml index e900868..2ac320b 100644 --- a/advanced/esphome/nspanel_esphome_core.yaml +++ b/advanced/esphome/nspanel_esphome_core.yaml @@ -364,9 +364,9 @@ api: - wait_until: condition: - not: - - text_sensor.state: # Is boot page visible? - id: current_page - state: 'boot' + - text_sensor.state: # Is boot page visible? + id: current_page + state: 'boot' timeout: 2s - if: condition: @@ -1257,7 +1257,8 @@ sensor: reference_resistance: 10kOhm filters: - lambda: |- - if ("${temp_units}" == "°F" or "${temp_units}" == "F" or "${temp_units}" == "°f" or "${temp_units}" == "f") + std::string temp_unit = "${temp_units}"; + if (temp_unit == "°F" or temp_unit == "F" or temp_unit == "°f" or temp_unit == "f") return (x * (9.0/5.0)) + 32.0 + temperature_correction->state; else return x + temperature_correction->state; @@ -2588,9 +2589,9 @@ script: - wait_until: condition: - not: - - text_sensor.state: # Is boot page visible? - id: current_page - state: 'boot' + - text_sensor.state: # Is boot page visible? + id: current_page + state: 'boot' timeout: 15s - lambda: |- static const char *const TAG = "script.boot_sequence";