diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 8bc3d9b..d89f318 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -63,17 +63,22 @@ please look at "[Customizations - Remove non-essential components](docs/customiz 4. **15s hardware button press no longer restarts the device** as the benefits of this were too small compared to leaving the button available for other uses. If you still want the 15s restart behaviour, you can look at "[Customizations - Restart with 15s button press](docs/customization.md#restart-with-15s-button-press) and, in addition to that, the [reset pin in the bottom of your panel](docs/pics/eu_reset_button.png) can be used. +5. **Relay Fallback Switches Removed**: These switches have been deprecated and hidden for some time and are now fully removed from the code. +If you have used any customizations to expose these switches, please refer to the updated guide in "[Customizations - Expose Relay Fallback Switch](docs/customization.md#expose-relay-fallback-switch)", +or you can use a call to the service `esphome.xxxxx_init_relays` to set it accordingly without the additional memory consumption related to creating additional switches. ## Overview of noteworthy changes -1. New default framework +1. Transition to ESP-IDF as Default Framework 2. Performance improvements 3. New API documentation 4. Selectable font size for screensaver time display ## Details of noteworthy changes -### 1. New default framework -Some text +### 1. Transition to ESP-IDF as Default Framework +As previously announced, we have now transitioned to ESP-IDF as our default framework starting with this release. This change aligns with our commitment to provide a robust and future-ready platform, offering enhanced performance, direct hardware access, and access to the latest developments from Espressif. For those who have prepared for this transition, we look forward to the new possibilities this brings to your projects. For users wishing to continue with the Arduino framework, instructions have been provided on explicitly setting your framework preference. We are here to assist through our community support channels for any questions or assistance needed. +For the ones previously using the default framework (without any explicity framework especification on your panel's yaml), remember you have to flash your device using a serial cable this time, otherwise you can face some issues. +More information about this transition can be found in our discussion here: https://github.com/Blackymas/NSPanel_HA_Blueprint/discussions/1756 ### 2. Performance improvements Some text diff --git a/docs/api.md b/docs/api.md index 73dbab4..be3023e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -426,11 +426,11 @@ It tailors ESPHome's relay operations for specific use cases, including local co **Parameters:** - `relay1_local_control` (bool): Enables or disables local control for Relay 1. - `relay1_icon` (string): Icon codepoint from [HASwitchPlate Material Design Icons](https://htmlpreview.github.io/?https://github.com/jobr99/Generate-HASP-Fonts/blob/master/cheatsheet.html) for Relay 1. -- `relay1_icon_color` (int): Sets the [RGB565 color number](https://rgbcolorpicker.com/565) for Relay 1's icon. +- `relay1_icon_color` (int[]): The RGB color array for Relay 1's icon. - `relay1_fallback` (bool): Determines the fallback state for Relay 1 in case of communication loss. - `relay2_local_control` (bool): Enables or disables local control for Relay 2. - `relay2_icon` (string): Icon codepoint from [HASwitchPlate Material Design Icons](https://htmlpreview.github.io/?https://github.com/jobr99/Generate-HASP-Fonts/blob/master/cheatsheet.html) for Relay 2. -- `relay2_icon_color` (int): Sets the [RGB565 color number](https://rgbcolorpicker.com/565) for Relay 2's icon. +- `relay2_icon_color` (int[]): The RGB color array for Relay 2's icon. - `relay2_fallback` (bool): Determines the fallback state for Relay 2 in case of communication loss. **Home Assistant Example:** @@ -438,23 +438,18 @@ It tailors ESPHome's relay operations for specific use cases, including local co service: esphome._init_relays data: relay1_local_control: true - relay1_icon: "\uE3A5" # Example for mdi:numeric-1-box-outline - relay1_icon_color: 63488 # Red in 16-bit color (0xF800) + relay1_icon: "\uE3A5" # Example for mdi:numeric-1-box-outline + relay1_icon_color: [248, 0, 0] # Red relay1_fallback: false relay2_local_control: true - relay2_icon: "\uE3A8" # Example for mdi:numeric-2-box-outline - relay2_icon_color: 2016 # Green in 16-bit color (0x07E0) + relay2_icon: "\uE3A8" # Example for mdi:numeric-2-box-outline + relay2_icon_color: [0, 252, 0] # Green relay2_fallback: true ``` - > [!NOTE] > Replace `` with the specific name of your panel configured in Home Assistant. > This service initializes relay settings based on the provided parameters, customizing relay functionality and presentation as defined in the blueprint. -> [!IMPORTANT] -> Colors here are in RGB565 numeric (decimal) format. You can use a [RGB565 color picker](https://rgbcolorpicker.com/565) to convert from RGB. - - ### Notification Clear Service: `notification_clear` Removes any displayed notification from the screen, allowing the display to return to its normal state or view. diff --git a/docs/customization.md b/docs/customization.md index 9f85f56..d99e854 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -663,10 +663,35 @@ Subsequent activations will trigger `light.toggle` from the blueprint, as this f ```yaml # Expose relay local control switch to Home Assistant switch: - - id: !extend relay1_local + - name: Relay 1 Local + platform: template + id: relay1_local + entity_category: config internal: false - - id: !extend relay2_local + lambda: |- + return (id(relay_settings) & nspanel_ha_blueprint::RelaySettings::Relay1_Local); + turn_on_action: + - lambda: nspanel_ha_blueprint::update_relay_setting(id(relay_settings), true, RelaySettings::Relay1_Local); + on_turn_on: + - logger.log: "Relay 1 Local turned On!" + turn_off_action: + - lambda: nspanel_ha_blueprint::update_relay_setting(id(relay_settings), false, RelaySettings::Relay1_Local); + on_turn_off: + - logger.log: "Relay 1 Local turned Off!" + - name: Relay 2 Local + platform: template + id: relay2_local + entity_category: config internal: false + lambda: return (id(relay_settings) & nspanel_ha_blueprint::RelaySettings::Relay2_Local); + turn_on_action: + - lambda: nspanel_ha_blueprint::update_relay_setting(id(relay_settings), true, RelaySettings::Relay2_Local); + on_turn_on: + - logger.log: "Relay 2 Local turned On!" + turn_off_action: + - lambda: nspanel_ha_blueprint::update_relay_setting(id(relay_settings), false, RelaySettings::Relay2_Local); + on_turn_off: + - logger.log: "Relay 2 Local turned Off!" ``` ### Relay Interlocking diff --git a/esphome/components/nspanel_ha_blueprint/__init__.py b/esphome/components/nspanel_ha_blueprint/__init__.py new file mode 100644 index 0000000..4753134 --- /dev/null +++ b/esphome/components/nspanel_ha_blueprint/__init__.py @@ -0,0 +1,18 @@ +# __init__.py +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.core import coroutine_with_priority + +CODEOWNERS = ["@edwardtfn"] + +nspanel_ha_blueprint_ns = cg.esphome_ns.namespace('nspanel_ha_blueprint') + +CONFIG_SCHEMA = cv.All( + cv.Schema({}), +) + +@coroutine_with_priority(1.0) + +async def to_code(config): + cg.add_define("USE_NSPANEL_HA_BLUEPRINT") + cg.add_global(nspanel_ha_blueprint_ns.using) diff --git a/esphome/components/nspanel_ha_blueprint/page_names.h b/esphome/components/nspanel_ha_blueprint/page_names.h new file mode 100644 index 0000000..e773391 --- /dev/null +++ b/esphome/components/nspanel_ha_blueprint/page_names.h @@ -0,0 +1,67 @@ +// page_names.h +#pragma once + +#include +#include +#include + +namespace nspanel_ha_blueprint { + + /** + * @file page_names.h + * Defines constants and functions related to page names for "NSPanel HA Blueprint" project.. + */ + + // Constants + /** + * A compile-time constant array containing the names of pages. + * These names correspond to various pages of the Nextion TFT file in use, + * such as settings, home, weather information, and more. + */ + constexpr std::array page_names = { + "home", + "weather01", + "weather02", + "weather03", + "weather04", + "weather05", + "climate", + "settings", + "boot", + "screensaver", + "light", + "cover", + "buttonpage01", + "buttonpage02", + "buttonpage03", + "buttonpage04", + "notification", + "qrcode", + "entitypage01", + "entitypage02", + "entitypage03", + "entitypage04", + "fan", + "alarm", + "keyb_num", + "media_player", + "confirm" + }; + + /** + * Retrieves the index of a given page name within the page_names array. + * + * @param page_name The name of the page to find. + * @return The index of the page_name in the page_names array. If the page_name + * is not found, returns UINT8_MAX as an indicator that no matching page was found. + */ + inline uint8_t get_page_id(const std::string& page_name) { + for (uint8_t i = 0; i < page_names.size(); ++i) { + if (strcmp(page_names[i], page_name.c_str()) == 0) { + return i; // Return the index if found + } + } + return UINT8_MAX; // Return UINT8_MAX if not found + } + +} // namespace nspanel_ha_blueprint \ No newline at end of file diff --git a/esphome/components/nspanel_ha_blueprint/relays.h b/esphome/components/nspanel_ha_blueprint/relays.h new file mode 100644 index 0000000..d2cadf6 --- /dev/null +++ b/esphome/components/nspanel_ha_blueprint/relays.h @@ -0,0 +1,44 @@ +// relays.h +#pragma once + +#include + +namespace nspanel_ha_blueprint { + + /** + * @enum RelaySettings + * Represents the settings for relays as individual bits within a uint8_t value. Each + * enum value corresponds to a specific bit position that represents a distinct setting + * for the relays. This allows for efficient storage and manipulation of multiple relay + * settings within a single byte. + * + * Bits are allocated as follows: + * - Bit 0: Relay 1 - Local control enabled. + * - Bit 1: Relay 1 - Fallback mode enabled. + * - Bits 2-3: Reserved for future use. + * - Bit 4: Relay 2 - Local control enabled. + * - Bit 5: Relay 2 - Fallback mode enabled. + * - Bits 6-7: Reserved for future use. + * + * Usage involves bitwise operations to set, clear, and check these settings within a + * uint8_t variable. This approach enables compact representation and easy manipulation + * of relay settings. + */ + enum RelaySettings { + Relay1_Local = 1 << 0, ///< Bit 0: Enables local control for Relay 1. + Relay1_Fallback = 1 << 1, ///< Bit 1: Enables fallback mode for Relay 1. + // Bits 2 and 3 are reserved for future expansion. + Relay2_Local = 1 << 4, ///< Bit 4: Enables local control for Relay 2. + Relay2_Fallback = 1 << 5, ///< Bit 5: Enables fallback mode for Relay 2. + // Bits 6 and 7 are reserved for future expansion. + }; + + void update_relay_setting(uint8_t& settings, bool condition, RelaySettings flag) { + if (condition) { + settings |= flag; // Set bit + } else { + settings &= ~flag; // Clear bit + } + } + +} // namespace nspanel_ha_blueprint diff --git a/esphome/components/nspanel_ha_blueprint/text.h b/esphome/components/nspanel_ha_blueprint/text.h new file mode 100644 index 0000000..75a8902 --- /dev/null +++ b/esphome/components/nspanel_ha_blueprint/text.h @@ -0,0 +1,48 @@ +// text.h +#pragma once + +#include +#include + +namespace nspanel_ha_blueprint { + + /** + * Copies the contents of a std::string to a fixed-size char array, ensuring + * null termination of the string within the array. This function template + * automatically deduces the size of the destination char array at compile time, + * minimizing the risk of buffer overflow. It's designed for use with fixed-size + * char arrays only, not pointers or dynamically allocated memory. + * + * Template Parameter: + * N - The size of the destination char array. This value is deduced automatically + * and must be greater than 0. + * + * Parameters: + * dest - A reference to the destination char array where the string should be copied. + * The array must have a size that can accommodate the source string plus a + * null terminator. If the source string is longer than the destination array, + * it will be truncated. + * src - The source std::string to copy. This string's contents are copied into the + * destination array up to the array's capacity minus one, to leave space for + * the null terminator. + * + * Usage Example: + * char destination[11]; + * std::string source = "Hello"; + * nspanel_ha_blueprint::copyStringToCharArray(destination, source); + * + * Note: The destination array is always null-terminated, even if the source string + * is truncated to fit into the array. + */ + template + void copyStringToCharArray(char (&dest)[N], const std::string& src) { + static_assert(N > 0, "Destination array size must be greater than 0."); + + // Copy up to N - 1 characters to ensure there's room for the null terminator + std::strncpy(dest, src.c_str(), N - 1); + + // Manually null-terminate the destination array + dest[N - 1] = '\0'; + } + +} // namespace nspanel_ha_blueprint diff --git a/esphome/components/nspanel_ha_blueprint/versioning.h b/esphome/components/nspanel_ha_blueprint/versioning.h new file mode 100644 index 0000000..60f93a7 --- /dev/null +++ b/esphome/components/nspanel_ha_blueprint/versioning.h @@ -0,0 +1,25 @@ +// versioning.h +#pragma once +#include // For sscanf + +namespace nspanel_ha_blueprint { + + /** + * Compares two version strings by major and minor version numbers. + * Assumes version strings are in the format "major.minor". + * + * @param version1 First version string to compare. + * @param version2 Second version string to compare. + * @return true if the major and minor versions are equal, false otherwise. + */ + inline bool compare_versions(const char* version1, const char* version2) { + int major1 = 0, minor1 = 0; + int major2 = 0, minor2 = 0; + + sscanf(version1, "%d.%d", &major1, &minor1); + sscanf(version2, "%d.%d", &major2, &minor2); + + return (major1 == major2) && (minor1 == minor2); + } + +} // namespace nspanel_ha_blueprint diff --git a/esphome/nspanel_esphome_addon_upload_tft.yaml b/esphome/nspanel_esphome_addon_upload_tft.yaml index be61ab6..a1fa1cd 100644 --- a/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -138,8 +138,11 @@ script: disp1->hide_component("bt_accept"); disp1->hide_component("bt_clear"); } - disp1->set_component_text_printf("confirm.title", "Upload TFT\\r%s", - id(framework) == 1 ? "Arduino" : (id(framework) == 2 ? "ESP-IDF" : "Unknown")); + #ifdef ARDUINO + disp1->set_component_text_printf("confirm.title", "Upload TFT\\rArduino"); + #elif defined(USE_ESP_IDF) + disp1->set_component_text_printf("confirm.title", "Upload TFT\\rESP-IDF"); + #endif page_id->update(); - id: report_settings diff --git a/esphome/nspanel_esphome_advanced.yaml b/esphome/nspanel_esphome_advanced.yaml index 675a365..a97c37a 100644 --- a/esphome/nspanel_esphome_advanced.yaml +++ b/esphome/nspanel_esphome_advanced.yaml @@ -7,6 +7,13 @@ ##### ATTENTION: This will add advanced elements to the core system and requires the core part. ##### ##################################################################################################### --- +substitutions: + ############################## + ## Change only in your ## + ## local yaml substitutions ## + web_password: ${wifi_password} + ############################## + button: - name: Exit reparse platform: template @@ -19,6 +26,8 @@ button: - logger.log: "Button pressed: Exit reparse" - script.execute: exit_reparse +captive_portal: + script: - id: exit_reparse mode: restart @@ -85,4 +94,12 @@ time: then: - component.update: api_timestamp - component.update: device_timestamp + +##### Web server ##### +web_server: + id: web_server_std + port: 80 + auth: + username: admin + password: ${web_password} ... diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index a53e3d4..c23280d 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -15,7 +15,6 @@ substitutions: ap_password: ${wifi_password} ota_password: ${wifi_password} web_password: ${wifi_password} - wifi_timeout: '15' temp_units: "°C" invalid_cooldown: "100ms" ##### DON'T CHANGE THIS ###### @@ -24,6 +23,10 @@ substitutions: ##### External components ##### external_components: + - source: + type: git + path: https://github.com/Blackymas/NSPanel_HA_Blueprint/esphome/components + ref: dev # To do: Change it for releasing - source: type: git url: https://github.com/edwardtfn/esphome @@ -108,8 +111,6 @@ wifi: then: - script.execute: watchdog -captive_portal: - ##### OTA PASSWORD ##### ota: id: ota_std @@ -118,6 +119,9 @@ ota: reboot_timeout: 3min num_attempts: 3 +##### Adds custom library for NSPanel HA Blueprint project +nspanel_ha_blueprint: + ##### JSON - Used to parse json and for Upload TFT ##### json: @@ -163,19 +167,11 @@ time: - logger.log: "System clock synchronized" - script.execute: refresh_datetime -##### Web server ##### -web_server: - id: web_server_std - port: 80 - auth: - username: admin - password: ${web_password} - ##### START - API CONFIGURATION ##### # yamllint disable rule:comments-indentation api: id: api_server - reboot_timeout: 0s + reboot_timeout: 60min on_client_connected: - script.execute: watchdog on_client_disconnected: @@ -240,7 +236,7 @@ api: disp1->send_command_printf("%sicon.font=%" PRIu32, id.c_str(), icon_font); disp1->set_component_foreground_color(btnbri.c_str(), txt_color); disp1->set_component_foreground_color(btntext.c_str(), txt_color); - set_component_color->execute(btnicon.c_str(), icon_color); + disp1->set_component_font_color(btnicon.c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(icon_color[0], icon_color[1], icon_color[2]))); disp1->set_component_text_printf(btnicon.c_str(), "%s", icon.c_str()); display_wrapped_text->execute(btntext.c_str(), label.c_str(), 10); if (strcmp(bri.c_str(), "0") != 0) @@ -306,7 +302,8 @@ api: then: - lambda: |- if (!id(is_uploading_tft)) - set_component_color->execute(id, color); + disp1->set_component_font_color(id.c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(color[0], color[1], color[2]))); + # Component Hide Service # Allows for dynamic interface changes by hiding specified components on the display. @@ -470,7 +467,8 @@ api: - lambda: |- if (!id(is_uploading_tft) and !(id.empty())) { if (!(icon.empty())) disp1->set_component_text_printf("%s_icon", id.c_str(), icon.c_str()); - if (icon_color.size() == 3) set_component_color->execute((id + "_icon").c_str(), icon_color); + if (icon_color.size() == 3) + disp1->set_component_font_color((id + "_icon").c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(icon_color[0], icon_color[1], icon_color[2]))); bool IsCurrentPage = true; size_t dotPos = id.find("."); if (dotPos != std::string::npos) { @@ -553,9 +551,9 @@ api: # appearance, and interactive components. Facilitates a broad spectrum of personalization options. # # Parameters: - # - date_color (int[]): RGB color array for the date display (RGB565 format). + # - date_color (int[]): RGB color array for the date display. # - time_format (string): Time display format string, utilizing standard formatting symbols. - # - time_color (int[]): RGB color array for the time display (RGB565 format). + # - time_color (int[]): RGB color array for the time display. # - meridiem (string[]): Optional array for AM/PM labels if included in time format. # - chip_font (int): Font Id for chip icons displayed on the "Home" page. # - custom_buttons_font (int): Font Id for icons on custom buttons. @@ -632,14 +630,17 @@ api: // Localization ESP_LOGV(TAG, "Load localization"); id(mui_time_format) = time_format; - id(mui_meridiem) = meridiem; - + if (meridiem.size() == 2) { + id(mui_meridiem)[0] = meridiem[0]; + id(mui_meridiem)[1] = meridiem[1]; + } + // Date/Time colors ESP_LOGV(TAG, "Load date/time colors"); - set_component_color->execute("home.date", date_color); - set_component_color->execute("home.time", time_color); id(home_date_color) = esphome::display::ColorUtil::color_to_565(esphome::Color(date_color[0], date_color[1], date_color[2])); id(home_time_color) = esphome::display::ColorUtil::color_to_565(esphome::Color(time_color[0], time_color[1], time_color[2])); + disp1->set_component_font_color("home.date", id(home_date_color)); + disp1->set_component_font_color("home.time", id(home_time_color)); // Chips icon size ESP_LOGV(TAG, "Chips size"); @@ -667,22 +668,27 @@ api: ESP_LOGV(TAG, "Set Notification button"); disp1->send_command_printf("is_notification=%i", (notification_text->state.empty() and notification_label->state.empty()) ? 0 : 1); disp1->set_component_text_printf("home.bt_notific", "%s", notification_icon.c_str()); - set_component_color->execute("home.bt_notific", notification_unread->state ? notification_icon_color_unread : notification_icon_color_normal); - id(home_notify_icon_color_normal) = notification_icon_color_normal; - id(home_notify_icon_color_unread) = notification_icon_color_unread; + id(home_notify_icon_color_normal) = esphome::display::ColorUtil::color_to_565(esphome::Color(notification_icon_color_normal[0], + notification_icon_color_normal[1], + notification_icon_color_normal[2])); + id(home_notify_icon_color_unread) = esphome::display::ColorUtil::color_to_565(esphome::Color(notification_icon_color_unread[0], + notification_icon_color_unread[1], + notification_icon_color_unread[2])); + disp1->set_component_font_color("home.bt_notific", notification_unread->state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal)); // QRCode button ESP_LOGV(TAG, "Set QRCode button"); disp1->send_command_printf("is_qrcode=%i", qrcode ? 1 : 0); disp1->set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str()); - set_component_color->execute("home.bt_qrcode", qrcode_icon_color); + disp1->set_component_font_color("home.bt_qrcode", esphome::display::ColorUtil::color_to_565(esphome::Color(qrcode_icon_color[0], qrcode_icon_color[1], qrcode_icon_color[2]))); // Entities pages button ESP_LOGV(TAG, "Set Entities button"); disp1->send_command_printf("is_entities=%i", entities_pages ? 1 : 0); disp1->set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str()); - //set_component_color->execute("home.bt_entities", entities_pages_icon_color); - set_component_color->execute("home.bt_entities", entities_pages_icon_color); + disp1->set_component_font_color("home.bt_entities", esphome::display::ColorUtil::color_to_565(esphome::Color(entities_pages_icon_color[0], + entities_pages_icon_color[1], + entities_pages_icon_color[2]))); blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 1)); } @@ -735,11 +741,11 @@ api: # Parameters: # - relay1_local_control (bool): Enable/disable local control for Relay 1. # - relay1_icon (string): Icon for Relay 1 (e.g., "lightbulb"). - # - relay1_icon_color (int): 16-bit RGB color for Relay 1's icon. Use 63488 for red (0xF800 in hex). + # - relay1_icon_color (int): RGB color array for Relay 1's icon. # - relay1_fallback (bool): Fallback state for Relay 1 in case of communication loss. # - relay2_local_control (bool): Enable/disable local control for Relay 2. # - relay2_icon (string): Icon for Relay 2 (e.g., "power"). - # - relay2_icon_color (int): 16-bit RGB color for Relay 2's icon. Example green color: 2016 (0x07E0 in hex). + # - relay2_icon_color (int): RGB color array for Relay 2's icon. # - relay2_fallback (bool): Fallback state for Relay 2 in case of communication loss. # Example service call: @@ -747,11 +753,11 @@ api: # data: # relay1_local_control: true # relay1_icon: "lightbulb" - # relay1_icon_color: 63488 # Red in 16-bit color + # relay1_icon_color: [248, 0, 0] # Red # relay1_fallback: false # relay2_local_control: true # relay2_icon: "power" - # relay2_icon_color: 2016 # Green in 16-bit color + # relay2_icon_color: [0, 252, 0] # Green # relay2_fallback: true # # NOTE: Replace with your panel's name as configured in Home Assistant. @@ -761,25 +767,45 @@ api: variables: relay1_local_control: bool relay1_icon: string - relay1_icon_color: int + relay1_icon_color: int[] relay1_fallback: bool relay2_local_control: bool relay2_icon: string - relay2_icon_color: int + relay2_icon_color: int[] relay2_fallback: bool then: - - script.execute: - id: relay_settings - relay1_local_control: !lambda "return relay1_local_control;" - relay1_icon: !lambda "return relay1_icon;" - relay1_icon_color: !lambda "return relay1_icon_color;" - relay1_fallback: !lambda "return relay1_fallback;" - relay2_local_control: !lambda "return relay2_local_control;" - relay2_icon: !lambda "return relay2_icon;" - relay2_icon_color: !lambda "return relay2_icon_color;" - relay2_fallback: !lambda "return relay2_fallback;" - - script.wait: relay_settings - lambda: |- + if (!id(is_uploading_tft)) { + using namespace nspanel_ha_blueprint; + using namespace esphome::display; + + // Relay settings + update_relay_setting(id(relay_settings), relay1_local_control, RelaySettings::Relay1_Local); + update_relay_setting(id(relay_settings), relay1_fallback, RelaySettings::Relay1_Fallback); + update_relay_setting(id(relay_settings), relay2_local_control, RelaySettings::Relay2_Local); + update_relay_setting(id(relay_settings), relay2_fallback, RelaySettings::Relay2_Fallback); + + // Relay icons + if (not relay1_icon.empty()) copyStringToCharArray(id(home_relay1_icon), relay1_icon); + if (not relay2_icon.empty()) copyStringToCharArray(id(home_relay2_icon), relay2_icon); + + // Relay icon's colors + if (relay1_icon_color.size() == 3) { + id(home_relay1_icon_color) = ColorUtil::color_to_565(esphome::Color(relay1_icon_color[0], + relay1_icon_color[1], + relay1_icon_color[2])); + disp1->set_component_font_color("home.icon_top_01", id(home_relay1_icon_color)); + } + if (relay2_icon_color.size() == 3) { + id(home_relay2_icon_color) = ColorUtil::color_to_565(esphome::Color(relay2_icon_color[0], + relay2_icon_color[1], + relay2_icon_color[2])); + disp1->set_component_font_color("home.icon_top_02", id(home_relay2_icon_color)); + } + + // Refresh display + refresh_relays->execute(); + } blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 4)); # Notification Clear Service @@ -823,7 +849,7 @@ api: if (!id(is_uploading_tft)) { ESP_LOGV("service.notification_show", "Starting"); - disp1->goto_page("notification"); + goto_page->execute("notification"); disp1->set_component_text_printf("notification.notifi_label", "%s", label.c_str()); display_wrapped_text->execute("notification.notifi_text01", message.c_str(), display_mode->state == 2 ? 23 : 32); @@ -1202,7 +1228,7 @@ api: if (!id(is_uploading_tft)) { disp1->set_component_text_printf("qrcode.qrcode_label", "%s", title.c_str()); disp1->set_component_text_printf("qrcode.qrcode_value", "%s", qrcode.c_str()); - if (show) disp1->goto_page("qrcode"); + if (show) goto_page->execute("qrcode"); blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 2)); } @@ -1271,10 +1297,17 @@ api: - lambda: |- if (!id(is_uploading_tft) and !(id.empty())) { if (!(icon.empty())) disp1->set_component_text_printf("%s_icon", id.c_str(), icon.c_str()); - if (icon_color.size() == 3) set_component_color->execute((id + "_icon").c_str(), icon_color); + if (icon_color.size() == 3) + disp1->set_component_font_color((id + "_icon").c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(icon_color[0], + icon_color[1], + icon_color[2]))); + if (!(name.empty())) disp1->set_component_text_printf("%s_label", id.c_str(), name.c_str()); if (!(value.empty())) disp1->set_component_text_printf("%s", id.c_str(), value.c_str()); - if (value_color.size() == 3) set_component_color->execute(id.c_str(), value_color); + if (value_color.size() == 3) + disp1->set_component_font_color(id.c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(value_color[0], + value_color[1], + value_color[2]))); } # Wake Up Service @@ -1301,7 +1334,7 @@ api: then: - lambda: |- if (not id(is_uploading_tft)) { - if (current_page->state == "screensaver") disp1->goto_page(wakeup_page_name->state.c_str()); + if (current_page->state == "screensaver") goto_page->execute(wakeup_page_name->state.c_str()); if (reset_timer) timer_reset_all->execute(wakeup_page_name->state.c_str()); else { @@ -1332,6 +1365,8 @@ api: } # yamllint enable rule:comments-indentation +debug: + ##### START - DISPLAY START CONFIGURATION ##### display: - id: disp1 @@ -1344,33 +1379,50 @@ display: static const char *const TAG = "display.disp1.on_page"; if (id(is_uploading_tft)) { ESP_LOGD(TAG, "Page changed ignored as a TFT upload is in progress"); - } else if (x > id(page_names).size()) { + } else if (x > page_names.size()) { ESP_LOGW(TAG, "Invalid page index: %i", int(x)); } else { ESP_LOGD(TAG, "Nextion page changed"); - ESP_LOGD(TAG, "New page: %s (%i)" , id(page_names)[x].c_str(), x); + ESP_LOGD(TAG, "New page: %s (%i)" , page_names[x], x); page_id->update(); - if (current_page->state != id(page_names)[x].c_str() or x == 9) { - current_page->publish_state(id(page_names)[x].c_str()); - page_changed->execute(id(page_names)[x].c_str()); + if (current_page->state != page_names[x] or x == 9) { + current_page->publish_state(page_names[x]); + page_changed->execute(page_names[x]); } } on_touch: lambda: |- static const char *const TAG = "display.disp1.on_touch"; ESP_LOGV(TAG, "Nextion touch event detected!"); - ESP_LOGV(TAG, "Page: %s", id(page_names)[page_id].c_str()); + ESP_LOGV(TAG, "Page: %s", page_names[page_id]); ESP_LOGV(TAG, "Component Id: %i", component_id); ESP_LOGV(TAG, "Event type: %s", touch_event ? "Press" : "Release"); - timer_reset_all->execute(id(page_names)[page_id].c_str()); + timer_reset_all->execute(page_names[page_id]); ##### START - GLOBALS CONFIGURATION ##### globals: - ##### Wi-Fi timeout ##### - - id: wifi_timeout - type: uint + + ####### Relay settings ####### + # Bit # Settings # + # 0 # Relay 1 - Local # + # 1 # Relay 1 - Fallback # + # 2 # reserved # + # 3 # reserved # + # 4 # Relay 2 - Local # + # 5 # Relay 2 - Fallback # + # 6 # reserved # + # 7 # reserved # + ############################## + - id: relay_settings + type: uint8_t + restore_value: true + initial_value: '0' + + ##### Versioning ##### + - id: version_blueprint + type: char[10] restore_value: false - initial_value: ${wifi_timeout} + initial_value: '' ##### Is uploading TFT ##### - id: is_uploading_tft @@ -1386,7 +1438,7 @@ globals: ###### Last volume level from Home Assistant ###### - id: last_volume_level - type: uint + type: uint8_t restore_value: false initial_value: '0' @@ -1402,34 +1454,12 @@ globals: restore_value: false initial_value: '0' - ###### Relay fallback even when buttons have other entities? ###### - - id: relay_1_fallback - type: bool - restore_value: true - initial_value: 'false' - - id: relay_2_fallback - type: bool - restore_value: true - initial_value: 'false' - ##### Is embedded thermostat set as main climate entity? ##### - id: is_embedded_thermostat type: bool restore_value: true initial_value: 'false' - ##### Save Display Brightness for NSPanel reboot ##### - - id: display_brightness_global - type: uint - restore_value: true - initial_value: '100' - - ##### Save Display DIM Brightness for NSPanel reboot - - id: display_dim_brightness_global - type: uint - restore_value: true - initial_value: '10' - ##### Is embedded sensor used for indoor temperature? ##### - id: embedded_indoor_temp type: bool @@ -1438,20 +1468,20 @@ globals: ##### Date/time formats ##### - id: home_date_color - type: uint + type: uint16_t restore_value: true initial_value: '65535' - - id: mui_time_format type: std::string restore_value: true + max_restore_data_length: 15 initial_value: '"%H:%M"' - id: home_time_color - type: uint + type: uint16_t restore_value: true initial_value: '65535' - id: mui_meridiem - type: std::vector + type: std::array restore_value: false initial_value: '{"AM", "PM"}' @@ -1467,19 +1497,19 @@ globals: ##### Chips ##### - id: home_chip_font_id - type: uint + type: uint8_t restore_value: true initial_value: '7' #### Custom buttons #### - id: home_custom_buttons_font_id - type: uint + type: uint8_t restore_value: true initial_value: '8' ##### Relay icons ##### - id: home_relay1_icon - type: std::string + type: char[4] restore_value: true initial_value: '' - id: home_relay1_icon_color @@ -1488,7 +1518,7 @@ globals: initial_value: '65535' - id: home_relay2_icon - type: std::string + type: char[4] restore_value: true initial_value: '' - id: home_relay2_icon_color @@ -1497,10 +1527,10 @@ globals: initial_value: '65535' - id: home_notify_icon_color_normal - type: std::vector + type: uint16_t restore_value: false - id: home_notify_icon_color_unread - type: std::vector + type: uint16_t restore_value: false ##### Screensaver ##### @@ -1509,52 +1539,13 @@ globals: restore_value: true initial_value: 'false' - id: screensaver_display_time_font - type: int + type: uint8_t restore_value: true initial_value: '6' - id: screensaver_display_time_color - type: std::vector + type: uint16_t restore_value: false - initial_value: '{64, 64, 64}' - - - id: page_names - type: std::vector - restore_value: false - initial_value: - '{ - "home", - "weather01", - "weather02", - "weather03", - "weather04", - "weather05", - "climate", - "settings", - "boot", - "screensaver", - "light", - "cover", - "buttonpage01", - "buttonpage02", - "buttonpage03", - "buttonpage04", - "notification", - "qrcode", - "entitypage01", - "entitypage02", - "entitypage03", - "entitypage04", - "fan", - "alarm", - "keyb_num", - "media_player", - "confirm" - }' - - - id: framework - type: uint8_t - restore_value: false - initial_value: '0' # 0 = unknown, 1 = Arduino, 2 = ESP-IDF + initial_value: '16904' - id: page_entity_value_horizontal_alignment type: uint8_t @@ -1590,9 +1581,9 @@ binary_sensor: - if: condition: or: - - switch.is_on: relay1_local + - lambda: return (id(relay_settings) & nspanel_ha_blueprint::RelaySettings::Relay1_Local); - and: - - lambda: !lambda return id(relay_1_fallback); + - lambda: return (id(relay_settings) & nspanel_ha_blueprint::RelaySettings::Relay1_Fallback); - or: - not: - api.connected: @@ -1630,9 +1621,9 @@ binary_sensor: - if: condition: or: - - switch.is_on: relay2_local + - lambda: return (id(relay_settings) & nspanel_ha_blueprint::RelaySettings::Relay2_Local); - and: - - lambda: !lambda return id(relay_2_fallback); + - lambda: return (id(relay_settings) & nspanel_ha_blueprint::RelaySettings::Relay2_Fallback); - or: - not: - api.connected: @@ -1671,6 +1662,8 @@ binary_sensor: publish_initial_state: true entity_category: diagnostic icon: mdi:tablet-dashboard + lambda: |- + return disp1->is_setup(); ##### API connection status - name: Status @@ -1722,10 +1715,9 @@ number: step: 1 restore_value: true optimistic: true - set_action: + on_value: then: - lambda: |- - id(display_brightness_global) = int(x); disp1->send_command_printf("brightness=%i", int(x)); disp1->send_command_printf("settings.brightslider.val=%i", int(x)); if (current_page->state != "screensaver") @@ -1749,13 +1741,12 @@ number: step: 1 restore_value: true optimistic: true - set_action: + on_value: then: - lambda: |- - id(display_dim_brightness_global) = int(x); disp1->send_command_printf("brightness_dim=%i", int(x)); disp1->send_command_printf("settings.dimslider.val=%i", int(x)); - if (current_page->state != "screensaver" and (current_brightness->state <= id(display_dim_brightness_global))) + if (current_page->state != "screensaver" and (current_brightness->state <= display_dim_brightness->state)) { set_brightness->execute(x); timer_sleep->execute(current_page->state.c_str(), int(timeout_sleep->state)); @@ -1774,10 +1765,9 @@ number: step: 1 restore_value: true optimistic: true - set_action: + on_value: then: - lambda: |- - id(display_dim_brightness_global) = int(x); disp1->send_command_printf("brightness_sleep=%i", int(x)); page_screensaver->execute(); @@ -1795,7 +1785,7 @@ number: restore_value: true internal: false optimistic: true - set_action: + on_value: - logger.log: Temperature correction changed. - delay: 1s - lambda: temp_nspanel->publish_state(temp_nspanel->raw_state); @@ -1813,7 +1803,7 @@ number: optimistic: true icon: mdi:timer unit_of_measurement: "s" - set_action: + on_value: - lambda: timer_page->execute(current_page->state.c_str(), int(x)); - name: Timeout Dimming platform: template @@ -1827,7 +1817,7 @@ number: optimistic: true icon: mdi:timer unit_of_measurement: "s" - set_action: + on_value: - lambda: timer_dim->execute(current_page->state.c_str(), int(x)); - name: Timeout Sleep platform: template @@ -1841,7 +1831,7 @@ number: optimistic: true icon: mdi:timer unit_of_measurement: "s" - set_action: + on_value: - lambda: |- timer_dim->execute(current_page->state.c_str(), int(timeout_dim->state)); timer_sleep->execute(current_page->state.c_str(), int(x)); @@ -1904,6 +1894,10 @@ select: ##### START - SENSOR CONFIGURATION ##### sensor: + - platform: debug + free: + name: "Heap Free" + ##### Blueprint status ##### # Bit # Settings step # # 0 # reserved # @@ -2028,11 +2022,11 @@ sensor: ESP_LOGD(TAG, "New page Id: %i", int(x)); if (id(is_uploading_tft)) { ESP_LOGD(TAG, "Skipping actions as a TFT upload is in progress"); - } else if (x > id(page_names).size()) { + } else if (x > page_names.size()) { ESP_LOGW(TAG, "Invalid page index: %i", int(x)); - } else if (current_page->state != id(page_names)[x].c_str()) { - current_page->publish_state(id(page_names)[x].c_str()); - page_changed->execute(id(page_names)[x].c_str()); + } else if (current_page->state != page_names[x]) { + current_page->publish_state(page_names[x]); + page_changed->execute(page_names[x]); } ##### Display mode (1 = EU, 2 = US, 3 = US Landscape) @@ -2080,12 +2074,12 @@ switch: - wait_until: condition: - lambda: !lambda return (blueprint_status->state > 99); - - lambda: set_component_color->execute("home.bt_notific", id(home_notify_icon_color_unread)); + - lambda: disp1->set_component_font_color("home.bt_notific", id(home_notify_icon_color_unread)); on_turn_off: - wait_until: condition: - lambda: !lambda return (blueprint_status->state > 99); - - lambda: set_component_color->execute("home.bt_notific", id(home_notify_icon_color_normal)); + - lambda: disp1->set_component_font_color("home.bt_notific", id(home_notify_icon_color_normal)); ##### Notification sound ##### - name: Notification sound @@ -2139,38 +2133,12 @@ switch: - lambda: !lambda return disp1->is_setup(); timeout: 20s - lambda: |- - if (id(setup_sequence_completed)) { - nextion_init->publish_state(disp1->is_setup()); - disp1->goto_page(wakeup_page_name->state.c_str()); - } + nextion_init->publish_state(disp1->is_setup()); + goto_page->execute(wakeup_page_name->state.c_str()); on_turn_off: - lambda: |- nextion_init->publish_state(false); - ##### Relay Local control ##### - - name: Relay 1 Local - platform: template - id: relay1_local - entity_category: config - optimistic: true - restore_mode: RESTORE_DEFAULT_OFF - internal: true - on_turn_on: - - logger.log: "Relay 1 Local turned On!" - on_turn_off: - - logger.log: "Relay 1 Local turned Off!" - - name: Relay 2 Local - platform: template - id: relay2_local - entity_category: config - optimistic: true - restore_mode: RESTORE_DEFAULT_OFF - internal: true - on_turn_on: - - logger.log: "Relay 2 Local turned On!" - on_turn_off: - - logger.log: "Relay 2 Local turned Off!" - ##### START - TEXT SENSOR CONFIGURATION ##### text_sensor: ##### Device name - Used by bluepring to find service's names ##### @@ -2277,7 +2245,7 @@ text_sensor: } else if (event == "click" and page == "home" and component == "climate") { detailed_entity->publish_state((id(is_embedded_thermostat)) ? "embedded_climate" : ""); disp1->set_component_value("climate.embedded", id(is_embedded_thermostat) ? 1 : 0); - disp1->goto_page("climate"); + goto_page->execute("climate"); } else if (page == "light" or page == "climate" or page == "notification") { // Generic event auto ha_event = new esphome::api::CustomAPIDevice(); ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", { @@ -2297,7 +2265,7 @@ text_sensor: std::string title = doc["mui"]; if (code_format == "number" and (key == "disarm" or code_arm_req == "1")) { - disp1->goto_page("keyb_num"); + goto_page->execute("keyb_num"); disp1->set_component_value("keyb_num.page_id", 23); //Calling from Alarm page disp1->set_component_text_printf("keyb_num.domain", "%s", page.c_str()); disp1->set_component_text_printf("keyb_num.key", "%s", key.c_str()); @@ -2326,7 +2294,7 @@ text_sensor: service_call_alarm_control_panel->execute(entity.c_str(), key.c_str(), code_format.c_str(), pin.c_str()); } else if (base_domain == "" or base_domain.empty()) base_domain = "home"; - disp1->goto_page(base_domain.c_str()); + goto_page->execute(base_domain.c_str()); } else if (page == "light") ha_call_service->execute("light.turn_on", key.c_str(), value.c_str(), entity.c_str()); else if (page == "media_player") { @@ -2336,54 +2304,13 @@ text_sensor: } ##### Versioning ##### - - id: version_blueprint - name: Version Blueprint - platform: template - entity_category: diagnostic - icon: mdi:tag-text-outline - internal: false - update_interval: never - lambda: |- - return {"unknown"}; - on_value: - - lambda: |- - static const char *const TAG = "text_sensor.version_blueprint"; - ESP_LOGD(TAG, "Blueprint version: %s", x.c_str()); - disp1->set_component_text_printf("boot.bluep_version", "%s", x.c_str()); - if (current_page->state == "boot") { - disp1->send_command_printf("tm_esphome.en=0"); - page_boot->execute(); - timer_reset_all->execute("boot"); - } - check_versions->execute(); - - - id: version_esphome - name: Version ESPHome - platform: template - entity_category: diagnostic - icon: mdi:tag-text-outline - internal: false - lambda: |- - return {"${version}"}; - on_value: - - lambda: |- - static const char *const TAG = "text_sensor.version_esphome"; - ESP_LOGD(TAG, "ESPHome version: %s", x.c_str()); - disp1->set_component_text_printf("boot.esph_version", x.c_str()); - if (current_page->state == "boot") { - disp1->send_command_printf("tm_esphome.en=0"); - page_boot->execute(); - timer_reset_all->execute("boot"); - } - check_versions->execute(); - - id: version_tft name: Version TFT platform: nextion component_name: boot.tft_version - entity_category: diagnostic - icon: mdi:tag-text-outline - internal: false + #entity_category: diagnostic + #icon: mdi:tag-text-outline + internal: true update_interval: never on_value: - lambda: |- @@ -2420,37 +2347,17 @@ script: - wait_until: condition: - lambda: |- - auto compareVersions = [](const char* version1, const char* version2) -> bool - { - int major1 = 0, minor1 = 0; - int major2 = 0, minor2 = 0; - - sscanf(version1, "%d.%d", &major1, &minor1); - sscanf(version2, "%d.%d", &major2, &minor2); - - return (major1 == major2) && (minor1 == minor2); - }; - return (compareVersions("${version}", version_tft->state.c_str()) and compareVersions("${version}", version_blueprint->state.c_str())); + return (compare_versions("${version}", version_tft->state.c_str()) and compare_versions("${version}", id(version_blueprint))); timeout: 60s - lambda: |- if (id(is_uploading_tft)) check_versions->stop(); static const char *const TAG = "script.check_versions"; - auto compareVersions = [](const char* version1, const char* version2) -> bool - { - int major1 = 0, minor1 = 0; - int major2 = 0, minor2 = 0; - - sscanf(version1, "%d.%d", &major1, &minor1); - sscanf(version2, "%d.%d", &major2, &minor2); - - return (major1 == major2) && (minor1 == minor2); - }; ESP_LOGD(TAG, "Versions:"); ESP_LOGD(TAG, " ESPHome: ${version}"); ESP_LOGD(TAG, " TFT: %s", version_tft->state.c_str()); - if (not compareVersions("${version}", version_tft->state.c_str())) ESP_LOGE(TAG, "TFT version mismatch!"); - ESP_LOGD(TAG, " Blueprint: %s", version_blueprint->state.c_str()); - if (not compareVersions("${version}", version_blueprint->state.c_str())) ESP_LOGE(TAG, "Blueprint version mismatch!"); + if (not compare_versions("${version}", version_tft->state.c_str())) ESP_LOGE(TAG, "TFT version mismatch!"); + ESP_LOGD(TAG, " Blueprint: %s", id(version_blueprint)); + if (not compare_versions("${version}", id(version_blueprint))) ESP_LOGE(TAG, "Blueprint version mismatch!"); auto ha_event = new esphome::api::CustomAPIDevice(); ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", @@ -2458,7 +2365,7 @@ script: {"type", "version"}, {"tft", version_tft->state.c_str()}, {"esphome", "${version}"}, - {"blueprint", version_blueprint->state.c_str()} + {"blueprint", id(version_blueprint)} }); - id: display_embedded_temp @@ -2527,7 +2434,9 @@ script: static const char *const TAG = "script.global_settings"; // Blueprint version ESP_LOGV(TAG, "Check Blueprint version"); - version_blueprint->publish_state(blueprint_version.c_str()); + nspanel_ha_blueprint::copyStringToCharArray(id(version_blueprint), blueprint_version); + disp1->set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str()); + if (current_page->state == "boot") page_boot->execute(); check_versions->execute(); // Embedded thermostat @@ -2547,7 +2456,7 @@ script: ESP_LOGV(TAG, "Setup screensaver page"); id(screensaver_display_time) = screensaver_time; id(screensaver_display_time_font) = screensaver_time_font; - id(screensaver_display_time_color) = screensaver_time_color; + id(screensaver_display_time_color) = esphome::display::ColorUtil::color_to_565(esphome::Color(screensaver_time_color[0], screensaver_time_color[1], screensaver_time_color[2])); page_screensaver->execute(); // Entities pages alignment @@ -2592,12 +2501,21 @@ script: rtttl: 'two short:d=4,o=5,b=100:16e6,16e6' - lambda: |- ESP_LOGD("script.global_settings", "Jump to wake-up page: %s", wakeup_page_name->state.c_str()); - disp1->goto_page(wakeup_page_name->state.c_str()); + goto_page->execute(wakeup_page_name->state.c_str()); timer_reset_all->execute(wakeup_page_name->state.c_str()); - lambda: |- ESP_LOGV("script.global_settings", "Finished"); + - id: goto_page + mode: restart + parameters: + page: string + then: + - lambda: |- + if (current_page->state != page) + disp1->goto_page(page.c_str()); + - id: ha_button mode: parallel parameters: @@ -2667,7 +2585,7 @@ script: notification_text->publish_state(""); notification_unread->turn_off(); refresh_notification->execute(); - if (current_page->state == "notification") disp1->goto_page("home"); + if (current_page->state == "notification") goto_page->execute("home"); } - id: entity_details_show @@ -2683,9 +2601,8 @@ script: if (page == "alarm_control_panel") page = "alarm"; detailed_entity->publish_state(entity); if (page == "alarm_control_panel") page = "alarm"; - std::string cmd_page = std::string("page ") + page.c_str(); - disp1->send_command_printf(cmd_page.c_str()); - set_page_id->execute("back_page_id", back_page.c_str()); + disp1->send_command_printf("page %s", page.c_str()); + disp1->send_command_printf("back_page_id=%" PRIu8, get_page_id(back_page.c_str())); if (page == "climate") disp1->set_component_value("embedded", (entity == "embedded_climate") ? 1 : 0); } @@ -2701,8 +2618,11 @@ script: static const char *const TAG = "script.page_blank"; ESP_LOGV(TAG, "Construct blank page"); disp1->set_component_text_printf("esp_version", "ESP: ${version}"); // ESPHome version - disp1->set_component_text_printf("framework", "%s", id(framework) == 1 ? "Arduino" : - (id(framework) == 2 ? "ESP-IDF" : "Unknown")); // ESPHome framework + #ifdef ARDUINO + disp1->set_component_text_printf("framework", "Arduino"); + #elif defined(USE_ESP_IDF) + disp1->set_component_text_printf("framework", "ESP-IDF"); + #endif disp1->send_command_printf("tm_esphome.en=0"); - id: page_boot @@ -2714,10 +2634,12 @@ script: set_brightness->execute(100); disp1->set_component_text_printf("boot.esph_version", "${version}"); // ESPHome version - disp1->set_component_text_printf("framework", "%s", id(framework) == 1 ? "Arduino" : - (id(framework) == 2 ? "ESP-IDF" : "Unknown")); // ESPHome framework + #ifdef ARDUINO + disp1->set_component_text_printf("framework", "Arduino"); + #elif defined(USE_ESP_IDF) + disp1->set_component_text_printf("framework", "ESP-IDF"); + #endif disp1->send_command_printf("tm_esphome.en=0"); - // disp1->show_component("bt_reboot"); - id: page_buttonpage mode: restart @@ -2758,7 +2680,7 @@ script: static const char *const TAG = "script.page_changed"; // Go to boot page if not initiated - if (page != "boot" and not nextion_init->state) disp1->goto_page("boot"); + if (not nextion_init->state) goto_page->execute("boot"); // Reset globals if (page != "alarm" && //DEBOG page != "climate" && @@ -2921,11 +2843,10 @@ script: if (current_page->state == "screensaver" and not id(is_uploading_tft)) { static const char *const TAG = "script.page_screensaver"; ESP_LOGV(TAG, "Updating screensaver page"); - set_page_id->execute("back_page_id", wakeup_page_name->state.c_str()); - // disp1->send_command_printf("back_page_id=%i", id(wakeup_page_id)); + disp1->send_command_printf("back_page_id=%" PRIu8, get_page_id(wakeup_page_name->state.c_str())); if (id(screensaver_display_time)) { disp1->send_command_printf("screensaver.text.font=%i", id(screensaver_display_time_font)); - set_component_color->execute("screensaver.text",id(screensaver_display_time_color)); + disp1->set_component_font_color("screensaver.text", id(screensaver_display_time_color)); disp1->show_component("text"); refresh_datetime->execute(); } else { @@ -3025,7 +2946,7 @@ script: static const char *const TAG = "script.refresh_notification"; bool is_notification = ((not notification_text->state.empty()) or (not notification_label->state.empty())); ESP_LOGV(TAG, "Notification: %s", YESNO(is_notification)); - disp1->send_command_printf("is_notification=%i", is_notification ? 0 : 1); + disp1->send_command_printf("is_notification=%i", is_notification ? 1 : 0); if (current_page->state == "home") { if (is_notification) { disp1->show_component("bt_notific"); @@ -3037,18 +2958,18 @@ script: condition: - lambda: return (blueprint_status->state > 99); - lambda: |- - set_component_color->execute("home.bt_notific", notification_unread->state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal)); + disp1->set_component_font_color("home.bt_notific", notification_unread->state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal)); - id: refresh_relays mode: restart then: - lambda: |- // Chips - Relays - disp1->set_component_text_printf("home.icon_top_01", "%s", (relay_1->state) ? id(home_relay1_icon).c_str() : "\uFFFF"); - disp1->set_component_text_printf("home.icon_top_02", "%s", (relay_2->state) ? id(home_relay2_icon).c_str() : "\uFFFF"); + disp1->set_component_text_printf("home.icon_top_01", "%s", (relay_1->state) ? id(home_relay1_icon) : "\uFFFF"); + disp1->set_component_text_printf("home.icon_top_02", "%s", (relay_2->state) ? id(home_relay2_icon) : "\uFFFF"); // Hardware buttons bars - Fallback mode - if (relay1_local->state) disp1->send_command_printf("home.left_bt_pic.val=%i", (relay_1->state) ? 1 : 0); - if (relay2_local->state) disp1->send_command_printf("home.right_bt_pic.val=%i", (relay_2->state) ? 1 : 0); + if (id(relay_settings) & nspanel_ha_blueprint::RelaySettings::Relay1_Local) disp1->send_command_printf("home.left_bt_pic.val=%i", (relay_1->state) ? 1 : 0); + if (id(relay_settings) & nspanel_ha_blueprint::RelaySettings::Relay2_Local) disp1->send_command_printf("home.right_bt_pic.val=%i", (relay_2->state) ? 1 : 0); - id: refresh_wifi_icon mode: restart @@ -3067,66 +2988,14 @@ script: "\uE5A9"); // mdi:wifi-off } - - id: relay_settings - mode: restart - parameters: - relay1_local_control: bool - relay1_icon: string - relay1_icon_color: int - relay1_fallback: bool - relay2_local_control: bool - relay2_icon: string - relay2_icon_color: int - relay2_fallback: bool - then: - - if: - condition: - lambda: 'return id(is_uploading_tft);' - then: - - script.stop: relay_settings - - lambda: |- - static const char *const TAG = "script.relay_settings"; - // Relays - ESP_LOGV(TAG, "Setup relays"); - relay1_local->publish_state(relay1_local_control); - relay2_local->publish_state(relay2_local_control); - id(relay_1_fallback) = relay1_fallback; - id(relay_2_fallback) = relay2_fallback; - disp1->set_component_font_color("home.icon_top_01", relay1_icon_color); - disp1->set_component_font_color("home.icon_top_02", relay2_icon_color); - disp1->set_component_text_printf("home.icon_top_01", "%s", relay1_icon.c_str()); - disp1->set_component_text_printf("home.icon_top_02", "%s", relay2_icon.c_str()); - id(home_relay1_icon) = relay1_icon.c_str(); - id(home_relay2_icon) = relay2_icon.c_str(); - id(home_relay1_icon_color) = relay1_icon_color; - id(home_relay2_icon_color) = relay2_icon_color; - ESP_LOGV(TAG, "Finished"); - - id: restore_settings mode: restart then: - - lambda: |- - ESP_LOGD("script.restore_settings", "Restoring settings"); - - #ifdef ARDUINO - id(framework) = 1; - #elif defined(USE_ESP_IDF) - id(framework) = 2; - #endif - - // ESP_LOGV(TAG, "Restoring wake-up page selector"); - // auto wakeup_page_name_call = id(wakeup_page_name).make_call(); - // wakeup_page_name_call.set_option(id(page_names)[id(wakeup_page_id)]); - // wakeup_page_name_call.perform(); - - // id(is_restored_settings) = true; - wait_until: condition: - lambda: return (not isnan(stoi(baud_rate->state))); - lambda: |- - ESP_LOGV("script.restore_settings", "Restoring baud rate"); set_baud_rate->execute(stoi(baud_rate->state), true); - ESP_LOGV("script.restore_settings", "Done!"); - id: service_call_alarm_control_panel mode: restart @@ -3198,15 +3067,15 @@ script: - id: set_brightness mode: restart parameters: - brightness: uint + brightness: float then: - lambda: |- static const char *const TAG = "script.set_brightness"; - ESP_LOGD(TAG, "brightness: %i%%", brightness); - if (brightness == id(display_brightness_global) and current_page->state != "screensaver") + ESP_LOGD(TAG, "brightness: %.0f%%", brightness); + if (brightness == display_brightness->state and current_page->state != "screensaver") disp1->send_command_printf("wakeup_timer.en=1"); else - disp1->set_backlight_brightness(static_cast(brightness) / 100.0f); + disp1->set_backlight_brightness(brightness / 100.0f); current_brightness->update(); - delay: 5s - lambda: current_brightness->update(); @@ -3298,60 +3167,6 @@ script: } ESP_LOGD(TAG, "Finished"); - - id: set_component_color - mode: queued - parameters: - component: string - foreground: int32_t[] - then: - - lambda: |- - if (id(is_uploading_tft)) set_component_color->stop(); - static const char *const TAG = "script.set_component_color"; - ESP_LOGVV(TAG, "Starting:"); - ESP_LOGVV(TAG, " Component: %s", component.c_str()); - int fg565 = -1; - // Foreground - if (foreground.size() == 3 and - foreground[0] >= 0 and - foreground[1] >= 0 and - foreground[2] >= 0) { - ESP_LOGVV(TAG, " Foreground: {%i, %i, %i}", foreground[0], foreground[1], foreground[2]); - fg565 = ((foreground[0] & 0b11111000) << 8) | ((foreground[1] & 0b11111100) << 3) | (foreground[2] >> 3); - } - else if (foreground.size() == 1) fg565 = foreground[0]; - else { - ESP_LOGE(TAG, " Component: %s", component.c_str()); - ESP_LOGE(TAG, " Foreground size: %i", foreground.size()); - fg565 = -1; - } - ESP_LOGVV(TAG, " Foreground: %i", fg565); - if (fg565 >= 0) disp1->set_component_font_color(component.c_str(), fg565); - - - id: set_page_id - mode: queued - parameters: - variable: string - page: string - then: - - lambda: |- - static const char *const TAG = "script.set_page_id"; - ESP_LOGV(TAG, "Starting:"); - ESP_LOGV(TAG, " Variable: %s", variable.c_str()); - ESP_LOGV(TAG, " Page: %s", page.c_str()); - - auto pageIndex = [](const std::string& page_name) -> uint8_t { - for (uint8_t i = 0; i < id(page_names).size(); ++i) { - if (id(page_names)[i] == page_name) { - return i; // Return the index if found - } - } - return 0u; // Return 0 (home page) if not found - }; - - uint detected_page_id = pageIndex(page.c_str()); - ESP_LOGV(TAG, "%s=%i", variable.c_str(), detected_page_id); - disp1->send_command_printf("%s=%i", variable.c_str(), detected_page_id); - - id: setup_sequence mode: restart then: @@ -3387,7 +3202,7 @@ script: - lambda: |- static const char *const TAG = "script.setup_sequence"; ESP_LOGD(TAG, "Goto page Boot"); - disp1->goto_page("boot"); + goto_page->execute("boot"); ESP_LOGD(TAG, "Fetching TFT version"); version_tft->update(); - wait_until: @@ -3449,14 +3264,12 @@ script: - lambda: |- static const char *const TAG = "script.setup_sequence"; ESP_LOGD(TAG, "Set dimming values"); - display_brightness->publish_state(id(display_brightness_global)); - display_dim_brightness->publish_state(id(display_dim_brightness_global)); - set_brightness->execute(id(display_brightness_global)); + set_brightness->execute(display_brightness->state); ESP_LOGD(TAG, "Set page Settings"); - disp1->send_command_printf("brightness=%i", id(display_brightness_global)); - disp1->send_command_printf("settings.brightslider.val=%i", id(display_brightness_global)); - disp1->send_command_printf("brightness_dim=%i", id(display_dim_brightness_global)); - disp1->send_command_printf("settings.dimslider.val=%i", id(display_dim_brightness_global)); + disp1->send_command_printf("brightness=%i", int(display_brightness->state)); + disp1->send_command_printf("settings.brightslider.val=%i", int(display_brightness->state)); + disp1->send_command_printf("brightness_dim=%i", int(display_dim_brightness->state)); + disp1->send_command_printf("settings.dimslider.val=%i", int(display_dim_brightness->state)); disp1->send_command_printf("brightness_sleep=%i", int(display_sleep_brightness->state)); ESP_LOGD(TAG, "Report to Home Assistant"); nextion_init->publish_state(disp1->is_setup()); @@ -3482,9 +3295,9 @@ script: disp1->send_command_printf("home.bt_qrcode.font=%i", id(home_custom_buttons_font_id)); disp1->send_command_printf("home.bt_entities.font=%i", id(home_custom_buttons_font_id)); disp1->send_command_printf("home.wifi_icon.font=%i", id(home_chip_font_id)); - ESP_LOGV(TAG, "Restoring relay's icons"); - disp1->set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str()); - disp1->set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str()); + ESP_LOGV(TAG, "Restoring relay's icon colors"); + disp1->set_component_font_color("home.icon_top_01", id(home_relay1_icon_color)); + disp1->set_component_font_color("home.icon_top_02", id(home_relay2_icon_color)); timer_reset_all->execute("boot"); notification_clear->execute(); id(setup_sequence_completed) = true; @@ -3497,7 +3310,7 @@ script: state: boot timeout: 10s - lambda: |- - if (current_page->state == "boot") disp1->goto_page(wakeup_page_name->state.c_str()); + if (current_page->state == "boot") goto_page->execute(wakeup_page_name->state.c_str()); else: # Unknown TFT - lambda: |- static const char *const TAG = "script.setup_sequence"; @@ -3558,13 +3371,10 @@ script: refresh_datetime->stop(); refresh_relays->stop(); refresh_wifi_icon->stop(); - relay_settings->stop(); service_call_alarm_control_panel->stop(); set_baud_rate->stop(); set_brightness->stop(); set_climate->stop(); - set_component_color->stop(); - set_page_id->stop(); setup_sequence->stop(); timer_dim->stop(); timer_page->stop(); @@ -3615,7 +3425,7 @@ script: current_page->state != "screensaver") { ESP_LOGD("script.timer_page", "Fallback to page Home"); - disp1->goto_page("home"); + goto_page->execute("home"); } - id: timer_dim # Handles the brightness dimming after a timeout mode: restart @@ -3625,12 +3435,12 @@ script: then: - lambda: |- ESP_LOGV("script.timer_dim", "Reset timer: %is", timeout); - if (current_brightness->state <= id(display_dim_brightness_global) + if (current_brightness->state <= display_dim_brightness->state and page != "screensaver" and page != "boot" and page != "blank-screensaver") { ESP_LOGD("script.timer_dim", "Waking up on page: %s", page.c_str()); - set_brightness->execute(id(display_brightness_global)); + set_brightness->execute(display_brightness->state); } - if: condition: @@ -3642,9 +3452,9 @@ script: current_page->state != "blank-screensaver" and current_page->state != "boot" and timeout >= 1) { - set_brightness->execute(id(display_dim_brightness_global)); + set_brightness->execute(display_dim_brightness->state); } - - id: timer_sleep # Handles the sleep (go to screensaver page) after a timeout + - id: timer_sleep # Handles the sleep (go to screensaver page) after a timeout mode: restart parameters: page: string @@ -3663,7 +3473,7 @@ script: current_page->state != "boot" and timeout >= 1) { ESP_LOGD("script.timer_sleep", "Going to sleep from page %s", current_page->state.c_str()); - disp1->goto_page("screensaver"); + goto_page->execute("screensaver"); set_brightness->execute(display_sleep_brightness->state); } @@ -3802,7 +3612,6 @@ script: // report Wi-Fi status bool wifi_connected = wifi_component->is_connected(); if (wifi_connected) { - id(wifi_timeout) = ${wifi_timeout}; float rssi = wifi_rssi->state; std::string rssi_status = "Unknown"; if (rssi > -50) rssi_status = "Excellent"; @@ -3815,15 +3624,7 @@ script: else ESP_LOGE(TAG, "Wi-Fi: %s (%.0f dBm)", rssi_status.c_str(), rssi); } else { - ESP_LOGW(TAG, "Wi-Fi: DISCONNECTED"); - if (id(wifi_timeout) > 0) { - id(wifi_timeout)--; - ESP_LOGI(TAG, "Retrying Wi-Fi connection"); - wifi_component->retry_connect(); - } else { - ESP_LOGE(TAG, "Restarting ESP due to a Wi-Fi timeout..."); - App.safe_reboot(); - } + ESP_LOGE(TAG, "Wi-Fi: DISCONNECTED"); } // report API status @@ -3831,7 +3632,7 @@ script: if (api_connected) { ESP_LOGI(TAG, "API: Connected"); } else { - ESP_LOGW(TAG, "API: DISCONNECTED"); + ESP_LOGE(TAG, "API: DISCONNECTED"); blueprint_status->publish_state(0); if (current_page->state != "blank" and current_page->state != "boot" and @@ -3840,7 +3641,7 @@ script: current_page->state != "settings" and current_page->state != "qrcode") { ESP_LOGI(TAG, "Fallback to page Home"); - disp1->goto_page("home"); + goto_page->execute("home"); } } @@ -3849,7 +3650,7 @@ script: // Report blueprint version ESP_LOGI(TAG, "Blueprint:"); if (blueprint_status->state > 99) { - ESP_LOGI(TAG, " Version: %s", version_blueprint->state.c_str()); + ESP_LOGI(TAG, " Version: %s", id(version_blueprint)); ESP_LOGI(TAG, " Init steps: %i (%0.1f%%)", int(blueprint_status->raw_state), blueprint_status->state); } else { ESP_LOGW(TAG, " Init steps: %i (%0.1f%%)", int(blueprint_status->raw_state), blueprint_status->state); @@ -3868,17 +3669,17 @@ script: ESP_LOGI(TAG, " Version: ${version}"); // Report framework #ifdef ARDUINO + ESP_LOGI(TAG, " Framework: Arduino"); size_t total_heap_size = ESP.getHeapSize(); size_t free_heap_size = ESP.getFreeHeap(); #elif defined(USE_ESP_IDF) + ESP_LOGI(TAG, " Framework: ESP-IDF"); size_t total_heap_size = heap_caps_get_total_size(MALLOC_CAP_DEFAULT); size_t free_heap_size = esp_get_free_heap_size(); #endif if (total_heap_size != 0) ESP_LOGI(TAG, " Heap: %zu bytes (%d%%)", free_heap_size, int(round(((float)free_heap_size / total_heap_size) * 100.0f))); - ESP_LOGI(TAG, " Framework: %s", id(framework) == 1 ? "Arduino" : - (id(framework) == 2 ? "ESP-IDF" : "Unknown")); // ESPHome framework // Report UART ESP_LOGI(TAG, "UART:"); diff --git a/hmi/nspanel_eu.HMI b/hmi/nspanel_eu.HMI index fdaec77..bf1b714 100644 Binary files a/hmi/nspanel_eu.HMI and b/hmi/nspanel_eu.HMI differ diff --git a/hmi/nspanel_us_land.HMI b/hmi/nspanel_us_land.HMI index e30e16c..ee2ab9b 100644 Binary files a/hmi/nspanel_us_land.HMI and b/hmi/nspanel_us_land.HMI differ diff --git a/hmi/nspanel_us_land.tft b/hmi/nspanel_us_land.tft index 2df0621..22ffbe6 100644 Binary files a/hmi/nspanel_us_land.tft and b/hmi/nspanel_us_land.tft differ diff --git a/hmi/nspanel_us_land_code/utilities.txt b/hmi/nspanel_us_land_code/utilities.txt new file mode 100644 index 0000000..cf4600e --- /dev/null +++ b/hmi/nspanel_us_land_code/utilities.txt @@ -0,0 +1,430 @@ +Page utilities + Attributes + ID : 0 + Scope : local + Dragging : 0 + Send Component ID : on press and release + Locked : no + Swide up page ID : disabled + Swide down page ID : disabled + Swide left page ID : disabled + Swide right page ID: disabled + + Events + Preinitialize Event + if(api==0) + { + page home + } + vis unavailable,0 + + Postinitialize Event + sendme + +Text title + Attributes + ID : 1 + Scope : local + Dragging : 0 + Send Component ID : on press and release + Associated Keyboard: none + Text : Power Dashboard + Max. Text Size : 100 + +Text title_icon + Attributes + ID : 2 + Scope : local + Dragging : 0 + Send Component ID : on press and release + Associated Keyboard: none + Text :  + Max. Text Size : 10 + +Text unavailable + Attributes + ID : 5 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : + Max. Text Size : 1 + +Text t0 + Attributes + ID : 6 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : î´½ + Max. Text Size : 4 + +Text t1 + Attributes + ID : 7 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 賈 + Max. Text Size : 4 + +Text t2 + Attributes + ID : 9 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text :  + Max. Text Size : 4 + +Text t3 + Attributes + ID : 10 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text :  + Max. Text Size : 4 + +Text t4 + Attributes + ID : 11 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : Green + Max. Text Size : 10 + +Text t5 + Attributes + ID : 12 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : Fossil + Max. Text Size : 10 + +Text t6 + Attributes + ID : 15 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : Home + Max. Text Size : 10 + +Text t7 + Attributes + ID : 16 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 全 + Max. Text Size : 4 + +Text t8 + Attributes + ID : 17 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : Solar + Max. Text Size : 10 + +Text t9 + Attributes + ID : 19 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 98% + Max. Text Size : 10 + +Text t10 + Attributes + ID : 20 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 2% + Max. Text Size : 10 + +Text t11 + Attributes + ID : 21 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 豈 + Max. Text Size : 4 + +Text t12 + Attributes + ID : 22 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : Battery + Max. Text Size : 10 + +Text t13 + Attributes + ID : 24 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 暑 + Max. Text Size : 4 + +Text t14 + Attributes + ID : 25 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : Heating + Max. Text Size : 10 + +Text t15 + Attributes + ID : 27 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 1.7 kW + Max. Text Size : 10 + +Text t16 + Attributes + ID : 28 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 21.7°C + Max. Text Size : 10 + +Text t17 + Attributes + ID : 29 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 1.1 kW + Max. Text Size : 10 + +Text t18 + Attributes + ID : 30 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : -2.1 kW + Max. Text Size : 10 + +Text t19 + Attributes + ID : 31 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 0.8 kW + Max. Text Size : 10 + +Text t20 + Attributes + ID : 32 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 慎 + Max. Text Size : 4 + +Text t21 + Attributes + ID : 33 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : Wind + Max. Text Size : 10 + +Text t22 + Attributes + ID : 35 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 1.1 kW + Max. Text Size : 10 + +Text t23 + Attributes + ID : 36 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : î—° + Max. Text Size : 4 + +Text t24 + Attributes + ID : 37 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : Car + Max. Text Size : 10 + +Text t25 + Attributes + ID : 39 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : 1.1 kW + Max. Text Size : 10 + +Slider h0 + Attributes + ID : 8 + Scope : local + Dragging : 0 + Send Component ID: disabled + Position : 50 + Upper range limit: 100 + Lower range limit: 0 + +Slider h1 + Attributes + ID : 13 + Scope : local + Dragging : 0 + Send Component ID: disabled + Position : 50 + Upper range limit: 100 + Lower range limit: 0 + +Slider h2 + Attributes + ID : 14 + Scope : local + Dragging : 0 + Send Component ID: disabled + Position : 50 + Upper range limit: 100 + Lower range limit: 0 + +Slider h3 + Attributes + ID : 18 + Scope : local + Dragging : 0 + Send Component ID: disabled + Position : 50 + Upper range limit: 100 + Lower range limit: 0 + +Slider h4 + Attributes + ID : 23 + Scope : local + Dragging : 0 + Send Component ID: disabled + Position : 50 + Upper range limit: 100 + Lower range limit: 0 + +Slider h5 + Attributes + ID : 26 + Scope : local + Dragging : 0 + Send Component ID: disabled + Position : 50 + Upper range limit: 100 + Lower range limit: 0 + +Slider h6 + Attributes + ID : 34 + Scope : local + Dragging : 0 + Send Component ID: disabled + Position : 50 + Upper range limit: 100 + Lower range limit: 0 + +Slider h7 + Attributes + ID : 38 + Scope : local + Dragging : 0 + Send Component ID: disabled + Position : 50 + Upper range limit: 100 + Lower range limit: 0 + +Button button_back + Attributes + ID : 3 + Scope : local + Dragging : 0 + Send Component ID: on press and release + State : unpressed + Text : î…˜ + Max. Text Size : 3 + + Events + Touch Press Event + page back_page_id + +Timer wakeup_timer + Attributes + ID : 4 + Scope : local + Period (ms): 100 + Enabled : yes + + Events + Timer Event + if(dim - {% set temp_color = + {{ hardware.relays.relay1.icon_color_rgb if hardware.relays.relay1.icon_color_rgb is defined and hardware.relays.relay1.icon_color_rgb is sequence and hardware.relays.relay1.icon_color_rgb | count == 3 else nextion.color.on - %} - {{ - ((temp_color[0] //(2**3)) *(2**11)) + - ((temp_color[1] //(2**2)) *(2**5)) + - ((temp_color[2] //(2**3))) }} relay1_fallback: '{{ hardware.relays.relay1.fallback }}' relay2_local_control: '{{ hardware.buttons.right.entity == relay02_entity }}' @@ -7200,18 +7195,13 @@ action: ) }} relay2_icon_color: > - {% set temp_color = + {{ hardware.relays.relay2.icon_color_rgb if hardware.relays.relay2.icon_color_rgb is defined and hardware.relays.relay2.icon_color_rgb is sequence and hardware.relays.relay2.icon_color_rgb | count == 3 else nextion.color.on - %} - {{ - ((temp_color[0] //(2**3)) *(2**11)) + - ((temp_color[1] //(2**2)) *(2**5)) + - ((temp_color[2] //(2**3))) }} relay2_fallback: '{{ hardware.relays.relay2.fallback }}' continue_on_error: true diff --git a/prebuilt/nspanel_esphome_prebuilt.yaml b/prebuilt/nspanel_esphome_prebuilt.yaml index b59bceb..5f817c8 100644 --- a/prebuilt/nspanel_esphome_prebuilt.yaml +++ b/prebuilt/nspanel_esphome_prebuilt.yaml @@ -24,7 +24,7 @@ external_components: packages: core_package: !include ../esphome/nspanel_esphome_core.yaml - upload_tft_package: !include ../esphome/nspanel_esphome_addon_upload_tft.yaml + #upload_tft_package: !include ../esphome/nspanel_esphome_addon_upload_tft.yaml api: services: @@ -93,18 +93,18 @@ script: static const char *const TAG = "prebuilt.script.watchdog"; ESP_LOGI(TAG, "Pre-built version: ${pre_built}"); -select: - - id: !extend tft_file_model - platform: template - options: - - "NSPanel Blank" - - "NSPanel EU" - - "NSPanel US" - - "NSPanel US Landscape" - - "NSPanel EU (CJK languages)" - - "NSPanel US (CJK languages)" - - "NSPanel US Landscape (CJK languages)" - initial_option: "NSPanel Blank" +#select: +# - id: !extend tft_file_model +# platform: template +# options: +# - "NSPanel Blank" +# - "NSPanel EU" +# - "NSPanel US" +# - "NSPanel US Landscape" +# - "NSPanel EU (CJK languages)" +# - "NSPanel US (CJK languages)" +# - "NSPanel US Landscape (CJK languages)" +# initial_option: "NSPanel Blank" text_sensor: - id: firmware_url @@ -114,11 +114,10 @@ text_sensor: internal: true icon: mdi:cloud-download -web_server: - id: web_server_std - auth: !remove +web_server: !remove wifi: + networks: !remove ap: {} power_save_mode: LIGHT # To make it compatible with BLE ...