From 3f9f0c00de116d1f54b8f497b023e93e19b98084 Mon Sep 17 00:00:00 2001 From: bkbartk Date: Fri, 24 Nov 2023 09:08:00 +0100 Subject: [PATCH 1/8] make screen power available sorry, I'm stubborn, but I sometimes prefer this over the 15 sec press --- nspanel_esphome_core.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index 89bdf83..751546f 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -1281,7 +1281,7 @@ switch: number: 4 inverted: true restore_mode: ALWAYS_ON - internal: true + # internal: true ##### Relay Local control ##### - name: ${device_name} Relay 1 Local From be37fc394154d911625c68941ed31400980b44e6 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 24 Nov 2023 17:23:09 +0100 Subject: [PATCH 2/8] New switch "Screen Power" --- ReleaseNotes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index e4d5f58..6dd3139 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -93,6 +93,7 @@ packages: - 4.1.2 patch: - Fix light icon color not being used for buttons - Add option to wake-up to Climate page + - New switch "Screen Power" which can turn the screen on/off   ## Details of noteworthy changes @@ -157,6 +158,7 @@ See here: https://github.com/Blackymas/NSPanel_HA_Blueprint/labels/roadmap - Display current temperature on buttons even when climate is off (#1268) - Button pages shows entity's icon when available (#1269) - Home page buttons shows entity's icon when available (#1276) + - New switch "Screen Power" which can turn the screen on/off (#1327) ## New Contributors @misery From c6141b97f6f0584ed03d96a03ad5cce5f89e4f97 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 24 Nov 2023 17:24:59 +0100 Subject: [PATCH 3/8] Set display not available when power off --- nspanel_esphome_core.yaml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index 751546f..080e370 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -345,10 +345,8 @@ api: disp1->set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str()); - wait_until: condition: - - not: - - text_sensor.state: # Is boot page visible? - id: current_page - state: 'boot' + - lambda: |- + return (id(boot_sequence_completed) or current_page->state != "boot"); timeout: 2s - if: condition: @@ -735,6 +733,12 @@ display: ##### START - GLOBALS CONFIGURATION ##### globals: + ##### Is boot sequence completed? ##### + - id: boot_sequence_completed + type: bool + restore_value: false + initial_value: 'false' + ###### Last volume level from Home Assistant ###### - id: last_volume_level type: uint @@ -1281,7 +1285,13 @@ switch: number: 4 inverted: true restore_mode: ALWAYS_ON - # internal: true + internal: false + on_turn_on: + - lambda: |- + if (id(boot_sequence_completed)) boot_sequence->execute(); + on_turn_off: + - lambda: |- + nextion_init->publish_state(false); ##### Relay Local control ##### - name: ${device_name} Relay 1 Local @@ -2529,7 +2539,7 @@ script: {"type", "boot"}, {"step", "start"} }); - delay(1000); + if (!id(boot_sequence_completed)) delay(1000); // Set dimming values display_brightness->publish_state(id(display_brightness_global)); display_dim_brightness->publish_state(id(display_dim_brightness_global)); @@ -2556,6 +2566,7 @@ script: disp1->set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str()); timer_reset_all->execute("boot"); notification_clear->execute(); + id(boot_sequence_completed) = true; ESP_LOGD(TAG, "Boot sequence finished!"); - id: notification_clear From feacca7391527c48ae40e4a4f95803d8e6951c9c Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 24 Nov 2023 18:22:03 +0100 Subject: [PATCH 4/8] Wait for display setup when turning on --- nspanel_esphome_core.yaml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index 080e370..6c309e9 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -345,8 +345,10 @@ api: disp1->set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str()); - wait_until: condition: - - lambda: |- - return (id(boot_sequence_completed) or current_page->state != "boot"); + - not: + - text_sensor.state: # Avoid this being called twice by multiple boot triggers + id: current_page + state: 'boot' timeout: 2s - if: condition: @@ -1287,9 +1289,18 @@ switch: restore_mode: ALWAYS_ON internal: false on_turn_on: + - logger.log: screen_power turn-on + - wait_until: + condition: + - lambda: !lambda return disp1->is_setup(); + timeout: 20s - lambda: |- - if (id(boot_sequence_completed)) boot_sequence->execute(); + if (id(boot_sequence_completed)) { + nextion_init->publish_state(true); + disp1->goto_page(wakeup_page_name->state.c_str()); + } on_turn_off: + - logger.log: screen_power turn-off - lambda: |- nextion_init->publish_state(false); @@ -2508,6 +2519,7 @@ script: - lambda: |- static const char *const TAG = "script.boot_sequence"; ESP_LOGD(TAG, "Starting boot sequence"); + id(boot_sequence_completed) = false; ESP_LOGD(TAG, "Wait for TFT version"); - wait_until: - lambda: !lambda return !id(version_tft).empty(); From 18078ca1c03db711878306c0834066f68fcc5b05 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 24 Nov 2023 18:33:09 +0100 Subject: [PATCH 5/8] Rename switch to "Nextion display - Power" --- ReleaseNotes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 6dd3139..f41bf9c 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -93,7 +93,7 @@ packages: - 4.1.2 patch: - Fix light icon color not being used for buttons - Add option to wake-up to Climate page - - New switch "Screen Power" which can turn the screen on/off + - New switch "Nextion display - Power" which can turn the screen on/off   ## Details of noteworthy changes @@ -158,7 +158,7 @@ See here: https://github.com/Blackymas/NSPanel_HA_Blueprint/labels/roadmap - Display current temperature on buttons even when climate is off (#1268) - Button pages shows entity's icon when available (#1269) - Home page buttons shows entity's icon when available (#1276) - - New switch "Screen Power" which can turn the screen on/off (#1327) + - New switch "Nextion display - Power" which can turn the screen on/off (#1327) ## New Contributors @misery From 8b5d7bfb058da799e0113fe58acb8fa409430e44 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 24 Nov 2023 18:33:55 +0100 Subject: [PATCH 6/8] Move "Nextion display - Power" to Diagnostic and disabled --- nspanel_esphome_core.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index 6c309e9..22190ad 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -1279,17 +1279,17 @@ switch: id: refresh_relays ##### DISPLAY ALWAYS ON ##### - - name: ${device_name} Screen Power + - name: ${device_name} Nextion display - Power platform: gpio id: screen_power - entity_category: config + entity_category: diagnostic pin: number: 4 inverted: true restore_mode: ALWAYS_ON internal: false + disabled_by_default: true on_turn_on: - - logger.log: screen_power turn-on - wait_until: condition: - lambda: !lambda return disp1->is_setup(); @@ -1300,7 +1300,6 @@ switch: disp1->goto_page(wakeup_page_name->state.c_str()); } on_turn_off: - - logger.log: screen_power turn-off - lambda: |- nextion_init->publish_state(false); From dc6bc5d04f8ecf17351a4cb1e1301e359794177b Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 24 Nov 2023 18:35:35 +0100 Subject: [PATCH 7/8] Revert back comments --- nspanel_esphome_core.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index 22190ad..fad8919 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -346,7 +346,7 @@ api: - wait_until: condition: - not: - - text_sensor.state: # Avoid this being called twice by multiple boot triggers + - text_sensor.state: # Is boot page visible? id: current_page state: 'boot' timeout: 2s From 0584b0727545e57cc10d7381476c18ff390ce2e2 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 24 Nov 2023 18:39:35 +0100 Subject: [PATCH 8/8] Remove unnecessary code --- nspanel_esphome_core.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index fad8919..7af1df8 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -2518,7 +2518,6 @@ script: - lambda: |- static const char *const TAG = "script.boot_sequence"; ESP_LOGD(TAG, "Starting boot sequence"); - id(boot_sequence_completed) = false; ESP_LOGD(TAG, "Wait for TFT version"); - wait_until: - lambda: !lambda return !id(version_tft).empty();