Reduce variables stored to flash
This commit is contained in:
@@ -90,20 +90,20 @@ globals:
|
||||
restore_value: false
|
||||
initial_value: ${upload_tft_baud_rate}
|
||||
|
||||
- id: tft_branch
|
||||
type: uint
|
||||
restore_value: true
|
||||
initial_value: '0'
|
||||
#- id: tft_branch
|
||||
# type: uint
|
||||
# restore_value: true
|
||||
# initial_value: '0'
|
||||
|
||||
- id: tft_is_valid
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
|
||||
- id: tft_model
|
||||
type: uint
|
||||
restore_value: true
|
||||
initial_value: '0'
|
||||
#- id: tft_model
|
||||
# type: uint
|
||||
# restore_value: true
|
||||
# initial_value: '0'
|
||||
|
||||
- id: tft_upload_attempt
|
||||
type: uint
|
||||
@@ -216,15 +216,15 @@ script:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "addon_upload_tft.script.restore_settings";
|
||||
|
||||
ESP_LOGD(TAG, "Restoring TFT file branch selector to index %u", id(tft_branch));
|
||||
auto tft_file_branch_call = id(tft_file_branch).make_call();
|
||||
tft_file_branch_call.set_index(id(tft_branch));
|
||||
tft_file_branch_call.perform();
|
||||
// ESP_LOGD(TAG, "Restoring TFT file branch selector to index %u", id(tft_branch));
|
||||
// auto tft_file_branch_call = id(tft_file_branch).make_call();
|
||||
// tft_file_branch_call.set_index(id(tft_branch));
|
||||
// tft_file_branch_call.perform();
|
||||
|
||||
ESP_LOGD(TAG, "Restoring TFT file model selector to index %u", id(tft_model));
|
||||
auto tft_file_model_call = id(tft_file_model).make_call();
|
||||
tft_file_model_call.set_index(id(tft_model));
|
||||
tft_file_model_call.perform();
|
||||
// ESP_LOGD(TAG, "Restoring TFT file model selector to index %u", id(tft_model));
|
||||
// auto tft_file_model_call = id(tft_file_model).make_call();
|
||||
// tft_file_model_call.set_index(id(tft_model));
|
||||
// tft_file_model_call.perform();
|
||||
|
||||
- id: set_tft_file
|
||||
mode: restart
|
||||
@@ -241,10 +241,10 @@ script:
|
||||
ESP_LOGD(TAG, "TFT URL set:");
|
||||
ESP_LOGD(TAG, " Branch: %s", branch.c_str());
|
||||
ESP_LOGD(TAG, " Model: %s", model.c_str());
|
||||
if (id(is_restored_settings) and tft_file_branch->active_index().has_value())
|
||||
id(tft_branch) = tft_file_branch->active_index().value();
|
||||
if (id(is_restored_settings) and tft_file_model->active_index().has_value())
|
||||
id(tft_model) = tft_file_model->active_index().value();
|
||||
// if (id(is_restored_settings) and tft_file_branch->active_index().has_value())
|
||||
// id(tft_branch) = tft_file_branch->active_index().value();
|
||||
// if (id(is_restored_settings) and tft_file_model->active_index().has_value())
|
||||
// id(tft_model) = tft_file_model->active_index().value();
|
||||
|
||||
if (id(is_uploading_tft))
|
||||
ESP_LOGW(TAG, " TFT Upload in progress.");
|
||||
@@ -1227,7 +1227,7 @@ select:
|
||||
- "dev"
|
||||
initial_option: "v${version}"
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
restore_value: false
|
||||
internal: true
|
||||
entity_category: config
|
||||
disabled_by_default: true
|
||||
|
||||
@@ -453,12 +453,12 @@ api:
|
||||
reset_timer: bool
|
||||
then:
|
||||
- lambda: |-
|
||||
if (current_page->state == "screensaver") disp1->goto_page(id(wakeup_page_id));
|
||||
if (current_page->state == "screensaver") disp1->goto_page(wakeup_page_name->state.c_str());
|
||||
if (reset_timer)
|
||||
timer_reset_all->execute(id(page_names)[id(wakeup_page_id)].c_str());
|
||||
timer_reset_all->execute(wakeup_page_name->state.c_str());
|
||||
else {
|
||||
timer_sleep->execute(id(page_names)[id(wakeup_page_id)].c_str(), int(timeout_sleep->state));
|
||||
timer_dim->execute(id(page_names)[id(wakeup_page_id)].c_str(), int(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 ####
|
||||
@@ -732,12 +732,6 @@ display:
|
||||
|
||||
##### START - GLOBALS CONFIGURATION #####
|
||||
globals:
|
||||
##### Wake-up page id #####
|
||||
- id: wakeup_page_id
|
||||
type: uint
|
||||
restore_value: true
|
||||
initial_value: '0'
|
||||
|
||||
##### Wi-Fi timeout #####
|
||||
- id: wifi_timeout
|
||||
type: uint
|
||||
@@ -762,12 +756,6 @@ globals:
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
|
||||
##### Is settings restored ####
|
||||
- id: is_restored_settings
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
|
||||
##### Is boot sequence completed? #####
|
||||
- id: setup_sequence_completed
|
||||
type: bool
|
||||
@@ -937,6 +925,11 @@ globals:
|
||||
"confirm"
|
||||
}'
|
||||
|
||||
- id: framework
|
||||
type: uint8_t
|
||||
restore_value: false
|
||||
initial_value: '0' # 0 = unknown, 1 = Arduino, 2 = ESP-IDF
|
||||
|
||||
##### START - BINARY SENSOR CONFIGURATION #####
|
||||
binary_sensor:
|
||||
|
||||
@@ -1073,11 +1066,32 @@ binary_sensor:
|
||||
|
||||
##### START - BUTTON CONFIGURATION #####
|
||||
button:
|
||||
###### Factory Reset button #####
|
||||
- name: ${name} Factory reset
|
||||
platform: factory_reset
|
||||
id: nspanel_factory_reset
|
||||
internal: false
|
||||
disabled_by_default: true
|
||||
icon: mdi:restart-alert
|
||||
|
||||
###### REBOOT BUTTON #####
|
||||
- name: ${name} Restart
|
||||
platform: restart
|
||||
id: restart_nspanel
|
||||
|
||||
###### Power cycle Nextion Display ######
|
||||
- name: ${name} Nextion display - Power cycle
|
||||
id: screen_power_cycle
|
||||
platform: template
|
||||
internal: false
|
||||
disabled_by_default: true
|
||||
icon: mdi:power-cycle
|
||||
entity_category: diagnostic
|
||||
on_press:
|
||||
- switch.turn_off: screen_power
|
||||
- delay: 1s
|
||||
- switch.turn_on: screen_power
|
||||
|
||||
##### START - NUMBER CONFIGURATION #####
|
||||
number:
|
||||
##### SCREEN BRIGHTNESS #####
|
||||
@@ -1270,9 +1284,7 @@ select:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "select.wakeup_page_name";
|
||||
ESP_LOGD(TAG, "New wake-up page selected: %s", x.c_str());
|
||||
if (id(is_restored_settings))
|
||||
set_page_id->execute("wakeup_page_id", x.c_str());
|
||||
- script.execute: page_screensaver
|
||||
page_screensaver->execute();
|
||||
|
||||
##### START - SENSOR CONFIGURATION #####
|
||||
sensor:
|
||||
@@ -1488,7 +1500,7 @@ switch:
|
||||
- lambda: |-
|
||||
if (id(setup_sequence_completed)) {
|
||||
nextion_init->publish_state(disp1->is_setup());
|
||||
disp1->goto_page(id(wakeup_page_id));
|
||||
disp1->goto_page(wakeup_page_name->state.c_str());
|
||||
}
|
||||
on_turn_off:
|
||||
- lambda: |-
|
||||
@@ -1521,6 +1533,26 @@ switch:
|
||||
##### START - TEXT SENSOR CONFIGURATION #####
|
||||
text_sensor:
|
||||
|
||||
##### Device name - Used for the Blueprint to identify service names when device is renamed
|
||||
- id: device_name
|
||||
name: ${name} Device name
|
||||
internal: false
|
||||
platform: template
|
||||
lambda: |-
|
||||
return {"${name}"};
|
||||
filters:
|
||||
- to_lower:
|
||||
- lambda: |-
|
||||
std::replace(x.begin(), x.end(), ' ', '_');
|
||||
return x;
|
||||
- substitute:
|
||||
- "- -> _"
|
||||
- "___ -> _"
|
||||
- "__ -> _"
|
||||
- "__ -> _"
|
||||
- "__ -> _"
|
||||
- "__ -> _"
|
||||
|
||||
##### Entity Id of the entity displayed on the detailed pages
|
||||
- name: ${name} Detailed Entity
|
||||
id: detailed_entity
|
||||
@@ -1938,9 +1970,9 @@ script:
|
||||
- rtttl.play:
|
||||
rtttl: 'two short:d=4,o=5,b=100:16e6,16e6'
|
||||
- lambda: |-
|
||||
ESP_LOGD("script.global_settings", "Jump to wake-up page: %s", id(page_names)[id(wakeup_page_id)].c_str());
|
||||
disp1->goto_page(id(wakeup_page_id));
|
||||
timer_reset_all->execute(id(page_names)[id(wakeup_page_id)].c_str());
|
||||
ESP_LOGD("script.global_settings", "Jump to wake-up page: %s", wakeup_page_name->state.c_str());
|
||||
disp1->goto_page(wakeup_page_name->state.c_str());
|
||||
timer_reset_all->execute(wakeup_page_name->state.c_str());
|
||||
|
||||
- lambda: |-
|
||||
ESP_LOGV("script.global_settings", "Finished");
|
||||
@@ -2051,14 +2083,9 @@ script:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "script.page_blank";
|
||||
ESP_LOGV(TAG, "Construct blank page");
|
||||
std::string framework = "unknown";
|
||||
#ifdef ARDUINO
|
||||
framework = "arduino";
|
||||
#elif defined(USE_ESP_IDF)
|
||||
framework = "esp-idf";
|
||||
#endif
|
||||
disp1->set_component_text_printf("esp_version", "ESP: ${version}"); // ESPHome version
|
||||
disp1->set_component_text_printf("framework", framework.c_str()); // ESPHome framework
|
||||
disp1->set_component_text_printf("framework", "%s", id(framework) == 1 ? "Arduino" :
|
||||
(id(framework) == 2 ? "ESP-IDF" : "Unknown")); // ESPHome framework
|
||||
disp1->send_command_printf("tm_esphome.en=0");
|
||||
|
||||
- id: page_boot
|
||||
@@ -2069,15 +2096,11 @@ script:
|
||||
ESP_LOGV(TAG, "Construct boot page");
|
||||
set_brightness->execute(100);
|
||||
|
||||
std::string framework = "unknown";
|
||||
#ifdef ARDUINO
|
||||
framework = "arduino";
|
||||
#elif defined(USE_ESP_IDF)
|
||||
framework = "esp-idf";
|
||||
#endif
|
||||
disp1->set_component_text_printf("esph_version", "${version}"); // ESPHome version
|
||||
disp1->set_component_text_printf("framework", framework.c_str()); // ESPHome framework
|
||||
disp1->show_component("bt_reboot");
|
||||
disp1->set_component_text_printf("esph_version", "${version}"); // ESPHome version
|
||||
disp1->set_component_text_printf("framework", "%s", id(framework) == 1 ? "Arduino" :
|
||||
(id(framework) == 2 ? "ESP-IDF" : "Unknown")); // ESPHome framework
|
||||
disp1->send_command_printf("tm_esphome.en=0");
|
||||
// disp1->show_component("bt_reboot");
|
||||
|
||||
- id: page_buttonpage
|
||||
mode: restart
|
||||
@@ -2270,7 +2293,8 @@ script:
|
||||
if (current_page->state == "screensaver" and not id(is_uploading_tft)) {
|
||||
static const char *const TAG = "script.page_screensaver";
|
||||
ESP_LOGV(TAG, "Updating screensaver page");
|
||||
disp1->send_command_printf("back_page_id=%i", id(wakeup_page_id));
|
||||
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));
|
||||
if (id(screensaver_display_time)) {
|
||||
disp1->show_component("text");
|
||||
set_component_color->execute("screensaver.text",id(screensaver_display_time_color));
|
||||
@@ -2445,16 +2469,22 @@ script:
|
||||
static const char *const TAG = "script.restore_settings";
|
||||
ESP_LOGD(TAG, "Restoring settings");
|
||||
|
||||
#ifdef ARDUINO
|
||||
id(framework) = 1;
|
||||
#elif defined(USE_ESP_IDF)
|
||||
id(framework) = 2;
|
||||
#endif
|
||||
|
||||
ESP_LOGV(TAG, "Restoring baud rate");
|
||||
set_baud_rate->execute(stoi(baud_rate->state), true);
|
||||
|
||||
ESP_LOGV(TAG, "Restoring wake-up page selector");
|
||||
auto wakeup_page_name_call = id(wakeup_page_name).make_call();
|
||||
wakeup_page_name_call.set_option(id(page_names)[id(wakeup_page_id)]);
|
||||
wakeup_page_name_call.perform();
|
||||
// ESP_LOGV(TAG, "Restoring wake-up page selector");
|
||||
// auto wakeup_page_name_call = id(wakeup_page_name).make_call();
|
||||
// wakeup_page_name_call.set_option(id(page_names)[id(wakeup_page_id)]);
|
||||
// wakeup_page_name_call.perform();
|
||||
|
||||
// id(is_restored_settings) = true;
|
||||
ESP_LOGV(TAG, "Finishing");
|
||||
id(is_restored_settings) = true;
|
||||
|
||||
- id: service_call_alarm_control_panel
|
||||
mode: restart
|
||||
@@ -2679,10 +2709,7 @@ script:
|
||||
|
||||
uint detected_page_id = pageIndex(page.c_str());
|
||||
ESP_LOGV(TAG, "%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);
|
||||
disp1->send_command_printf("%s=%i", variable.c_str(), detected_page_id);
|
||||
|
||||
- id: setup_sequence
|
||||
mode: restart
|
||||
@@ -2829,7 +2856,7 @@ script:
|
||||
state: boot
|
||||
timeout: 10s
|
||||
- lambda: |-
|
||||
if (current_page->state == "boot") disp1->goto_page(id(wakeup_page_id));
|
||||
if (current_page->state == "boot") disp1->goto_page(wakeup_page_name->state.c_str());
|
||||
else: # Unknown TFT
|
||||
- lambda: |-
|
||||
static const char *const TAG = "script.setup_sequence";
|
||||
@@ -3200,14 +3227,15 @@ script:
|
||||
#ifdef ARDUINO
|
||||
size_t total_heap_size = ESP.getHeapSize();
|
||||
size_t free_heap_size = ESP.getFreeHeap();
|
||||
ESP_LOGI(TAG, " Heap: %zu bytes (%d%%)", free_heap_size, int(round(((float)free_heap_size / total_heap_size) * 100.0f)));
|
||||
ESP_LOGI(TAG, " Framework: arduino");
|
||||
#elif defined(USE_ESP_IDF)
|
||||
size_t total_heap_size = heap_caps_get_total_size(MALLOC_CAP_DEFAULT);
|
||||
size_t free_heap_size = esp_get_free_heap_size();
|
||||
ESP_LOGI(TAG, " Heap: %zu bytes (%d%%)", free_heap_size, int(round(((float)free_heap_size / total_heap_size) * 100.0f)));
|
||||
ESP_LOGI(TAG, " Framework: esp-idf");
|
||||
#endif
|
||||
if (total_heap_size != 0)
|
||||
ESP_LOGI(TAG, " Heap: %zu bytes (%d%%)", free_heap_size,
|
||||
int(round(((float)free_heap_size / total_heap_size) * 100.0f)));
|
||||
ESP_LOGI(TAG, " Framework: %s", id(framework) == 1 ? "Arduino" :
|
||||
(id(framework) == 2 ? "ESP-IDF" : "Unknown")); // ESPHome framework
|
||||
|
||||
// Report UART
|
||||
ESP_LOGI(TAG, "UART:");
|
||||
|
||||
Reference in New Issue
Block a user