Remember wake-up page after power cycle

Solves #1520
This commit is contained in:
Edward Firmo
2024-01-03 23:10:22 +01:00
parent 10eed8723e
commit 5be3692ab6
3 changed files with 31 additions and 14 deletions

View File

@@ -78,6 +78,8 @@ wifi:
As multiple alarms are supported now, the system don't know which one to show on the wake-up. As multiple alarms are supported now, the system don't know which one to show on the wake-up.
11. **Changes in icon presentation.**<br> 11. **Changes in icon presentation.**<br>
As part of our efforts to standardize icons across various pages, you might notice some differences in how they appear and behave. This includes new colors for lights and climate icons, as well as the introduction of new icon designs. While many aspects can still be customized through blueprint settings, the default presentation will now adhere to this new standardized format. These changes might be a departure from what you're accustomed to in previous versions, but they aim to enhance overall consistency and user experience. As part of our efforts to standardize icons across various pages, you might notice some differences in how they appear and behave. This includes new colors for lights and climate icons, as well as the introduction of new icon designs. While many aspects can still be customized through blueprint settings, the default presentation will now adhere to this new standardized format. These changes might be a departure from what you're accustomed to in previous versions, but they aim to enhance overall consistency and user experience.
12. ***Action required:* Reset your wake-up page selection.**<br>
We've enhanced the wake-up page functionality for improved consistency after power cycles. Previously, the system didn't remember your selection following a power outage. With our latest update, this issue has been resolved. However, this improvement requires you to reselect your wake-up page one more time. Thanks for your cooperation in making these settings more reliable for everyday use.
&nbsp; &nbsp;
## Overview of noteworthy changes ## Overview of noteworthy changes

View File

@@ -1204,7 +1204,7 @@ select:
- "NSPanel US (CJK languages)" - "NSPanel US (CJK languages)"
- "NSPanel US Landscape (CJK languages)" - "NSPanel US Landscape (CJK languages)"
initial_option: "Use nextion_update_url" initial_option: "Use nextion_update_url"
optimistic: false optimistic: true
restore_value: true restore_value: true
internal: false internal: false
entity_category: config entity_category: config
@@ -1222,7 +1222,7 @@ select:
- "beta" - "beta"
- "dev" - "dev"
initial_option: "main" initial_option: "main"
optimistic: false optimistic: true
restore_value: true restore_value: true
internal: false internal: false
entity_category: config entity_category: config

View File

