diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 37d9d70..8cbe64d 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -46,7 +46,7 @@ Since in this update lots of input to the blueprint changed, we highly recommend - SSID - BSSID - You can still add these components by adding the file `nspanel_esphome_advanced.yaml` in your ESPHome settings as in the example bellow, but please have in mind that these are not used by the blueprint and will be using some memory of your ESPHome. + You can still add these components (except by "Exit reparse") by adding the file `nspanel_esphome_advanced.yaml` in your ESPHome settings as in the example bellow, but please have in mind that these are not used by the blueprint and will be using some memory of your ESPHome. ```yaml ... packages: @@ -58,21 +58,28 @@ packages: - nspanel_esphome_advanced.yaml # activate advanced (legacy) elements - can be useful for troubleshooting ... ``` +2. Very long press on hardware buttons +If you have a custom automation using very long hold (more than 15s) of hardware buttons it may fail as now the panel will restart with button hold for 15s.   -## Overview of all changes +## Overview of noteworthy changes 1. New Upload TFT engine -2. +2. Hardware restarts with button hold for 15s   -## Details of all changes +## Details of noteworthy changes ### 1. New Upload TFT engine We rebuilt the Upload TFT engine and now it will be using less resources from ESPHome during the transfer and, in addition, will provide more logs for troubleshooting. The original engine from Nextion component still as a fallback in case the new engine fails, but it might be removed in a future version. -### 2. +### 2. Hardware restarts with button hold for 15s +Now if you press the hardware buttons for more than 15s, the panel will act as the following: +| Button | Action | Details | +| :--: | :--: | :- | +| Left | Power cycle the screen | It can remove the need to power cycle the panel when the screen can't stablish connection to ESPHome (`Nextion is not connected!` on logs). | +| Right | Restarts the panel | It is equivalent to press the "Restart" button on the Settings page or from Home Assistant, but is available even when the Wi-Fi isn't connected or Home Assistant is out. |   ## Next topics we are currently working on diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 05099dc..b2c9250 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -33,7 +33,7 @@ blueprint: 🎉 Roadmap can be found here: [Roadmap](https://github.com/Blackymas/NSPanel_HA_Blueprint/labels/roadmap) - ℹ️ Version: v4.1dev3 + ℹ️ Version: v4.1dev4 source_url: https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/main/nspanel_blueprint.yaml domain: automation @@ -3588,7 +3588,7 @@ trigger_variables: variables: ##### GENERAL ##### - blueprint_version: '4.1dev3' + blueprint_version: '4.1dev4' date_format_temp: !input 'date_format' #Avoid breaking change for existing users with legacy type format date_format: > diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index a5dbff1..b707d73 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -12,7 +12,7 @@ substitutions: ############################################## ##### DON'T CHANGE THIS ##### - version: "4.1dev3" + version: "4.1dev4" ############################# ##### ESPHOME CONFIGURATION ##### @@ -32,22 +32,22 @@ esphome: timeout: 60s - wait_until: condition: - - lambda: !lambda return id(disp1).is_setup(); + - lambda: !lambda return disp1->is_setup(); timeout: 20s - script.execute: exit_reparse - wait_until: condition: - - lambda: !lambda return id(disp1).is_setup(); + - lambda: !lambda return disp1->is_setup(); timeout: 20s - lambda: |- static const char *const TAG = "on_boot"; - if (not id(disp1).is_setup()) { + if (not disp1->is_setup()) { ESP_LOGE(TAG, "No response from Nextion display"); ESP_LOGD(TAG, "Turn off Nextion"); - id(screen_power).turn_off(); + screen_power->turn_off(); delay(1500); ESP_LOGD(TAG, "Turn on Nextion"); - id(screen_power).turn_on(); + screen_power->turn_on(); } ##### TYPE OF ESP BOARD ##### @@ -139,90 +139,90 @@ api: then: - lambda: |- // set alarm icon on home page - id(disp1).send_command_printf("is_alarm=%i", (state == "" or state.empty()) ? 0 : 1); - id(update_alarm_icon).execute("home.bt_alarm", state.c_str()); + disp1->send_command_printf("is_alarm=%i", (state == "" or state.empty()) ? 0 : 1); + update_alarm_icon->execute("home.bt_alarm", state.c_str()); // Is page Alarm visible? - if (id(current_page).state == "alarm") // To do: This page constructor should be moved to Blueprint + if (current_page->state == "alarm") // To do: This page constructor should be moved to Blueprint { // Update alarm page id(entity_id) = entity; // Alarm page - Header - id(update_alarm_icon).execute("icon_state", state.c_str()); - id(disp1).set_component_text_printf("page_label", "%s", page_title.c_str()); - id(disp1).set_component_text_printf("code_format", "%s", code_format.c_str()); - if (code_arm_required) id(disp1).set_component_text_printf("code_arm_req", "1"); else id(disp1).set_component_text_printf("code_arm_req", "0"); + update_alarm_icon->execute("icon_state", state.c_str()); + disp1->set_component_text_printf("page_label", "%s", page_title.c_str()); + disp1->set_component_text_printf("code_format", "%s", code_format.c_str()); + if (code_arm_required) disp1->set_component_text_printf("code_arm_req", "1"); else disp1->set_component_text_printf("code_arm_req", "0"); // Alarm page - Button's icons - id(disp1).set_component_text_printf("bt_home_icon", "\uE689"); //mdi:shield-home - id(disp1).set_component_text_printf("bt_away_icon", "\uE99C"); //mdi:shield-lock - id(disp1).set_component_text_printf("bt_night_icon", "\uF827"); //mdi:shield-moon - id(disp1).set_component_text_printf("bt_vacat_icon", "\uE6BA"); //mdi:shield-airplane - id(disp1).set_component_text_printf("bt_bypass_icon", "\uE77F"); //mdi:shield-half-full - id(disp1).set_component_text_printf("bt_disarm_icon", "\uE99D"); //mdi:shield-off + disp1->set_component_text_printf("bt_home_icon", "\uE689"); //mdi:shield-home + disp1->set_component_text_printf("bt_away_icon", "\uE99C"); //mdi:shield-lock + disp1->set_component_text_printf("bt_night_icon", "\uF827"); //mdi:shield-moon + disp1->set_component_text_printf("bt_vacat_icon", "\uE6BA"); //mdi:shield-airplane + disp1->set_component_text_printf("bt_bypass_icon", "\uE77F"); //mdi:shield-half-full + disp1->set_component_text_printf("bt_disarm_icon", "\uE99D"); //mdi:shield-off // Alarm page - Button's text - id(display_wrapped_text).execute("bt_home_text", mui_alarm[0].c_str(), 10); - id(display_wrapped_text).execute("bt_away_text", mui_alarm[1].c_str(), 10); - id(display_wrapped_text).execute("bt_night_text", mui_alarm[2].c_str(), 10); - id(display_wrapped_text).execute("bt_vacat_text", mui_alarm[3].c_str(), 10); - id(display_wrapped_text).execute("bt_bypass_text", mui_alarm[4].c_str(), 10); - id(display_wrapped_text).execute("bt_disarm_text", mui_alarm[5].c_str(), 10); + display_wrapped_text->execute("bt_home_text", mui_alarm[0].c_str(), 10); + display_wrapped_text->execute("bt_away_text", mui_alarm[1].c_str(), 10); + display_wrapped_text->execute("bt_night_text", mui_alarm[2].c_str(), 10); + display_wrapped_text->execute("bt_vacat_text", mui_alarm[3].c_str(), 10); + display_wrapped_text->execute("bt_bypass_text", mui_alarm[4].c_str(), 10); + display_wrapped_text->execute("bt_disarm_text", mui_alarm[5].c_str(), 10); // Alarm page - Buttons if (supported_features & 1) // Alarm - Button - Home { - id(disp1).send_command_printf("bt_home_pic.pic=%i", (state == "armed_home") ? 43 : 42); - id(disp1).set_component_background_color("bt_home_text", (state == "armed_home") ? 19818 : 52857); - id(disp1).set_component_background_color("bt_home_icon", (state == "armed_home") ? 19818 : 52857); - id(disp1).set_component_font_color("bt_home_text", (state == "armed_home") ? 65535 : 0); - id(disp1).set_component_font_color("bt_home_icon", (state == "armed_home") ? 65535 : 0); - if (state == "armed_home") id(disp1).hide_component("bt_home"); else id(disp1).show_component("bt_home"); + disp1->send_command_printf("bt_home_pic.pic=%i", (state == "armed_home") ? 43 : 42); + disp1->set_component_background_color("bt_home_text", (state == "armed_home") ? 19818 : 52857); + disp1->set_component_background_color("bt_home_icon", (state == "armed_home") ? 19818 : 52857); + disp1->set_component_font_color("bt_home_text", (state == "armed_home") ? 65535 : 0); + disp1->set_component_font_color("bt_home_icon", (state == "armed_home") ? 65535 : 0); + if (state == "armed_home") disp1->hide_component("bt_home"); else disp1->show_component("bt_home"); } if (supported_features & 2) // Alarm - Button - Away { - id(disp1).send_command_printf("bt_away_pic.pic=%i", (state == "armed_away") ? 43 : 42); - id(disp1).set_component_background_color("bt_away_text", (state == "armed_away") ? 19818 : 52857); - id(disp1).set_component_background_color("bt_away_icon", (state == "armed_away") ? 19818 : 52857); - id(disp1).set_component_font_color("bt_away_text", (state == "armed_away") ? 65535 : 0); - id(disp1).set_component_font_color("bt_away_icon", (state == "armed_away") ? 65535 : 0); - if (state == "armed_away") id(disp1).hide_component("bt_away"); else id(disp1).show_component("bt_away"); + disp1->send_command_printf("bt_away_pic.pic=%i", (state == "armed_away") ? 43 : 42); + disp1->set_component_background_color("bt_away_text", (state == "armed_away") ? 19818 : 52857); + disp1->set_component_background_color("bt_away_icon", (state == "armed_away") ? 19818 : 52857); + disp1->set_component_font_color("bt_away_text", (state == "armed_away") ? 65535 : 0); + disp1->set_component_font_color("bt_away_icon", (state == "armed_away") ? 65535 : 0); + if (state == "armed_away") disp1->hide_component("bt_away"); else disp1->show_component("bt_away"); } if (supported_features & 4) // Alarm - Button - Night { - id(disp1).send_command_printf("bt_night_pic.pic=%i", (state == "armed_night") ? 43 : 42); - id(disp1).set_component_background_color("bt_night_text", (state == "armed_night") ? 19818 : 52857); - id(disp1).set_component_background_color("bt_night_icon", (state == "armed_night") ? 19818 : 52857); - id(disp1).set_component_font_color("bt_night_text", (state == "armed_night") ? 65535 : 0); - id(disp1).set_component_font_color("bt_night_icon", (state == "armed_night") ? 65535 : 0); - if (state == "armed_night") id(disp1).hide_component("bt_night"); else id(disp1).show_component("bt_night"); + disp1->send_command_printf("bt_night_pic.pic=%i", (state == "armed_night") ? 43 : 42); + disp1->set_component_background_color("bt_night_text", (state == "armed_night") ? 19818 : 52857); + disp1->set_component_background_color("bt_night_icon", (state == "armed_night") ? 19818 : 52857); + disp1->set_component_font_color("bt_night_text", (state == "armed_night") ? 65535 : 0); + disp1->set_component_font_color("bt_night_icon", (state == "armed_night") ? 65535 : 0); + if (state == "armed_night") disp1->hide_component("bt_night"); else disp1->show_component("bt_night"); } if (supported_features & 32) // Alarm - Button - Vacation { - id(disp1).send_command_printf("bt_vacat_pic.pic=%i", (state == "armed_vacation") ? 43 : 42); - id(disp1).set_component_background_color("bt_vacat_text", (state == "armed_vacation") ? 19818 : 52857); - id(disp1).set_component_background_color("bt_vacat_icon", (state == "armed_vacation") ? 19818 : 52857); - id(disp1).set_component_font_color("bt_vacat_text", (state == "armed_vacation") ? 65535 : 0); - id(disp1).set_component_font_color("bt_vacat_icon", (state == "armed_vacation") ? 65535 : 0); - if (state == "armed_vacation") id(disp1).hide_component("bt_vacat"); else id(disp1).show_component("bt_vacat"); + disp1->send_command_printf("bt_vacat_pic.pic=%i", (state == "armed_vacation") ? 43 : 42); + disp1->set_component_background_color("bt_vacat_text", (state == "armed_vacation") ? 19818 : 52857); + disp1->set_component_background_color("bt_vacat_icon", (state == "armed_vacation") ? 19818 : 52857); + disp1->set_component_font_color("bt_vacat_text", (state == "armed_vacation") ? 65535 : 0); + disp1->set_component_font_color("bt_vacat_icon", (state == "armed_vacation") ? 65535 : 0); + if (state == "armed_vacation") disp1->hide_component("bt_vacat"); else disp1->show_component("bt_vacat"); } if (supported_features & 16) // Alarm - Button - Custom bypass { - id(disp1).send_command_printf("bt_bypass_pic.pic=%i", (state == "armed_bypass") ? 43 : 42); - id(disp1).set_component_background_color("bt_bypass_text", (state == "armed_bypass") ? 19818 : 52857); - id(disp1).set_component_background_color("bt_bypass_icon", (state == "armed_bypass") ? 19818 : 52857); - id(disp1).set_component_font_color("bt_bypass_text", (state == "armed_bypass") ? 65535 : 0); - id(disp1).set_component_font_color("bt_bypass_icon", (state == "armed_bypass") ? 65535 : 0); - if (state == "armed_bypass") id(disp1).hide_component("bt_bypass"); else id(disp1).show_component("bt_bypass"); + disp1->send_command_printf("bt_bypass_pic.pic=%i", (state == "armed_bypass") ? 43 : 42); + disp1->set_component_background_color("bt_bypass_text", (state == "armed_bypass") ? 19818 : 52857); + disp1->set_component_background_color("bt_bypass_icon", (state == "armed_bypass") ? 19818 : 52857); + disp1->set_component_font_color("bt_bypass_text", (state == "armed_bypass") ? 65535 : 0); + disp1->set_component_font_color("bt_bypass_icon", (state == "armed_bypass") ? 65535 : 0); + if (state == "armed_bypass") disp1->hide_component("bt_bypass"); else disp1->show_component("bt_bypass"); } if ( true ) // Alarm - Button - Disarm { - id(disp1).send_command_printf("bt_disarm_pic.pic=%i", (state == "disarmed") ? 43 : 42); - id(disp1).set_component_background_color("bt_disarm_text", (state == "disarmed") ? 19818 : 52857); - id(disp1).set_component_background_color("bt_disarm_icon", (state == "disarmed") ? 19818 : 52857); - id(disp1).set_component_font_color("bt_disarm_text", (state == "disarmed") ? 65535 : 0); - id(disp1).set_component_font_color("bt_disarm_icon", (state == "disarmed") ? 65535 : 0); - if (state == "disarmed") id(disp1).hide_component("bt_disarm"); else id(disp1).show_component("bt_disarm"); + disp1->send_command_printf("bt_disarm_pic.pic=%i", (state == "disarmed") ? 43 : 42); + disp1->set_component_background_color("bt_disarm_text", (state == "disarmed") ? 19818 : 52857); + disp1->set_component_background_color("bt_disarm_icon", (state == "disarmed") ? 19818 : 52857); + disp1->set_component_font_color("bt_disarm_text", (state == "disarmed") ? 65535 : 0); + disp1->set_component_font_color("bt_disarm_icon", (state == "disarmed") ? 65535 : 0); + if (state == "disarmed") disp1->hide_component("bt_disarm"); else disp1->show_component("bt_disarm"); } } @@ -251,12 +251,12 @@ api: // Blueprint version ESP_LOGV("service.global_settings", "Check Blueprint version"); id(version_blueprint) = blueprint_version; - id(check_versions).execute(); + check_versions->execute(); // Relays ESP_LOGV("service.global_settings", "Setup relays"); - id(relay1_local).publish_state(relay1_local_control); - id(relay2_local).publish_state(relay2_local_control); + relay1_local->publish_state(relay1_local_control); + relay2_local->publish_state(relay2_local_control); id(home_relay1_icon) = relay1_icon.c_str(); id(home_relay2_icon) = relay2_icon.c_str(); id(home_relay1_icon_color) = relay1_icon_color; @@ -276,30 +276,30 @@ api: // Embedded thermostat ESP_LOGV("service.global_settings", "Load embedded thermostat"); id(is_embedded_thermostat) = embedded_climate; - id(addon_climate_set_climate_friendly_name).execute(embedded_climate_friendly_name.c_str()); + addon_climate_set_climate_friendly_name->execute(embedded_climate_friendly_name.c_str()); // Indoor temperature ESP_LOGV("service.global_settings", "Set indoor temperature"); id(embedded_indoor_temp) = embedded_indoor_temperature; id(temp_unit_fahrenheit) = temperature_unit_is_fahrenheit; - id(display_embedded_temp).execute(); + display_embedded_temp->execute(); // Confirm page ESP_LOGV("service.global_settings", "Setup confirm page"); - id(display_wrapped_text).execute("confirm.title", mui_please_confirm.c_str(), 15); + display_wrapped_text->execute("confirm.title", mui_please_confirm.c_str(), 15); // Refresh colors of global components ESP_LOGV("service.global_settings", "Refresh color of global components"); - id(disp1).set_component_font_color("home.date", id(home_date_color)); - id(disp1).set_component_font_color("home.time", id(home_time_color)); - id(disp1).set_component_font_color("home.icon_top_01", id(home_relay1_icon_color)); - id(disp1).set_component_font_color("home.icon_top_02", id(home_relay2_icon_color)); + disp1->set_component_font_color("home.date", id(home_date_color)); + disp1->set_component_font_color("home.time", id(home_time_color)); + 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)); // Update home page ESP_LOGV("service.global_settings", "Update home page"); - id(page_home).execute(false); + page_home->execute(false); - ESP_LOGV("service.global_settings", "Current page: %s", id(current_page).state.c_str()); + ESP_LOGV("service.global_settings", "Current page: %s", current_page->state.c_str()); - if: condition: @@ -309,7 +309,7 @@ api: then: - lambda: |- ESP_LOGV("service.global_settings", "Boot page is visible"); - id(disp1).set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str()); + disp1->set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str()); - wait_until: condition: - not: @@ -332,16 +332,16 @@ api: - rtttl.play: rtttl: 'two short:d=4,o=5,b=100:16e6,16e6' - lambda: |- - ESP_LOGD("service.global_settings", "Jump to wake-up page: %s", id(wakeup_page_name).state.c_str()); - id(disp1).goto_page(id(wakeup_page_name).state.c_str()); - id(timer_reset_all).execute(id(wakeup_page_name).state.c_str()); + ESP_LOGD("service.global_settings", "Jump to wake-up page: %s", wakeup_page_name->state.c_str()); + disp1->goto_page(wakeup_page_name->state.c_str()); + timer_reset_all->execute(wakeup_page_name->state.c_str()); ##### Service to send a command "printf" directly to the display ##### - service: send_command_printf variables: cmd: string then: - - lambda: 'id(disp1).send_command_printf("%s", cmd.c_str());' + - lambda: 'disp1->send_command_printf("%s", cmd.c_str());' ##### Service to send a command "text_printf" directly to the display ##### - service: send_command_text_printf @@ -349,7 +349,7 @@ api: component: string message: string then: - - lambda: 'id(disp1).set_component_text_printf(component.c_str(), "%s", message.c_str());' + - lambda: 'disp1->set_component_text_printf(component.c_str(), "%s", message.c_str());' ##### Service to send a command "component_value (Dualstate Button)" directly to the display ##### - service: send_command_value @@ -357,26 +357,26 @@ api: component: string message: int then: - - lambda: 'id(disp1).set_component_value(component.c_str(), message);' + - lambda: 'disp1->set_component_value(component.c_str(), message);' ##### Service to send a command "hide componente" directly to the display ##### - service: send_command_hide ### unused ### variables: component: string then: - - lambda: 'id(disp1).hide_component(component.c_str());' + - lambda: 'disp1->hide_component(component.c_str());' ##### Service to send a command "show componente" directly to the display ##### - service: send_command_show ### unused ### variables: component: string then: - - lambda: 'id(disp1).show_component(component.c_str());' + - lambda: 'disp1->show_component(component.c_str());' ##### Service to send a command "show ALL componente" directly to the display ##### - service: send_command_show_all ### unused ### then: - - lambda: id(disp1).show_component("255"); + - lambda: disp1->show_component("255"); ##### Service to send a command "font color" directly to the display ##### - service: set_component_color @@ -385,7 +385,7 @@ api: foreground: int[] background: int[] then: - - lambda: id(set_component_color).execute(component, foreground, background); + - lambda: set_component_color->execute(component, foreground, background); ##### Service to show a notification-message on the screen ##### - service: notification_show @@ -396,29 +396,23 @@ api: - lambda: |- ESP_LOGV("service.notification_show", "Starting"); - id(disp1).send_command_printf("is_notification=1"); - id(disp1).goto_page("notification"); - id(disp1).set_component_text_printf("notification.notifi_label", "%s", label.c_str()); + disp1->send_command_printf("is_notification=1"); + disp1->goto_page("notification"); + disp1->set_component_text_printf("notification.notifi_label", "%s", label.c_str()); - id(display_wrapped_text).execute("notification.notifi_text01", text.c_str(), id(display_mode) == 2 ? 23 : 32); + display_wrapped_text->execute("notification.notifi_text01", text.c_str(), id(display_mode) == 2 ? 23 : 32); - id(notification_label).publish_state(label.c_str()); - id(notification_text).publish_state(text.c_str()); - id(timer_reset_all).execute(id(current_page).state.c_str()); - id(notification_unread).turn_on(); - if (id(notification_sound).state) id(buzzer).play("two short:d=4,o=5,b=100:16e6,16e6"); + notification_label->publish_state(label.c_str()); + notification_text->publish_state(text.c_str()); + timer_reset_all->execute(current_page->state.c_str()); + notification_unread->turn_on(); + if (notification_sound->state) buzzer->play("two short:d=4,o=5,b=100:16e6,16e6"); ##### Service to clear the notification ##### - service: notification_clear then: - logger.log: "Service: notification_clear" - - ¬ification_clear - lambda: |- - id(disp1).send_command_printf("is_notification=0"); - if (id(current_page).state == "home") id(disp1).hide_component("bt_notific"); - id(notification_label).publish_state(""); - id(notification_text).publish_state(""); - id(notification_unread).turn_off(); + - script.execute: notification_clear ##### Service to open information for settings-page(s) - service: open_entity_settings_page @@ -433,19 +427,19 @@ api: - lambda: |- id(entity_id) = entity; std::string cmd_page = std::string("page ") + page.c_str(); - id(disp1).send_command_printf(cmd_page.c_str()); - id(disp1).set_component_text_printf("page_label", "%s", page_label.c_str()); - id(disp1).set_component_text_printf("back_page", "%s", back_page.c_str()); + disp1->send_command_printf(cmd_page.c_str()); + disp1->set_component_text_printf("page_label", "%s", page_label.c_str()); + disp1->set_component_text_printf("back_page", "%s", back_page.c_str()); if (page == "climate") { - if (entity == "embedded_climate") id(addon_climate_set_climate_friendly_name).execute(page_label.c_str()); - id(disp1).set_component_value("embedded", (entity == "embedded_climate") ? 1 : 0); + if (entity == "embedded_climate") addon_climate_set_climate_friendly_name->execute(page_label.c_str()); + disp1->set_component_value("embedded", (entity == "embedded_climate") ? 1 : 0); } else { if ((page_icon != std::string()) and (page_icon != "")) - id(disp1).set_component_text_printf("icon_state", "%s", page_icon.c_str()); - id(set_component_color).execute("icon_state", page_icon_color, {}); + disp1->set_component_text_printf("icon_state", "%s", page_icon.c_str()); + set_component_color->execute("icon_state", page_icon_color, {}); } # Service to show a QR code on the display (ex. for WiFi password) @@ -456,9 +450,9 @@ api: show: bool then: - lambda: |- - id(disp1).set_component_text_printf("qrcode.qrcode_label", "%s", title.c_str()); - id(disp1).set_component_text_printf("qrcode.qrcode_value", "%s", qrcode.c_str()); - if (show) id(disp1).goto_page("qrcode"); + 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"); #### Service to set climate state #### - service: set_climate @@ -473,7 +467,7 @@ api: entity: string then: - lambda: |- - if (id(current_page).state == "climate") id(entity_id) = entity; + if (current_page->state == "climate") id(entity_id) = entity; - script.execute: id: set_climate @@ -502,16 +496,16 @@ api: std::string btnicon = btn_id.c_str() + std::string("icon"); std::string btntext = btn_id.c_str() + std::string("text"); std::string btnbri = btn_id.c_str() + std::string("bri"); - id(disp1).send_command_printf("%spic.pic=%i", btn_id.c_str(), btn_pic); - id(set_component_color).execute(btnicon.c_str(), btn_icon_font, btn_bg); - id(set_component_color).execute(btntext.c_str(), btn_txt_font, btn_bg); - id(set_component_color).execute(btnbri.c_str(), btn_bri_font, btn_bg); - id(disp1).set_component_text_printf(btnicon.c_str(), "%s", btn_icon.c_str()); - id(display_wrapped_text).execute(btntext.c_str(), btn_label.c_str(), 10); + disp1->send_command_printf("%spic.pic=%i", btn_id.c_str(), btn_pic); + set_component_color->execute(btnicon.c_str(), btn_icon_font, btn_bg); + set_component_color->execute(btntext.c_str(), btn_txt_font, btn_bg); + set_component_color->execute(btnbri.c_str(), btn_bri_font, btn_bg); + disp1->set_component_text_printf(btnicon.c_str(), "%s", btn_icon.c_str()); + display_wrapped_text->execute(btntext.c_str(), btn_label.c_str(), 10); if (strcmp(btn_bri_txt.c_str(), "0") != 0) - id(disp1).set_component_text_printf(btnbri.c_str(), "%s", btn_bri_txt.c_str()); + disp1->set_component_text_printf(btnbri.c_str(), "%s", btn_bri_txt.c_str()); else - id(disp1).set_component_text_printf(btnbri.c_str(), " "); + disp1->set_component_text_printf(btnbri.c_str(), " "); ##### SERVICE TO WAKE UP THE DISPLAY ##### - service: wake_up @@ -519,12 +513,12 @@ api: reset_timer: bool then: - lambda: |- - if (id(current_page).state == "screensaver") id(disp1).goto_page(id(wakeup_page_name).state.c_str()); + if (current_page->state == "screensaver") disp1->goto_page(wakeup_page_name->state.c_str()); if (reset_timer) - id(timer_reset_all).execute(id(wakeup_page_name).state.c_str()); + timer_reset_all->execute(wakeup_page_name->state.c_str()); else { - id(timer_sleep).execute(id(wakeup_page_name).state.c_str(), int(id(timeout_sleep).state)); - id(timer_dim).execute(id(wakeup_page_name).state.c_str(), int(id(timeout_dim).state)); + timer_sleep->execute(wakeup_page_name->state.c_str(), int(timeout_sleep->state)); + timer_dim->execute(wakeup_page_name->state.c_str(), int(timeout_dim->state)); } #### Service to set the entities #### @@ -540,11 +534,11 @@ api: std::string enticon = ent_id.c_str() + std::string("_pic"); std::string entlabel = ent_id.c_str() + std::string("_label"); std::string entxcen = ent_id.c_str() + std::string(".xcen=") + ent_value_xcen.c_str(); - id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str()); - if (strcmp(ent_icon.c_str(), "0") != 0) id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str()); - id(disp1).set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str()); - id(disp1).set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str()); - if (strcmp(ent_value_xcen.c_str(), "0") != 0) id(disp1).send_command_printf("%s", entxcen.c_str()); + disp1->set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str()); + if (strcmp(ent_icon.c_str(), "0") != 0) disp1->set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str()); + disp1->set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str()); + disp1->set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str()); + if (strcmp(ent_value_xcen.c_str(), "0") != 0) disp1->send_command_printf("%s", entxcen.c_str()); #### Service to populate the page Home ##### - service: page_home @@ -562,25 +556,25 @@ api: then: - lambda: |- // Notification button - id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1); - id(disp1).set_component_text_printf("home.bt_notific", "%s", notification_icon.c_str()); - id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? notification_icon_color_unread : notification_icon_color_normal, {}); + 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; // QRCode button - id(disp1).send_command_printf("is_qrcode=%i", (qrcode) ? 1 : 0); - id(disp1).set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str()); - id(set_component_color).execute("home.bt_qrcode", qrcode_icon_color, {}); + 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, {}); // Entities pages button - id(disp1).send_command_printf("is_entities=%i", (entities_pages) ? 1 : 0); - id(disp1).set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str()); - id(set_component_color).execute("home.bt_entities", entities_pages_icon_color, {}); + 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, {}); // Alarm button - id(disp1).send_command_printf("is_alarm=%i", (alarm_state == "" or alarm_state.empty()) ? 0 : 1); - id(update_alarm_icon).execute("home.bt_alarm", alarm_state.c_str()); + disp1->send_command_printf("is_alarm=%i", (alarm_state == "" or alarm_state.empty()) ? 0 : 1); + update_alarm_icon->execute("home.bt_alarm", alarm_state.c_str()); #### Service to populate the page Settings ##### - service: page_settings @@ -592,10 +586,10 @@ api: dim: string then: - lambda: |- - if (not reboot.empty()) id(disp1).set_component_text_printf("settings.lbl_reboot", " %s", reboot.c_str()); - id(disp1).set_component_text_printf("settings.lbl_brightness", " %s", brightness.c_str()); - id(display_wrapped_text).execute("settings.lbl_bright", bright.c_str(), id(display_mode) == 2 ? 25 : 10); - id(display_wrapped_text).execute("settings.lbl_dim", dim.c_str(), id(display_mode) == 2 ? 25 : 10); + if (not reboot.empty()) disp1->set_component_text_printf("settings.lbl_reboot", " %s", reboot.c_str()); + disp1->set_component_text_printf("settings.lbl_brightness", " %s", brightness.c_str()); + display_wrapped_text->execute("settings.lbl_bright", bright.c_str(), id(display_mode) == 2 ? 25 : 10); + display_wrapped_text->execute("settings.lbl_dim", dim.c_str(), id(display_mode) == 2 ? 25 : 10); #### Service to populate the media player page ##### - service: media_player @@ -613,60 +607,60 @@ api: supported_features: int then: - lambda: |- - if (id(current_page).state == "media_player") + if (current_page->state == "media_player") { id(entity_id) = entity; - id(disp1).set_component_text_printf("page_label", "%s", friendly_name.c_str()); - id(display_wrapped_text).execute("track", media_title.c_str(), id(display_mode) == 2 ? 16 : 27); - id(display_wrapped_text).execute("artist", media_artist.c_str(), id(display_mode) == 2 ? 26 : 40); + disp1->set_component_text_printf("page_label", "%s", friendly_name.c_str()); + display_wrapped_text->execute("track", media_title.c_str(), id(display_mode) == 2 ? 16 : 27); + display_wrapped_text->execute("artist", media_artist.c_str(), id(display_mode) == 2 ? 26 : 40); // on/off button if (supported_features & 128 and state == "off") //TURN_ON { - id(set_component_color).execute("bt_on_off", { 65535 }, {} ); - id(disp1).show_component("bt_on_off"); + set_component_color->execute("bt_on_off", { 65535 }, {} ); + disp1->show_component("bt_on_off"); } else if (supported_features & 256 and state != "off") //TURN_OFF { - id(set_component_color).execute("bt_on_off", { 10597 }, {} ); - id(disp1).show_component("bt_on_off"); + set_component_color->execute("bt_on_off", { 10597 }, {} ); + disp1->show_component("bt_on_off"); } - else id(disp1).hide_component("bt_on_off"); + else disp1->hide_component("bt_on_off"); // play/pause button if ((supported_features & 512 or supported_features & 16384) and state != "playing" and state != "off") //PLAY_MEDIA+PLAY { - id(disp1).set_component_text_printf("bt_play_pause", "%s", "\uE409"); // mdi:play - id(disp1).show_component("bt_play_pause"); + disp1->set_component_text_printf("bt_play_pause", "%s", "\uE409"); // mdi:play + disp1->show_component("bt_play_pause"); } else if (supported_features & 1 and state == "playing" ) //PAUSE { - id(disp1).set_component_text_printf("bt_play_pause", "%s", "\uE3E3"); // mdi:pause - id(disp1).show_component("bt_play_pause"); + disp1->set_component_text_printf("bt_play_pause", "%s", "\uE3E3"); // mdi:pause + disp1->show_component("bt_play_pause"); } - else id(disp1).hide_component("bt_play_pause"); + else disp1->hide_component("bt_play_pause"); // bt_prev button - PREVIOUS_TRACK - if (supported_features & 16 and state != "off") id(disp1).show_component("bt_prev"); else id(disp1).hide_component("bt_prev"); + if (supported_features & 16 and state != "off") disp1->show_component("bt_prev"); else disp1->hide_component("bt_prev"); // bt_next button - NEXT_TRACK - if (supported_features & 32 and state != "off") id(disp1).show_component("bt_next"); else id(disp1).hide_component("bt_next"); + if (supported_features & 32 and state != "off") disp1->show_component("bt_next"); else disp1->hide_component("bt_next"); // Stop button - STOP - //if (supported_features & 4096 and (state == "playing" or state == "paused")) id(disp1).show_component("bt_stop"); else id(disp1).hide_component("bt_stop"); + //if (supported_features & 4096 and (state == "playing" or state == "paused")) disp1->show_component("bt_stop"); else disp1->hide_component("bt_stop"); // mute/unmute button - VOLUME_MUTE - id(disp1).set_component_value("is_muted", (is_volume_muted) ? 1 : 0); + disp1->set_component_value("is_muted", (is_volume_muted) ? 1 : 0); if (supported_features & 8 and is_volume_muted) // unmute { - id(disp1).set_component_text_printf("bt_mute", "%s", "\uEE07"); // mdi:volume-variant-off - id(disp1).show_component("bt_mute"); + disp1->set_component_text_printf("bt_mute", "%s", "\uEE07"); // mdi:volume-variant-off + disp1->show_component("bt_mute"); } else if (supported_features & 8) // mute { - id(disp1).set_component_text_printf("bt_mute", "%s", "\uE57E"); // mdi:volume-low - id(disp1).show_component("bt_mute"); + disp1->set_component_text_printf("bt_mute", "%s", "\uE57E"); // mdi:volume-low + disp1->show_component("bt_mute"); } - else id(disp1).hide_component("bt_mute"); + else disp1->hide_component("bt_mute"); // VOLUME_SET if (supported_features & 4) @@ -674,20 +668,20 @@ api: if (volume_level != id(last_volume_level)) { id(last_volume_level) = volume_level; - id(disp1).set_component_text_printf("vol_text", "%i%%", volume_level); - id(disp1).set_component_value("vol_slider", volume_level); + disp1->set_component_text_printf("vol_text", "%i%%", volume_level); + disp1->set_component_value("vol_slider", volume_level); } - id(disp1).show_component("vol_slider"); - id(disp1).show_component("bt_vol_down"); - id(disp1).show_component("bt_vol_up"); - id(disp1).show_component("vol_text"); + disp1->show_component("vol_slider"); + disp1->show_component("bt_vol_down"); + disp1->show_component("bt_vol_up"); + disp1->show_component("vol_text"); } else { - id(disp1).hide_component("vol_slider"); - id(disp1).hide_component("bt_vol_down"); - id(disp1).hide_component("bt_vol_up"); - id(disp1).hide_component("vol_text"); + disp1->hide_component("vol_slider"); + disp1->hide_component("bt_vol_down"); + disp1->hide_component("bt_vol_up"); + disp1->hide_component("vol_text"); } if (media_duration > 0) @@ -696,20 +690,20 @@ api: { id(last_media_duration) = media_duration; id(last_media_position) = media_position; - id(disp1).set_component_value("prg_current", int(round(min(media_position + media_position_delta, media_duration)))); + disp1->set_component_value("prg_current", int(round(min(media_position + media_position_delta, media_duration)))); } - id(disp1).set_component_value("prg_total", int(round(media_duration))); - id(disp1).send_command_printf("prg_timer.en=%i", (state == "playing") ? 1 : 0); - id(disp1).show_component("time_current"); - id(disp1).show_component("time_total"); - id(disp1).show_component("time_progress"); + disp1->set_component_value("prg_total", int(round(media_duration))); + disp1->send_command_printf("prg_timer.en=%i", (state == "playing") ? 1 : 0); + disp1->show_component("time_current"); + disp1->show_component("time_total"); + disp1->show_component("time_progress"); } else { - id(disp1).send_command_printf("prg_timer.en=0"); - id(disp1).hide_component("time_current"); - id(disp1).hide_component("time_total"); - id(disp1).hide_component("time_progress"); + disp1->send_command_printf("prg_timer.en=0"); + disp1->hide_component("time_current"); + disp1->hide_component("time_total"); + disp1->hide_component("time_progress"); } } @@ -718,57 +712,12 @@ display: - id: disp1 platform: nextion uart_id: tf_uart - #tft_url: ${nextion_update_url} # Should come back when esp-idf Nextion is available on_page: # I couldn't make this trigger to work, so used text_sensor nspanelevent and localevent instead lambda: |- ESP_LOGW("display.disp1.on_page", "NEXTION PAGE CHANGED"); ESP_LOGW("display.disp1.on_page", "New page: %i", int(x)); on_setup: - then: - - lambda: |- - ESP_LOGV("display.disp1.on_setup", "Nextion starting"); - if (id(current_page).state != "boot") id(disp1).goto_page("boot"); - id(set_brightness).execute(100); - id(disp1).send_command_printf("bkcmd=3"); - id(disp1).set_component_text_printf("boot.esph_version", "%s", "${version}"); // ### esphome-version ### - id(disp1).show_component("bt_reboot"); - id(timer_reset_all).execute("boot"); - ESP_LOGV("display.disp1.on_setup", "Wait for API"); - - wait_until: - api.connected - - lambda: |- - ESP_LOGV("display.disp1.on_setup", "Publish IP address"); - id(disp1).set_component_text_printf("boot.ip_addr", "%s", network::get_ip_address().str().c_str()); - id(set_brightness).execute(100); - ESP_LOGV("display.disp1.on_setup", "Report to Home Assistant"); - auto ha_event = new esphome::api::CustomAPIDevice(); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", - { - {"type", "boot"}, - {"step", "start"} - }); - delay(1000); - // Set dimming values - id(display_brightness).publish_state(id(display_brightness_global)); - id(display_dim_brightness).publish_state(id(display_dim_brightness_global)); - id(disp1).send_command_printf("brightness=%i", id(display_brightness_global)); - id(disp1).send_command_printf("settings.brightslider.val=%i", id(display_brightness_global)); - id(disp1).send_command_printf("brightness_dim=%i", id(display_dim_brightness_global)); - id(disp1).send_command_printf("settings.dimslider.val=%i", id(display_dim_brightness_global)); - id(set_brightness).execute(id(display_brightness_global)); - id(nextion_init).publish_state(true); - ESP_LOGV("display.disp1.on_setup", "Report to Home Assistant"); - //auto ha_event = new esphome::api::CustomAPIDevice(); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", - { - {"type", "boot"}, - {"step", "nextion_init"} - }); - id(home_relay1_icon) = "\uE3A5"; - id(home_relay1_icon) = "\uE3A8"; - id(timer_reset_all).execute("boot"); - - *notification_clear - - logger.log: "Nextion start - Done!" + - script.execute: boot_sequence ##### START - GLOBALS CONFIGURATION ##### globals: @@ -920,7 +869,7 @@ binary_sensor: - logger.log: "Left button - Long click" - script.execute: id: ha_button - page: !lambda return id(current_page).state.c_str(); + page: !lambda return current_page->state.c_str(); component: "hw_bt_left" command: "long_click" - timing: &short_click-timing @@ -942,9 +891,19 @@ binary_sensor: - switch.toggle: relay_1 - script.execute: id: ha_button - page: !lambda return id(current_page).state.c_str(); + page: !lambda return current_page->state.c_str(); component: "hw_bt_left" command: "short_click" + - timing: &hold_to_restart-timing + - ON for at least 15.0s + then: + - switch.turn_off: screen_power + - delay: 5s + - switch.turn_on: screen_power + - delay: 2s + - lambda: disp1->soft_reset(); + - delay: 2s + - script.execute: boot_sequence ##### RIGHT BUTTON BELOW DISPLAY TO TOGGLE RELAY ##### - name: ${device_name} Right Button @@ -959,7 +918,7 @@ binary_sensor: - logger.log: "Right button - Long click" - script.execute: id: ha_button - page: !lambda return id(current_page).state.c_str(); + page: !lambda return current_page->state.c_str(); component: "hw_bt_right" command: "long_click" - timing: *short_click-timing @@ -980,9 +939,12 @@ binary_sensor: - switch.toggle: relay_2 - script.execute: id: ha_button - page: !lambda return id(current_page).state.c_str(); + page: !lambda return current_page->state.c_str(); component: "hw_bt_right" command: "short_click" + - timing: *hold_to_restart-timing + then: #Restart the panel + - button.press: restart_nspanel ##### Restart NSPanel Button - Setting Page ##### - name: ${device_name} Restart @@ -1044,14 +1006,14 @@ number: then: - lambda: |- id(display_brightness_global) = int(x); - id(disp1).send_command_printf("brightness=%i", int(x)); - id(disp1).send_command_printf("settings.brightslider.val=%i", int(x)); - if (id(current_page).state != "screensaver") + disp1->send_command_printf("brightness=%i", int(x)); + disp1->send_command_printf("settings.brightslider.val=%i", int(x)); + if (current_page->state != "screensaver") { - id(disp1).set_backlight_brightness(x/100); - id(timer_dim).execute(id(current_page).state.c_str(), int(id(timeout_dim).state)); - id(timer_sleep).execute(id(current_page).state.c_str(), int(id(timeout_sleep).state)); - if (id(current_page).state == "settings") id(disp1).set_component_text_printf("bright_text", "%i%%", int(x)); + disp1->set_backlight_brightness(x/100); + timer_dim->execute(current_page->state.c_str(), int(timeout_dim->state)); + timer_sleep->execute(current_page->state.c_str(), int(timeout_sleep->state)); + if (current_page->state == "settings") disp1->set_component_text_printf("bright_text", "%i%%", int(x)); } ##### SCREEN BRIGHTNESS DIMMED DOWN ##### @@ -1069,13 +1031,13 @@ number: then: - lambda: |- id(display_dim_brightness_global) = int(x); - id(disp1).send_command_printf("brightness_dim=%i", int(x)); - id(disp1).send_command_printf("settings.dimslider.val=%i", int(x)); - if (id(current_page).state != "screensaver" and (id(display_last_brightness) <= id(display_dim_brightness_global))) + 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 (id(display_last_brightness) <= id(display_dim_brightness_global))) { - id(set_brightness).execute(x); - id(timer_sleep).execute(id(current_page).state.c_str(), int(id(timeout_sleep).state)); - if (id(current_page).state == "settings") id(disp1).set_component_text_printf("dim_text", "%i%%", int(x)); + set_brightness->execute(x); + timer_sleep->execute(current_page->state.c_str(), int(timeout_sleep->state)); + if (current_page->state == "settings") disp1->set_component_text_printf("dim_text", "%i%%", int(x)); } ##### Temperature Correction ##### @@ -1094,7 +1056,7 @@ number: set_action: - logger.log: Temperature correction changed. - delay: 1s - - lambda: id(temp_nspanel).publish_state(id(temp_nspanel).raw_state); + - lambda: temp_nspanel->publish_state(temp_nspanel->raw_state); ##### Timers settings ##### - name: ${device_name} Timeout Page @@ -1110,7 +1072,7 @@ number: icon: mdi:timer unit_of_measurement: "s" set_action: - - lambda: id(timer_page).execute(id(current_page).state.c_str(), int(x)); + - lambda: timer_page->execute(current_page->state.c_str(), int(x)); - name: ${device_name} Timeout Dimming platform: template id: timeout_dim @@ -1124,7 +1086,7 @@ number: icon: mdi:timer unit_of_measurement: "s" set_action: - - lambda: id(timer_dim).execute(id(current_page).state.c_str(), int(x)); + - lambda: timer_dim->execute(current_page->state.c_str(), int(x)); - name: ${device_name} Timeout Sleep platform: template id: timeout_sleep @@ -1139,8 +1101,8 @@ number: unit_of_measurement: "s" set_action: - lambda: |- - id(timer_dim).execute(id(current_page).state.c_str(), int(id(timeout_dim).state)); - id(timer_sleep).execute(id(current_page).state.c_str(), int(x)); + timer_dim->execute(current_page->state.c_str(), int(timeout_dim->state)); + timer_sleep->execute(current_page->state.c_str(), int(x)); ##### START - SELECT CONFIGURATION ##### select: @@ -1182,7 +1144,7 @@ sensor: on_value: then: - lambda: |- - id(timer_reset_all).execute(id(current_page).state.c_str()); + timer_reset_all->execute(current_page->state.c_str()); ##### INTERNAL TEMPERATURE SENSOR, ADC VALUE ##### - id: ntc_source @@ -1208,11 +1170,11 @@ sensor: reference_temperature: 25°C reference_resistance: 10kOhm filters: - - lambda: return x + id(temperature_correction).state; + - lambda: return x + temperature_correction->state; on_value: then: # Show panel's temperature if API or Wi-Fi are out - - lambda: id(display_embedded_temp).execute(); + - lambda: display_embedded_temp->execute(); ###### Display Brightness GET VALUE FROM NSPanel SLIDER ##### - name: ${device_name} brightness Slider @@ -1226,7 +1188,7 @@ sensor: id: display_brightness value: !lambda 'return int(x);' - lambda: |- - id(timer_reset_all).execute("settings"); + timer_reset_all->execute("settings"); ###### Display DIM Brightness GET VALUE FROM NSPanel SLIDER ##### - name: ${device_name} dim brightness slider @@ -1240,7 +1202,7 @@ sensor: id: display_dim_brightness value: !lambda 'return int(x);' - lambda: |- - id(timer_reset_all).execute("settings"); + timer_reset_all->execute("settings"); ##### START - SWITCH CONFIGURATION ##### switch: @@ -1253,9 +1215,9 @@ switch: optimistic: true restore_mode: ALWAYS_OFF on_turn_on: - - lambda: id(set_component_color).execute("home.bt_notific", id(home_notify_icon_color_unread), {}); + - lambda: set_component_color->execute("home.bt_notific", id(home_notify_icon_color_unread), {}); on_turn_off: - - lambda: id(set_component_color).execute("home.bt_notific", id(home_notify_icon_color_normal), {}); + - lambda: set_component_color->execute("home.bt_notific", id(home_notify_icon_color_normal), {}); ##### Notification sound ##### - name: ${device_name} Notification sound @@ -1355,7 +1317,7 @@ text_sensor: static const char *const TAG = "text_sensor.current_page"; // Construct new page ESP_LOGV(TAG, "Construct new page"); - id(page_changed).execute(x.c_str()); + page_changed->execute(x.c_str()); - name: ${device_name} Notification Label platform: template @@ -1386,7 +1348,7 @@ text_sensor: deserializeJson(doc, x); std::string page = doc["page"]; std::string component = doc["component"]; - if (not (component == "currentpage" and (page == "screensaver" or page == "home"))) id(timer_reset_all).execute(page.c_str()); + if (not (component == "currentpage" and (page == "screensaver" or page == "home"))) timer_reset_all->execute(page.c_str()); std::string value = doc["value"]; std::string entity = id(entity_id); //doc["entity"]; ESP_LOGE(TAG, "page: %s", page.c_str()); @@ -1432,15 +1394,15 @@ text_sensor: // send event to Home Assistant auto ha_event = new esphome::api::CustomAPIDevice(); - if (event == "short_click" or event == "long_click") id(ha_button).execute(page.c_str(), component.c_str(), event.c_str()); + if (event == "short_click" or event == "long_click") ha_button->execute(page.c_str(), component.c_str(), event.c_str()); else if (event == "click") { if (page == "home" and component == "climate") { id(entity_id) = (id(is_embedded_thermostat)) ? "embedded_climate" : ""; - id(disp1).set_component_value("climate.embedded", (id(is_embedded_thermostat)) ? 1 : 0); + disp1->set_component_value("climate.embedded", (id(is_embedded_thermostat)) ? 1 : 0); } - id(disp1).goto_page("climate"); + disp1->goto_page("climate"); } else if (page == "light" or page == "climate" or page == "notification")// Generic event { @@ -1462,15 +1424,15 @@ text_sensor: std::string title = doc["mui"]; if (code_format == "number" and (key == "disarm" or code_arm_req == "1")) { - id(disp1).goto_page("keyb_num"); - id(disp1).set_component_value("keyb_num.page_id", 23); //Calling from Alarm page - id(disp1).set_component_text_printf("keyb_num.domain", "%s", page.c_str()); - id(disp1).set_component_text_printf("keyb_num.key", "%s", key.c_str()); - id(disp1).set_component_text_printf("keyb_num.value", "%s", value.c_str()); - id(disp1).set_component_text_printf("keyb_num.entity", "%s", entity.c_str()); - id(disp1).set_component_text_printf("keyb_num.title", "%s", title.c_str()); + disp1->goto_page("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()); + disp1->set_component_text_printf("keyb_num.value", "%s", value.c_str()); + disp1->set_component_text_printf("keyb_num.entity", "%s", entity.c_str()); + disp1->set_component_text_printf("keyb_num.title", "%s", title.c_str()); } - else id(service_call_alarm_control_panel).execute(entity.c_str(), key.c_str(), code_format.c_str(), ""); + else service_call_alarm_control_panel->execute(entity.c_str(), key.c_str(), code_format.c_str(), ""); } else if (page == "boot") { @@ -1489,7 +1451,7 @@ text_sensor: std::string version_tmp = doc["version"]; id(version_tft) = version_tmp; } - id(check_versions).execute(); + check_versions->execute(); // Detect timeout if (event == "timeout") @@ -1501,19 +1463,19 @@ text_sensor: {"value", value} }); if (stof(value) >= 5) - id(disp1).goto_page(id(wakeup_page_name).state.c_str()); + disp1->goto_page(wakeup_page_name->state.c_str()); } } - else if (page == "climate") id(service_call_climate).execute(entity.c_str(), key.c_str(), value.c_str(), (embedded==1)); + else if (page == "climate") service_call_climate->execute(entity.c_str(), key.c_str(), value.c_str(), (embedded==1)); else if (page == "cover") { - if (key == "position") id(ha_call_service).execute("cover.set_cover_position", key.c_str(), value.c_str(), entity.c_str()); - else id(ha_call_service).execute((std::string("cover.") + key.c_str()), "", "", entity.c_str()); + if (key == "position") ha_call_service->execute("cover.set_cover_position", key.c_str(), value.c_str(), entity.c_str()); + else ha_call_service->execute((std::string("cover.") + key.c_str()), "", "", entity.c_str()); } else if (page == "fan") { - if (key == "stop" or value == "0") id(ha_call_service).execute("fan.turn_off", "", "", entity.c_str()); - else id(ha_call_service).execute("fan.turn_on", key.c_str(), value.c_str(), entity.c_str()); + if (key == "stop" or value == "0") ha_call_service->execute("fan.turn_off", "", "", entity.c_str()); + else ha_call_service->execute("fan.turn_on", key.c_str(), value.c_str(), entity.c_str()); } else if (page == "keyb_num") { @@ -1522,17 +1484,17 @@ text_sensor: { std::string code_format = doc["code_format"]; std::string pin = doc["pin"]; - id(service_call_alarm_control_panel).execute(entity.c_str(), key.c_str(), code_format.c_str(), pin.c_str()); + 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"; - id(disp1).goto_page(base_domain.c_str()); + disp1->goto_page(base_domain.c_str()); } - else if (page == "light") id(ha_call_service).execute("light.turn_on", key.c_str(), value.c_str(), entity.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") { - if (key == "volume_mute") id(ha_call_service).execute("media_player.volume_mute", "is_volume_muted", value.c_str(), entity.c_str()); - else if (key == "volume_set") id(ha_call_service).execute("media_player.volume_set", "volume_level", to_string(stof(value) / 100), entity.c_str()); - else if (not key.empty()) id(ha_call_service).execute((std::string("media_player.") + key.c_str()), "", "", entity.c_str()); + if (key == "volume_mute") ha_call_service->execute("media_player.volume_mute", "is_volume_muted", value.c_str(), entity.c_str()); + else if (key == "volume_set") ha_call_service->execute("media_player.volume_set", "volume_level", to_string(stof(value) / 100), entity.c_str()); + else if (not key.empty()) ha_call_service->execute((std::string("media_player.") + key.c_str()), "", "", entity.c_str()); } ### Scripts ###### @@ -1546,9 +1508,9 @@ script: then: - lambda: |- ESP_LOGV("script.timer_reset_all", "Reset timers"); - id(timer_page).execute(page.c_str(), int(id(timeout_page).state)); - id(timer_dim).execute(page.c_str(), int(id(timeout_dim).state)); - id(timer_sleep).execute(page.c_str(), int(id(timeout_sleep).state)); + timer_page->execute(page.c_str(), int(timeout_page->state)); + timer_dim->execute(page.c_str(), int(timeout_dim->state)); + timer_sleep->execute(page.c_str(), int(timeout_sleep->state)); - id: timer_page # Handle the fallback to home page after a timeout mode: restart @@ -1565,11 +1527,11 @@ script: then: - delay: !lambda return (timeout *1000); - lambda: |- - ESP_LOGV("script.timer_page", "Timed out on page: %s", id(current_page).state.c_str()); - if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and id(current_page).state != "home" and timeout >= 1) + ESP_LOGV("script.timer_page", "Timed out on page: %s", current_page->state.c_str()); + if (current_page->state != "screensaver" and current_page->state != "boot" and current_page->state != "home" and timeout >= 1) { ESP_LOGD("script.timer_page", "Fallback to page Home"); - id(disp1).goto_page("home"); + disp1->goto_page("home"); } - id: timer_dim # Handle the brightness dimming after a timeout mode: restart @@ -1584,7 +1546,7 @@ script: and page != "boot" and page != "blank-screensaver") { ESP_LOGD("script.timer_dim", "Waking up on page: %s", page.c_str()); - id(set_brightness).execute(id(display_brightness_global)); + set_brightness->execute(id(display_brightness_global)); } - if: condition: @@ -1592,11 +1554,11 @@ script: then: - delay: !lambda return (timeout *1000); - lambda: |- - if (id(current_page).state != "screensaver" and - id(current_page).state != "blank-screensaver" and - id(current_page).state != "boot" and + if (current_page->state != "screensaver" and + current_page->state != "blank-screensaver" and + current_page->state != "boot" and timeout >= 1) { - id(set_brightness).execute(id(display_dim_brightness_global)); + set_brightness->execute(id(display_dim_brightness_global)); } - id: timer_sleep # Handle the sleep (go to screensaver page) after a timeout mode: restart @@ -1609,16 +1571,16 @@ script: - if: condition: - lambda: |- - return (timeout >= 1 and id(current_page).state != "screensaver" and id(current_page).state != "boot"); + return (timeout >= 1 and current_page->state != "screensaver" and current_page->state != "boot"); then: - delay: !lambda return (timeout *1000); - lambda: |- - if (id(current_page).state != "screensaver" and - id(current_page).state != "boot" and + if (current_page->state != "screensaver" and + current_page->state != "boot" and timeout >= 1) { - ESP_LOGD("script.timer_sleep", "Going to sleep from page %s", id(current_page).state.c_str()); - id(disp1).goto_page("screensaver"); - id(set_brightness).execute(0); + ESP_LOGD("script.timer_sleep", "Going to sleep from page %s", current_page->state.c_str()); + disp1->goto_page("screensaver"); + set_brightness->execute(0); } - id: set_brightness @@ -1628,11 +1590,11 @@ script: then: - lambda: |- ESP_LOGD("script.set_brightness", "brightness: %i%%", brightness); - if (id(current_page).state != "screensaver") { + if (current_page->state != "screensaver") { if (brightness == id(display_brightness_global)) { - id(disp1).send_command_printf("wakeup_timer.en=1"); + disp1->send_command_printf("wakeup_timer.en=1"); } else { - id(disp1).set_backlight_brightness(static_cast(brightness) / 100.0f); + disp1->set_backlight_brightness(static_cast(brightness) / 100.0f); } id(display_last_brightness) = brightness; } @@ -1655,34 +1617,34 @@ script: state: 'climate' then: - lambda: |- - id(addon_climate_set_climate).execute(embedded_climate); - id(disp1).send_command_printf("climateslider.maxval=%i", total_steps); - id(disp1).set_component_value("temp_offset", temp_offset); - id(disp1).set_component_value("temp_step", temp_step); - id(disp1).set_component_text_printf("current_temp", "%.1f°", current_temp); - id(disp1).show_component("current_temp"); - id(disp1).show_component("current_icon"); + addon_climate_set_climate->execute(embedded_climate); + disp1->send_command_printf("climateslider.maxval=%i", total_steps); + disp1->set_component_value("temp_offset", temp_offset); + disp1->set_component_value("temp_step", temp_step); + disp1->set_component_text_printf("current_temp", "%.1f°", current_temp); + disp1->show_component("current_temp"); + disp1->show_component("current_icon"); if (target_temp > -999) { float slider_val = round(((10*target_temp) - temp_offset) / temp_step); - id(disp1).set_component_value("climateslider", slider_val); - id(disp1).set_component_text_printf("target_temp", "%.1f°", target_temp); - id(disp1).set_component_text_printf("target_icon", "%s", climate_icon.c_str()); - id(disp1).show_component("target_icon"); - id(disp1).show_component("target_temp"); - id(disp1).show_component("climateslider"); - id(disp1).show_component("decrease_temp"); - id(disp1).show_component("increase_temp"); + disp1->set_component_value("climateslider", slider_val); + disp1->set_component_text_printf("target_temp", "%.1f°", target_temp); + disp1->set_component_text_printf("target_icon", "%s", climate_icon.c_str()); + disp1->show_component("target_icon"); + disp1->show_component("target_temp"); + disp1->show_component("climateslider"); + disp1->show_component("decrease_temp"); + disp1->show_component("increase_temp"); } else { - id(disp1).hide_component("target_icon"); - id(disp1).hide_component("target_temp"); - id(disp1).hide_component("climateslider"); - id(disp1).hide_component("decrease_temp"); - id(disp1).hide_component("increase_temp"); + disp1->hide_component("target_icon"); + disp1->hide_component("target_temp"); + disp1->hide_component("climateslider"); + disp1->hide_component("decrease_temp"); + disp1->hide_component("increase_temp"); } - id(disp1).set_component_value("embedded", (embedded_climate) ? 1 : 0); + disp1->set_component_value("embedded", (embedded_climate) ? 1 : 0); - id: refresh_datetime mode: restart @@ -1692,9 +1654,9 @@ script: if (time_format_str.find("%p") != std::string::npos) { std::string meridiem_text = id(time_provider).now().strftime("%p"); - id(disp1).set_component_text_printf("home.meridiem", "%s", meridiem_text.c_str()); + disp1->set_component_text_printf("home.meridiem", "%s", meridiem_text.c_str()); } - else { id(disp1).set_component_text_printf("home.meridiem", " "); } + else { disp1->set_component_text_printf("home.meridiem", " "); } if (time_format_str.find("%-H") != std::string::npos) { time_format_str = time_format_str.replace(time_format_str.find("%-H"), sizeof("%-H")-1, to_string((int)(id(time_provider).now().hour))); } if (time_format_str.find("%-I") != std::string::npos) { @@ -1712,20 +1674,20 @@ script: } } std::string time_text = id(time_provider).now().strftime(time_format_str); - id(disp1).set_component_text_printf("home.time", "%s", time_text.c_str()); + disp1->set_component_text_printf("home.time", "%s", time_text.c_str()); - id: refresh_relays mode: restart then: - lambda: |- // Chips - Relays - if (id(relay_1).state) id(disp1).set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str()); - else id(disp1).set_component_text_printf("icon_top_01", "\uFFFF"); - if (id(relay_2).state) id(disp1).set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str()); - else id(disp1).set_component_text_printf("home.icon_top_02", "\uFFFF"); + if (relay_1->state) disp1->set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str()); + else disp1->set_component_text_printf("icon_top_01", "\uFFFF"); + if (relay_2->state) disp1->set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str()); + else disp1->set_component_text_printf("home.icon_top_02", "\uFFFF"); // Hardware buttons - Fallback mode - if (id(relay_1).state and id(relay1_local).state) id(disp1).send_command_printf("home.left_bt_pic.val=%i", (id(relay_1).state) ? 1 : 0); - if (id(relay_2).state and id(relay2_local).state) id(disp1).send_command_printf("home.right_bt_pic.val=%i", (id(relay_2).state) ? 1 : 0); + if (relay_1->state and relay1_local->state) disp1->send_command_printf("home.left_bt_pic.val=%i", (relay_1->state) ? 1 : 0); + if (relay_2->state and relay2_local->state) disp1->send_command_printf("home.right_bt_pic.val=%i", (relay_2->state) ? 1 : 0); - id: refresh_wifi_icon mode: restart @@ -1743,17 +1705,17 @@ script: condition: api.connected: then: - - lambda: id(disp1).send_command_printf("api=1"); - - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A8"); - - lambda: id(disp1).set_component_font_color("home.wifi_icon", 33808); + - lambda: disp1->send_command_printf("api=1"); + - lambda: disp1->set_component_text_printf("home.wifi_icon", "%s", "\uE5A8"); + - lambda: disp1->set_component_font_color("home.wifi_icon", 33808); else: - - lambda: id(disp1).send_command_printf("api=0"); - - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uF256"); - - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488); + - lambda: disp1->send_command_printf("api=0"); + - lambda: disp1->set_component_text_printf("home.wifi_icon", "%s", "\uF256"); + - lambda: disp1->set_component_font_color("home.wifi_icon", 63488); else: - - lambda: id(disp1).send_command_printf("api=0"); - - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A9"); - - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488); + - lambda: disp1->send_command_printf("api=0"); + - lambda: disp1->set_component_text_printf("home.wifi_icon", "%s", "\uE5A9"); + - lambda: disp1->set_component_font_color("home.wifi_icon", 63488); - id: service_call_alarm_control_panel mode: restart @@ -1785,7 +1747,7 @@ script: resp_kv.value = pin.c_str(); resp.data.push_back(resp_kv); } - id(api_server).send_homeassistant_service_call(resp); + api_server->send_homeassistant_service_call(resp); } - id: service_call_climate @@ -1798,11 +1760,11 @@ script: then: - lambda: |- if (embedded) - id(addon_climate_service_call).execute(key.c_str(), value.c_str()); + addon_climate_service_call->execute(key.c_str(), value.c_str()); else if (key == "set_temperature") - id(ha_call_service).execute("climate.set_temperature", "temperature", to_string(stof(value) / 10), entity.c_str()); + ha_call_service->execute("climate.set_temperature", "temperature", to_string(stof(value) / 10), entity.c_str()); else if (key == "hvac_mode") - id(ha_call_service).execute("climate.set_hvac_mode", key.c_str(), value.c_str(), entity.c_str()); + ha_call_service->execute("climate.set_hvac_mode", key.c_str(), value.c_str(), entity.c_str()); - id: ha_call_service mode: restart @@ -1834,7 +1796,7 @@ script: command: string then: - lambda: |- - id(timer_reset_all).execute(page.c_str()); + timer_reset_all->execute(page.c_str()); auto ha_event = new esphome::api::CustomAPIDevice(); ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", { @@ -1898,8 +1860,8 @@ script: alarm_icon = "\uEECC"; //mdi:shield-alert-outline alarm_color = 63488; } - id(disp1).set_component_text_printf(component.c_str(), alarm_icon.c_str()); - id(disp1).set_component_font_color(component.c_str(), alarm_color); + disp1->set_component_text_printf(component.c_str(), alarm_icon.c_str()); + disp1->set_component_font_color(component.c_str(), alarm_color); - id: update_climate_icon mode: restart @@ -1915,54 +1877,54 @@ script: switch (mode) // CLIMATE_MODE_OFF = 0, CLIMATE_MODE_HEAT_COOL = 1, CLIMATE_MODE_COOL = 2, CLIMATE_MODE_HEAT = 3, CLIMATE_MODE_FAN_ONLY = 4, CLIMATE_MODE_DRY = 5, CLIMATE_MODE_AUTO = 6 { case 0: //CLIMATE_MODE_OFF - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uFFFF"); // (E424) Don't show icon when off - id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) + disp1->set_component_text_printf(component.c_str(), "%s", "\uFFFF"); // (E424) Don't show icon when off + disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 1: //CLIMATE_MODE_HEAT_COOL - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE069"); // mdi:autorenew - id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) + disp1->set_component_text_printf(component.c_str(), "%s", "\uE069"); // mdi:autorenew + disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 2: //CLIMATE_MODE_COOL - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake - id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) + disp1->set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake + disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 3: //CLIMATE_MODE_HEAT - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire - id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) + disp1->set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire + disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 4: //CLIMATE_MODE_FAN_ONLY - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan - id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) + disp1->set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan + disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 5: //CLIMATE_MODE_DRY - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent - id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) + disp1->set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent + disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 6: //CLIMATE_MODE_AUTO - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uEE8D"); // mdi:calendar-sync - id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) + disp1->set_component_text_printf(component.c_str(), "%s", "\uEE8D"); // mdi:calendar-sync + disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; } break; case 2: //CLIMATE_ACTION_COOLING - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake - id(disp1).set_component_font_color(component.c_str(), 1055); // blue + disp1->set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake + disp1->set_component_font_color(component.c_str(), 1055); // blue break; case 3: //CLIMATE_ACTION_HEATING - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire - id(disp1).set_component_font_color(component.c_str(), 64164); // deep-orange + disp1->set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire + disp1->set_component_font_color(component.c_str(), 64164); // deep-orange break; case 4: //CLIMATE_ACTION_IDLE - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE50E"); // mdi:thermometer - id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) + disp1->set_component_text_printf(component.c_str(), "%s", "\uE50E"); // mdi:thermometer + disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 5: //CLIMATE_ACTION_DRYING - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent - id(disp1).set_component_font_color(component.c_str(), 64704); // orange + disp1->set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent + disp1->set_component_font_color(component.c_str(), 64704); // orange break; case 6: //CLIMATE_ACTION_FAN - id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan - id(disp1).set_component_font_color(component.c_str(), 1530); // cyan + disp1->set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan + disp1->set_component_font_color(component.c_str(), 1530); // cyan break; } @@ -1980,12 +1942,12 @@ script: // Foreground if (foreground.size() == 3) fg565 = ((foreground[0] & 0b11111000) << 8) | ((foreground[1] & 0b11111100) << 3) | (foreground[2] >> 3); else if (foreground.size() == 1) fg565 = foreground[0]; - if (fg565 >= 0) id(disp1).set_component_font_color(component.c_str(), fg565); + if (fg565 >= 0) disp1->set_component_font_color(component.c_str(), fg565); // Background if (background.size() == 3) bg565 = ((background[0] & 0b11111000) << 8) | ((background[1] & 0b11111100) << 3) | (background[2] >> 3); else if (background.size() == 1) bg565 = background[0]; - if (bg565 >= 0) id(disp1).set_component_background_color(component.c_str(), bg565); + if (bg565 >= 0) disp1->set_component_background_color(component.c_str(), bg565); - id: display_wrapped_text mode: queued @@ -2016,7 +1978,7 @@ script: startPos = endPos + 1; // Skip the space while (text[startPos] == ' ' and startPos < text.length()) { startPos++; } } - id(disp1).set_component_text_printf(component.c_str(), "%s", wrappedText.c_str()); + disp1->set_component_text_printf(component.c_str(), "%s", wrappedText.c_str()); - id: display_embedded_temp mode: restart @@ -2031,8 +1993,8 @@ script: - wifi.connected: then: - lambda: |- - if (id(temp_unit_fahrenheit)) id(disp1).set_component_text_printf("home.current_temp", "%.0f°F", ((id(temp_nspanel).state * 9.0 / 5.0) + 32.0)); // °F = (°C × 9/5) + 32 - else id(disp1).set_component_text_printf("home.current_temp", "%.1f°C", id(temp_nspanel).state); + if (id(temp_unit_fahrenheit)) disp1->set_component_text_printf("home.current_temp", "%.0f°F", ((temp_nspanel->state * 9.0 / 5.0) + 32.0)); // °F = (°C × 9/5) + 32 + else disp1->set_component_text_printf("home.current_temp", "%.1f°C", temp_nspanel->state); - id: check_versions mode: restart @@ -2109,7 +2071,7 @@ script: if (!id(entity_id).empty()) ESP_LOGD(TAG, "Entity shown: %s", id(entity_id).c_str()); // Reset timers - id(timer_reset_all).execute(page.c_str()); + timer_reset_all->execute(page.c_str()); // Report new page to Home Assistant ESP_LOGV(TAG, "Trigger HA event"); @@ -2123,35 +2085,35 @@ script: // Report new page to add-ons ESP_LOGV(TAG, "Call add-ons scripts for new page"); - id(addon_climate_set_climate).execute(page == "climate" and id(entity_id) == "embedded_climate"); + addon_climate_set_climate->execute(page == "climate" and id(entity_id) == "embedded_climate"); // Call page constructor - if (page == "boot") id(page_boot).execute(true); - else if (page == "buttonpage01") id(page_buttonpage).execute(true, 1); - else if (page == "buttonpage02") id(page_buttonpage).execute(true, 2); - else if (page == "buttonpage03") id(page_buttonpage).execute(true, 3); - else if (page == "buttonpage04") id(page_buttonpage).execute(true, 4); - else if (page == "climate") id(page_climate).execute(true); - else if (page == "confirm") id(page_confirm).execute(true); - else if (page == "cover") id(page_cover).execute(true); - else if (page == "entitypage01") id(page_entitypage).execute(true, 1); - else if (page == "entitypage02") id(page_entitypage).execute(true, 2); - else if (page == "entitypage03") id(page_entitypage).execute(true, 3); - else if (page == "entitypage04") id(page_entitypage).execute(true, 4); - else if (page == "fan") id(page_fan).execute(true); - else if (page == "home") id(page_home).execute(true); - else if (page == "keyb_num") id(page_keyb_num).execute(true); - else if (page == "light") id(page_light).execute(true); - else if (page == "media_player") id(page_media_player).execute(true); - else if (page == "notification") id(page_notification).execute(true); - else if (page == "qrcode") id(page_qrcode).execute(true); - else if (page == "screensaver") id(page_screensaver).execute(true); - else if (page == "settings") id(page_settings).execute(true); - else if (page == "weather01") id(page_weather).execute(true, 1); - else if (page == "weather02") id(page_weather).execute(true, 2); - else if (page == "weather03") id(page_weather).execute(true, 3); - else if (page == "weather04") id(page_weather).execute(true, 4); - else if (page == "weather05") id(page_weather).execute(true, 5); + if (page == "boot") page_boot->execute(true); + else if (page == "buttonpage01") page_buttonpage->execute(true, 1); + else if (page == "buttonpage02") page_buttonpage->execute(true, 2); + else if (page == "buttonpage03") page_buttonpage->execute(true, 3); + else if (page == "buttonpage04") page_buttonpage->execute(true, 4); + else if (page == "climate") page_climate->execute(true); + else if (page == "confirm") page_confirm->execute(true); + else if (page == "cover") page_cover->execute(true); + else if (page == "entitypage01") page_entitypage->execute(true, 1); + else if (page == "entitypage02") page_entitypage->execute(true, 2); + else if (page == "entitypage03") page_entitypage->execute(true, 3); + else if (page == "entitypage04") page_entitypage->execute(true, 4); + else if (page == "fan") page_fan->execute(true); + else if (page == "home") page_home->execute(true); + else if (page == "keyb_num") page_keyb_num->execute(true); + else if (page == "light") page_light->execute(true); + else if (page == "media_player") page_media_player->execute(true); + else if (page == "notification") page_notification->execute(true); + else if (page == "qrcode") page_qrcode->execute(true); + else if (page == "screensaver") page_screensaver->execute(true); + else if (page == "settings") page_settings->execute(true); + else if (page == "weather01") page_weather->execute(true, 1); + else if (page == "weather02") page_weather->execute(true, 2); + else if (page == "weather03") page_weather->execute(true, 3); + else if (page == "weather04") page_weather->execute(true, 4); + else if (page == "weather05") page_weather->execute(true, 5); - id: page_boot mode: restart @@ -2162,6 +2124,11 @@ script: static const char *const TAG = "script.page_boot"; if (construct_page) { ESP_LOGV(TAG, "Construct boot page"); + disp1->send_command_printf("tm_esphome.en=0"); + disp1->send_command_printf("tm_pageid.en=0"); + set_brightness->execute(100); + disp1->set_component_text_printf("boot.esph_version", "%s", "${version}"); // ### esphome-version ### + disp1->show_component("bt_reboot"); } - id: page_buttonpage @@ -2174,7 +2141,7 @@ script: static const char *const TAG = "script.page_buttonpage"; if (construct_page) { ESP_LOGV(TAG, "Construct button page"); - id(page_index_indicator).execute(page_number, 4); + page_index_indicator->execute(page_number, 4); } - id: page_climate @@ -2186,15 +2153,15 @@ script: static const char *const TAG = "script.page_climate"; if (construct_page) { ESP_LOGV(TAG, "Construct climate page"); - id(disp1).set_component_text_printf("climate.button01_icon", "%s", "\uEE8D"); //mdi:calendar-sync - id(disp1).set_component_text_printf("climate.button02_icon", "%s", "\uE069"); //mdi:autorenew - id(disp1).set_component_text_printf("climate.button03_icon", "%s", "\uE237"); //mdi:fire - id(disp1).set_component_text_printf("climate.button04_icon", "%s", "\uE716"); //mdi:snowflake - id(disp1).set_component_text_printf("climate.button05_icon", "%s", "\uE58D"); //mdi:water-percent - id(disp1).set_component_text_printf("climate.button06_icon", "%s", "\uE20F"); //mdi:fan - id(disp1).set_component_text_printf("climate.button07_icon", "%s", "\uE424"); //mdi:power + disp1->set_component_text_printf("climate.button01_icon", "%s", "\uEE8D"); //mdi:calendar-sync + disp1->set_component_text_printf("climate.button02_icon", "%s", "\uE069"); //mdi:autorenew + disp1->set_component_text_printf("climate.button03_icon", "%s", "\uE237"); //mdi:fire + disp1->set_component_text_printf("climate.button04_icon", "%s", "\uE716"); //mdi:snowflake + disp1->set_component_text_printf("climate.button05_icon", "%s", "\uE58D"); //mdi:water-percent + disp1->set_component_text_printf("climate.button06_icon", "%s", "\uE20F"); //mdi:fan + disp1->set_component_text_printf("climate.button07_icon", "%s", "\uE424"); //mdi:power } - id(addon_climate_update_page_climate).execute(); + addon_climate_update_page_climate->execute(); - id: page_confirm mode: restart @@ -2216,10 +2183,10 @@ script: static const char *const TAG = "script.page_cover"; if (construct_page) { // To do: Should be moved to Blueprint ESP_LOGV(TAG, "Construct cover page"); - id(disp1).set_component_text_printf("cover.cover_stop", "%s", "\uE666"); //mdi:stop-circle-outline + disp1->set_component_text_printf("cover.cover_stop", "%s", "\uE666"); //mdi:stop-circle-outline // In the future this will be dynamically contructed based on the device_class - id(disp1).set_component_text_printf("cover.cover_open", "%s", "\uF11D"); //mdi:window-shutter-open - id(disp1).set_component_text_printf("cover.cover_close", "%s", "\uF11B"); //mdi:window-shutter + disp1->set_component_text_printf("cover.cover_open", "%s", "\uF11D"); //mdi:window-shutter-open + disp1->set_component_text_printf("cover.cover_close", "%s", "\uF11B"); //mdi:window-shutter } - id: page_entitypage @@ -2232,7 +2199,7 @@ script: static const char *const TAG = "script.page_entitypage"; if (construct_page) { ESP_LOGV(TAG, "Construct entity page"); - id(page_index_indicator).execute(page_number, 4); + page_index_indicator->execute(page_number, 4); } - id: page_fan @@ -2244,10 +2211,10 @@ script: static const char *const TAG = "script.page_fan"; if (construct_page) { // To do: Should be moved to Blueprint ESP_LOGV(TAG, "Construct fan page"); - id(disp1).set_component_text_printf("fan.button_on", "%s", "\uE20F"); //mdi:fan - id(disp1).set_component_text_printf("fan.button_off", "%s", "\uE81C"); //mdi:fan-off - id(disp1).set_component_text_printf("fan.button_up", "%s", "\uF46D"); //mdi:fan-chevron-up - id(disp1).set_component_text_printf("fan.button_down", "%s", "\uF46C"); //mdi:fan-chevron-down + disp1->set_component_text_printf("fan.button_on", "%s", "\uE20F"); //mdi:fan + disp1->set_component_text_printf("fan.button_off", "%s", "\uE81C"); //mdi:fan-off + disp1->set_component_text_printf("fan.button_up", "%s", "\uF46D"); //mdi:fan-chevron-up + disp1->set_component_text_printf("fan.button_down", "%s", "\uF46C"); //mdi:fan-chevron-down } - id: page_home @@ -2260,14 +2227,14 @@ script: if (construct_page) { ESP_LOGV(TAG, "Construct home page"); } - if (id(current_page).state == "home") { // Is home page visible? + if (current_page->state == "home") { // Is home page visible? ESP_LOGV(TAG, "Update home page"); - id(refresh_relays).execute(); - id(refresh_wifi_icon).execute(); - id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1); - id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal), {}); - id(refresh_datetime).execute(); - id(addon_climate_update_page_home).execute(); + refresh_relays->execute(); + refresh_wifi_icon->execute(); + disp1->send_command_printf("is_notification=%i", (notification_text->state.empty() and notification_label->state.empty()) ? 0 : 1); + set_component_color->execute("home.bt_notific", notification_unread->state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal), {}); + refresh_datetime->execute(); + addon_climate_update_page_home->execute(); } - id: page_keyb_num @@ -2279,10 +2246,10 @@ script: static const char *const TAG = "script.page_keyb_num"; if (construct_page) { ESP_LOGV(TAG, "Construct keyb_num page"); - id(disp1).set_component_text_printf("keyb_num.bview", "%s", "\uE207"); //mdi:eye - id(disp1).set_component_text_printf("keyb_num.bclose", "%s", "\uE158"); //mdi:close-circle - id(disp1).set_component_text_printf("keyb_num.bclear", "%s", "\uE641"); //mdi:eraser-variant - id(disp1).set_component_text_printf("keyb_num.benter", "%s", "\uE12B"); //mdi:check + disp1->set_component_text_printf("keyb_num.bview", "%s", "\uE207"); //mdi:eye + disp1->set_component_text_printf("keyb_num.bclose", "%s", "\uE158"); //mdi:close-circle + disp1->set_component_text_printf("keyb_num.bclear", "%s", "\uE641"); //mdi:eraser-variant + disp1->set_component_text_printf("keyb_num.benter", "%s", "\uE12B"); //mdi:check } - id: page_light @@ -2306,14 +2273,14 @@ script: static const char *const TAG = "script.page_media_player"; if (construct_page) { // To do: Should be moved to Blueprint ESP_LOGV(TAG, "Construct media_player page"); - id(disp1).set_component_text_printf("bt_on_off", "%s", "\uE424"); //mdi:power - id(disp1).set_component_text_printf("bt_prev", "%s", "\uE4AD"); //mdi:skip-previous - id(disp1).set_component_text_printf("bt_next", "%s", "\uE4AC"); //mdi:skip-next - id(disp1).set_component_text_printf("bt_play_pause", "%s", "\uE40D"); //mdi:play-pause - //id(disp1).set_component_text_printf("bt_stop", "%s", "\uE4DA"); //mdi:stop - id(disp1).set_component_text_printf("bt_mute", "%s", "\uE75E"); //mdi:volume-mute - id(disp1).set_component_text_printf("bt_vol_down", "%s", "\uE75D"); //mdi:volume-minus - id(disp1).set_component_text_printf("bt_vol_up", "%s", "\uE75C"); //mdi:volume-plus + disp1->set_component_text_printf("bt_on_off", "%s", "\uE424"); //mdi:power + disp1->set_component_text_printf("bt_prev", "%s", "\uE4AD"); //mdi:skip-previous + disp1->set_component_text_printf("bt_next", "%s", "\uE4AC"); //mdi:skip-next + disp1->set_component_text_printf("bt_play_pause", "%s", "\uE40D"); //mdi:play-pause + //disp1->set_component_text_printf("bt_stop", "%s", "\uE4DA"); //mdi:stop + disp1->set_component_text_printf("bt_mute", "%s", "\uE75E"); //mdi:volume-mute + disp1->set_component_text_printf("bt_vol_down", "%s", "\uE75D"); //mdi:volume-minus + disp1->set_component_text_printf("bt_vol_up", "%s", "\uE75C"); //mdi:volume-plus } - id: page_notification @@ -2325,8 +2292,8 @@ script: static const char *const TAG = "script.page_notification"; if (construct_page) { ESP_LOGV(TAG, "Construct notification page"); - id(disp1).set_component_text_printf("notification.notifi_label", "%s", id(notification_label).state.c_str()); - id(display_wrapped_text).execute("notification.notifi_text01", id(notification_text).state.c_str(), id(display_mode) == 2 ? 23 : 32); + disp1->set_component_text_printf("notification.notifi_label", "%s", notification_label->state.c_str()); + display_wrapped_text->execute("notification.notifi_text01", notification_text->state.c_str(), id(display_mode) == 2 ? 23 : 32); } - id: page_qrcode @@ -2350,20 +2317,20 @@ script: if (construct_page) { ESP_LOGV(TAG, "Construct screensaver page"); } - if (id(current_page).state == "screensaver") { // Is screensaver page visible? + if (current_page->state == "screensaver") { // Is screensaver page visible? ESP_LOGV(TAG, "Update screensaver page"); int wakeup_page_id = 0; - if (id(wakeup_page_name).state == "buttonpage01") wakeup_page_id = 12; - else if (id(wakeup_page_name).state == "buttonpage02") wakeup_page_id = 13; - else if (id(wakeup_page_name).state == "buttonpage03") wakeup_page_id = 14; - else if (id(wakeup_page_name).state == "buttonpage04") wakeup_page_id = 15; - else if (id(wakeup_page_name).state == "entitypage01") wakeup_page_id = 18; - else if (id(wakeup_page_name).state == "entitypage02") wakeup_page_id = 19; - else if (id(wakeup_page_name).state == "entitypage03") wakeup_page_id = 20; - else if (id(wakeup_page_name).state == "entitypage04") wakeup_page_id = 21; - else if (id(wakeup_page_name).state == "qrcode") wakeup_page_id = 17; - else if (id(wakeup_page_name).state == "alarm") wakeup_page_id = 23; - id(disp1).set_component_value("orign", wakeup_page_id); + if (wakeup_page_name->state == "buttonpage01") wakeup_page_id = 12; + else if (wakeup_page_name->state == "buttonpage02") wakeup_page_id = 13; + else if (wakeup_page_name->state == "buttonpage03") wakeup_page_id = 14; + else if (wakeup_page_name->state == "buttonpage04") wakeup_page_id = 15; + else if (wakeup_page_name->state == "entitypage01") wakeup_page_id = 18; + else if (wakeup_page_name->state == "entitypage02") wakeup_page_id = 19; + else if (wakeup_page_name->state == "entitypage03") wakeup_page_id = 20; + else if (wakeup_page_name->state == "entitypage04") wakeup_page_id = 21; + else if (wakeup_page_name->state == "qrcode") wakeup_page_id = 17; + else if (wakeup_page_name->state == "alarm") wakeup_page_id = 23; + disp1->set_component_value("orign", wakeup_page_id); } - id: page_settings @@ -2375,9 +2342,9 @@ script: static const char *const TAG = "script.page_settings"; if (construct_page) { // To do: Add timers on TFT? ESP_LOGV(TAG, "Construct settings page"); - //id(disp1).set_component_text_printf("bt_sleep", "%s", (id(sleep_mode).state) ? "\uEA19" : "\uEA18"); //mdi:toggle-switch-outline or mdi:toggle-switch-off-outline - id(disp1).hide_component("lbl_sleep"); - id(disp1).hide_component("bt_sleep"); + //disp1->set_component_text_printf("bt_sleep", "%s", (id(sleep_mode).state) ? "\uEA19" : "\uEA18"); //mdi:toggle-switch-outline or mdi:toggle-switch-off-outline + disp1->hide_component("lbl_sleep"); + disp1->hide_component("bt_sleep"); } - id: page_weather @@ -2390,7 +2357,7 @@ script: static const char *const TAG = "script.page_weather"; if (construct_page) { ESP_LOGV(TAG, "Construct weather page"); - id(page_index_indicator).execute(page_number, 5); + page_index_indicator->execute(page_number, 5); } - id: page_index_indicator @@ -2410,7 +2377,7 @@ script: indicator += "○"; } } - id(disp1).set_component_text_printf("page_index", "%s", indicator.c_str()); + disp1->set_component_text_printf("page_index", "%s", indicator.c_str()); - id: exit_reparse mode: restart @@ -2423,6 +2390,64 @@ script: id: tf_uart data: [0xFF, 0xFF, 0xFF] + - id: boot_sequence + mode: restart + then: + - lambda: |- + static const char *const TAG = "script.boot_sequence"; + ESP_LOGD(TAG, "Starting boot sequence"); + if (current_page->state == "boot") page_boot->execute(true); + timer_reset_all->execute("boot"); + ESP_LOGD(TAG, "Wait for API"); + - wait_until: + api.connected + - lambda: |- + static const char *const TAG = "script.boot_sequence"; + if (current_page->state == "boot") { + ESP_LOGD(TAG, "Publish IP address"); + disp1->set_component_text_printf("boot.ip_addr", "%s", network::get_ip_address().str().c_str()); + set_brightness->execute(100); + } + ESP_LOGD(TAG, "Report to Home Assistant"); + auto ha_event = new esphome::api::CustomAPIDevice(); + ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + { + {"type", "boot"}, + {"step", "start"} + }); + delay(1000); + // Set dimming values + display_brightness->publish_state(id(display_brightness_global)); + display_dim_brightness->publish_state(id(display_dim_brightness_global)); + 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)); + set_brightness->execute(id(display_brightness_global)); + ESP_LOGD(TAG, "Report to Home Assistant"); + nextion_init->publish_state(true); + //auto ha_event = new esphome::api::CustomAPIDevice(); + ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + { + {"type", "boot"}, + {"step", "nextion_init"} + }); + id(home_relay1_icon) = "\uE3A5"; + id(home_relay1_icon) = "\uE3A8"; + timer_reset_all->execute("boot"); + notification_clear->execute(); + ESP_LOGD(TAG, "Boot sequence finished!"); + + - id: notification_clear + mode: restart + then: + - lambda: |- + disp1->send_command_printf("is_notification=0"); + if (current_page->state == "home") disp1->hide_component("bt_notific"); + notification_label->publish_state(""); + notification_text->publish_state(""); + notification_unread->turn_off(); + ##### ADD-ONS ############################################################ ##### Add-on - Climate ##### - id: addon_climate_service_call diff --git a/nspanel_eu.HMI b/nspanel_eu.HMI index 371efe0..1eb5d5b 100644 Binary files a/nspanel_eu.HMI and b/nspanel_eu.HMI differ diff --git a/nspanel_eu.tft b/nspanel_eu.tft index 7f77c1f..593491c 100644 Binary files a/nspanel_eu.tft and b/nspanel_eu.tft differ diff --git a/nspanel_eu_code/Program.s.txt b/nspanel_eu_code/Program.s.txt index 9cb5ec8..8df190e 100644 --- a/nspanel_eu_code/Program.s.txt +++ b/nspanel_eu_code/Program.s.txt @@ -18,9 +18,9 @@ Program.s lcd_dev fffb 0002 0000 0020// Fix touch offset for EU Version } printh 92 - prints "nspanelevent",0 + prints "currentpage",0 printh 00 - prints "{\"page\": \"\", \"component\": \"\", \"value\": \"\"}",0 + prints "",0 printh 00 printh FF FF FF page 8//Power on start page boot diff --git a/nspanel_eu_code/boot.txt b/nspanel_eu_code/boot.txt index 7f58781..ee3f1ab 100644 --- a/nspanel_eu_code/boot.txt +++ b/nspanel_eu_code/boot.txt @@ -20,14 +20,7 @@ Page boot printh FF FF FF dim=0 vis bt_reboot,0 - covx display_mode,aux2.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" - printh 92 - prints "localevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF + covx baud,baud_rate.txt,0,0 Touch Press Event printh 91 @@ -140,7 +133,7 @@ Text tft_version Dragging : 0 Send Component ID : disabled Associated Keyboard: none - Text : 4.1dev3 + Text : 4.1dev4 Max. Text Size : 9 Text esph_version @@ -163,6 +156,16 @@ Text bluep_version Text : Max. Text Size : 9 +Text baud_rate + Attributes + ID : 18 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : + Max. Text Size : 10 + Dual-state Button bt_reboot Attributes ID : 4 @@ -217,3 +220,39 @@ Timer wakeup_timer wakeup_timer.en=0 } +Timer tm_esphome + Attributes + ID : 17 + Scope : local + Period (ms): 30000 + Enabled : yes + + Events + Timer Event + if(baud==115200) + { + bauds=921600 + }else + { + bauds=115200 + } + rest + +Timer tm_pageid + Attributes + ID : 19 + Scope : local + Period (ms): 2500 + Enabled : yes + + Events + Timer Event + covx display_mode,aux2.txt,0,0 + nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" + printh 92 + prints "localevent",0 + printh 00 + prints nspanelevent.txt,0 + printh 00 + printh FF FF FF + diff --git a/nspanel_us.HMI b/nspanel_us.HMI index 1f8e1ad..4dd6d3c 100644 Binary files a/nspanel_us.HMI and b/nspanel_us.HMI differ diff --git a/nspanel_us.tft b/nspanel_us.tft index 2e3a9a0..6359724 100644 Binary files a/nspanel_us.tft and b/nspanel_us.tft differ diff --git a/nspanel_us_code/Program.s.txt b/nspanel_us_code/Program.s.txt index 52a40de..6612dfe 100644 --- a/nspanel_us_code/Program.s.txt +++ b/nspanel_us_code/Program.s.txt @@ -18,9 +18,9 @@ Program.s lcd_dev fffb 0002 0000 0020// Fix touch offset for EU Version } printh 92 - prints "nspanelevent",0 + prints "currentpage",0 printh 00 - prints "{\"page\": \"\", \"component\": \"\", \"value\": \"\"}",0 + prints "",0 printh 00 printh FF FF FF page 8//Power on start page boot diff --git a/nspanel_us_code/boot.txt b/nspanel_us_code/boot.txt index 7f58781..ee3f1ab 100644 --- a/nspanel_us_code/boot.txt +++ b/nspanel_us_code/boot.txt @@ -20,14 +20,7 @@ Page boot printh FF FF FF dim=0 vis bt_reboot,0 - covx display_mode,aux2.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" - printh 92 - prints "localevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF + covx baud,baud_rate.txt,0,0 Touch Press Event printh 91 @@ -140,7 +133,7 @@ Text tft_version Dragging : 0 Send Component ID : disabled Associated Keyboard: none - Text : 4.1dev3 + Text : 4.1dev4 Max. Text Size : 9 Text esph_version @@ -163,6 +156,16 @@ Text bluep_version Text : Max. Text Size : 9 +Text baud_rate + Attributes + ID : 18 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : + Max. Text Size : 10 + Dual-state Button bt_reboot Attributes ID : 4 @@ -217,3 +220,39 @@ Timer wakeup_timer wakeup_timer.en=0 } +Timer tm_esphome + Attributes + ID : 17 + Scope : local + Period (ms): 30000 + Enabled : yes + + Events + Timer Event + if(baud==115200) + { + bauds=921600 + }else + { + bauds=115200 + } + rest + +Timer tm_pageid + Attributes + ID : 19 + Scope : local + Period (ms): 2500 + Enabled : yes + + Events + Timer Event + covx display_mode,aux2.txt,0,0 + nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" + printh 92 + prints "localevent",0 + printh 00 + prints nspanelevent.txt,0 + printh 00 + printh FF FF FF + diff --git a/nspanel_us_land.HMI b/nspanel_us_land.HMI index 7daf9d8..723eae5 100644 Binary files a/nspanel_us_land.HMI and b/nspanel_us_land.HMI differ diff --git a/nspanel_us_land.tft b/nspanel_us_land.tft index 0d9c425..6eb30fe 100644 Binary files a/nspanel_us_land.tft and b/nspanel_us_land.tft differ diff --git a/nspanel_us_land_code/Program.s.txt b/nspanel_us_land_code/Program.s.txt index 0a45324..9d3a5a7 100644 --- a/nspanel_us_land_code/Program.s.txt +++ b/nspanel_us_land_code/Program.s.txt @@ -18,9 +18,9 @@ Program.s lcd_dev fffb 0002 0000 0020// Fix touch offset for EU Version } printh 92 - prints "nspanelevent",0 + prints "currentpage",0 printh 00 - prints "{\"page\": \"\", \"component\": \"\", \"value\": \"\"}",0 + prints "",0 printh 00 printh FF FF FF page 8//Power on start page boot diff --git a/nspanel_us_land_code/boot.txt b/nspanel_us_land_code/boot.txt index 7f58781..ee3f1ab 100644 --- a/nspanel_us_land_code/boot.txt +++ b/nspanel_us_land_code/boot.txt @@ -20,14 +20,7 @@ Page boot printh FF FF FF dim=0 vis bt_reboot,0 - covx display_mode,aux2.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" - printh 92 - prints "localevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF + covx baud,baud_rate.txt,0,0 Touch Press Event printh 91 @@ -140,7 +133,7 @@ Text tft_version Dragging : 0 Send Component ID : disabled Associated Keyboard: none - Text : 4.1dev3 + Text : 4.1dev4 Max. Text Size : 9 Text esph_version @@ -163,6 +156,16 @@ Text bluep_version Text : Max. Text Size : 9 +Text baud_rate + Attributes + ID : 18 + Scope : local + Dragging : 0 + Send Component ID : disabled + Associated Keyboard: none + Text : + Max. Text Size : 10 + Dual-state Button bt_reboot Attributes ID : 4 @@ -217,3 +220,39 @@ Timer wakeup_timer wakeup_timer.en=0 } +Timer tm_esphome + Attributes + ID : 17 + Scope : local + Period (ms): 30000 + Enabled : yes + + Events + Timer Event + if(baud==115200) + { + bauds=921600 + }else + { + bauds=115200 + } + rest + +Timer tm_pageid + Attributes + ID : 19 + Scope : local + Period (ms): 2500 + Enabled : yes + + Events + Timer Event + covx display_mode,aux2.txt,0,0 + nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" + printh 92 + prints "localevent",0 + printh 00 + prints nspanelevent.txt,0 + printh 00 + printh FF FF FF +