@@ -37,6 +37,9 @@ esphome:
static const char *const TAG = "on_boot"; static const char *const TAG = "on_boot";
ESP_LOGD(TAG, "After boot check-up starting"); ESP_LOGD(TAG, "After boot check-up starting");
set_baud_rate->execute(stoi(baud_rate->state), true); set_baud_rate->execute(stoi(baud_rate->state), true);
- select.set:
id: wakeup_page_name
option: !lambda return id(page_names)[id(wakeup_page_id)].c_str();
on_shutdown: on_shutdown:
then: then:
- switch.turn_off: screen_power - switch.turn_off: screen_power
@@ -455,12 +458,12 @@ api:
reset_timer: bool reset_timer: bool
then: then:
- lambda: |- - lambda: |-
if (current_page->state == "screensaver") disp1->goto_page(wakeup_page_name->state.c_str()); if (current_page->state == "screensaver") disp1->goto_page(id(wakeup_page_id));
if (reset_timer) if (reset_timer)
timer_reset_all->execute(wakeup_page_name->state.c_str()); timer_reset_all->execute(id(page_names)[id(wakeup_page_id)].c_str());
else { else {
timer_sleep->execute(wakeup_page_name->state.c_str(), int(timeout_sleep->state)); timer_sleep->execute(id(page_names)[id(wakeup_page_id)].c_str(), int(timeout_sleep->state));
timer_dim->execute(wakeup_page_name->state.c_str(), int(timeout_dim->state)); timer_dim->execute(id(page_names)[id(wakeup_page_id)].c_str(), int(timeout_dim->state));
} }
#### Service to set the entities #### #### Service to set the entities ####
@@ -719,6 +722,11 @@ display:
##### START - GLOBALS CONFIGURATION ##### ##### START - GLOBALS CONFIGURATION #####
globals: globals:
##### Wake-up page id #####
- id: wakeup_page_id
type: uint
restore_value: true
initial_value: '0'
##### Wi-Fi timeout ##### ##### Wi-Fi timeout #####
- id: wifi_timeout - id: wifi_timeout
@@ -1248,11 +1256,15 @@ select:
- qrcode - qrcode
initial_option: home initial_option: home
optimistic: true optimistic: true
restore_value: true restore_value: false
internal: false internal: false
entity_category: config entity_category: config
icon: mdi:page-next-outline icon: mdi:page-next-outline
set_action: set_action:
- lambda: |-
static const char *const TAG = "select.wakeup_page_name";
ESP_LOGD(TAG, "New wake-up page selected: %s", x.c_str());
set_page_id->execute("wakeup_page_id", x.c_str());
- script.execute: page_screensaver - script.execute: page_screensaver
##### START - SENSOR CONFIGURATION ##### ##### START - SENSOR CONFIGURATION #####
@@ -1441,7 +1453,7 @@ switch:
- lambda: |- - lambda: |-
if (id(setup_sequence_completed)) { if (id(setup_sequence_completed)) {
nextion_init->publish_state(disp1->is_setup()); nextion_init->publish_state(disp1->is_setup());
disp1->goto_page(wakeup_page_name->state.c_str()); disp1->goto_page(id(wakeup_page_id));
} }
on_turn_off: on_turn_off:
- lambda: |- - lambda: |-
@@ -1869,9 +1881,9 @@ script:
- rtttl.play: - rtttl.play:
rtttl: 'two short:d=4,o=5,b=100:16e6,16e6' rtttl: 'two short:d=4,o=5,b=100:16e6,16e6'
- lambda: |- - lambda: |-
ESP_LOGD("script.global_settings", "Jump to wake-up page: %s", wakeup_page_name->state.c_str()); ESP_LOGD("script.global_settings", "Jump to wake-up page: %s", id(page_names)[id(wakeup_page_id)].c_str());
disp1->goto_page(wakeup_page_name->state.c_str()); disp1->goto_page(id(wakeup_page_id));
timer_reset_all->execute(wakeup_page_name->state.c_str()); timer_reset_all->execute(id(page_names)[id(wakeup_page_id)].c_str());
- lambda: |- - lambda: |-
ESP_LOGV("script.global_settings", "Finished"); ESP_LOGV("script.global_settings", "Finished");
@@ -2202,7 +2214,7 @@ script:
if (current_page->state == "screensaver" and not id(is_uploading_tft)) { if (current_page->state == "screensaver" and not id(is_uploading_tft)) {
static const char *const TAG = "script.page_screensaver"; static const char *const TAG = "script.page_screensaver";
ESP_LOGV(TAG, "Updating screensaver page"); ESP_LOGV(TAG, "Updating screensaver page");
set_page_id->execute("back_page_id", wakeup_page_name->state.c_str()); disp1->send_command_printf("back_page_id=%i", id(wakeup_page_id));
set_component_color->execute("screensaver.text",id(screensaver_display_time_color)); set_component_color->execute("screensaver.text",id(screensaver_display_time_color));
refresh_datetime->execute(); refresh_datetime->execute();
} }
@@ -2573,7 +2585,10 @@ script:
uint detected_page_id = pageIndex(page.c_str()); uint detected_page_id = pageIndex(page.c_str());
ESP_LOGV(TAG, "%s=%i", variable.c_str(), detected_page_id); ESP_LOGV(TAG, "%s=%i", variable.c_str(), detected_page_id);
disp1->send_command_printf("%s=%i", variable.c_str(), detected_page_id); if (variable == "wakeup_page_id")
id(wakeup_page_id) = detected_page_id;
else
disp1->send_command_printf("%s=%i", variable.c_str(), detected_page_id);
- id: setup_sequence - id: setup_sequence
mode: restart mode: restart
@@ -2720,7 +2735,7 @@ script:
state: boot state: boot
timeout: 10s timeout: 10s
- lambda: |- - lambda: |-
if (current_page->state == "boot") disp1->goto_page(wakeup_page_name->state.c_str()); if (current_page->state == "boot") disp1->goto_page(id(wakeup_page_id));
else: # Unknown TFT else: # Unknown TFT
- lambda: |- - lambda: |-
static const char *const TAG = "script.setup_sequence"; static const char *const TAG = "script.setup_sequence";