Do not update climate entity when page home is refreshed

Solves #1530
This commit is contained in:
Edward Firmo
2024-01-04 15:33:06 +01:00
parent fe124dfe9c
commit 77a2ab7c46
5 changed files with 110 additions and 57 deletions

View File

@@ -141,6 +141,8 @@ We still working on the Upload TFT engine to make it easier for new and for expe
If you have issues with the remote file and want to transfer it from your local server just as before, simply select **Use nextion_update_url** in **Update TFT Display - Model**.
And you also can use the `esphome.xxxxx_upload_tft_url` service to upload using an alternative URL without the need of flash your panel again.
#### Alternative baud rate for TFT uploads
You can select an alternative baud rate for your TFT uploads. This allows faster TFT uploads and also supports displays previously set with baud rates not supported by this project (currently 115200 bps and 921600 bps).

View File

@@ -47,7 +47,7 @@ climate:
internal: false
on_state:
- lambda: |-
static const char *const TAG = "climate.thermostat_embedded.on_state";
static const char *const TAG = "addon_climate_base.climate.thermostat_embedded.on_state";
ESP_LOGD(TAG, "Starting");
page_climate->execute();
page_home->execute();
@@ -129,12 +129,12 @@ script:
);
// Update target temp icon
update_climate_icon->execute("climate.target_icon", int(thermostat_embedded->action), int(thermostat_embedded->mode));
update_climate_icon->execute("target_icon", int(thermostat_embedded->action), int(thermostat_embedded->mode));
// Update buttons bar
// Hide not supported hotspots
disp1->hide_component("button01");
if (${addon_climate_dual}) disp1->hide_component("button02");
if (${addon_climate_dual}) disp1->show_component("button02"); else disp1->hide_component("button02");
if (${addon_climate_heat} or ${addon_climate_dual}) disp1->show_component("button03"); else disp1->hide_component("button03"); //Heat
if (${addon_climate_cool} or ${addon_climate_dual}) disp1->show_component("button04"); else disp1->hide_component("button04"); //Cool
disp1->hide_component("button05");
@@ -158,9 +158,6 @@ script:
- id: !extend page_home
then:
- lambda: |-
// Update home.climate_entity variable
detailed_entity->publish_state((id(is_embedded_thermostat)) ? "embedded_climate" : "");
disp1->set_component_value("climate.embedded", (id(is_embedded_thermostat)) ? 1 : 0);
// Update chips
if (id(is_embedded_thermostat))
id(update_climate_icon).execute("home.icon_top_03", int(thermostat_embedded->action), int(thermostat_embedded->mode));

View File

@@ -65,20 +65,6 @@ display:
tft_url: ${nextion_update_url}
exit_reparse_on_start: true
esphome:
on_boot:
- priority: 605.0
then:
- lambda: |-
static const char *const TAG = "addon_upload_tft.esphome.on_boot";
ESP_LOGD(TAG, "Restoring TFT file selectors");
- select.set_index:
id: tft_file_branch
index: !lambda return id(tft_branch);
- select.set_index:
id: tft_file_model
index: !lambda return id(tft_model);
globals:
- id: baud_rate_original
type: uint
@@ -210,17 +196,38 @@ script:
App.feed_wdt();
}
- id: !extend restore_settings
mode: restart
then:
- lambda: |-
static const char *const TAG = "addon_upload_tft.script.restore_settings";
ESP_LOGD(TAG, "Restoring TFT file branch selector to index %i", 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 %i", 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
then:
- delay: 2s
- lambda: |-
static const char *const TAG = "addon_upload_tft.script.set_tft_file";
std::string model = tft_file_model->state;
std::string branch = tft_file_branch->state;
ESP_LOGD(TAG, "A new TFT was selected:");
ESP_LOGD(TAG, " Model: %s", model.c_str());
std::string model = tft_file_model->state;
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_uploading_tft))
ESP_LOGW(TAG, "TFT Upload in progress.");
else {
@@ -1220,6 +1227,23 @@ script:
- script.wait: report_upload_progress
select:
- id: tft_file_branch
name: ${device_name} Update TFT display - Branch
platform: template
options:
- "main"
- "beta"
- "dev"
initial_option: "main"
optimistic: true
restore_value: true
internal: false
entity_category: config
disabled_by_default: true
icon: mdi:file-sync
set_action:
- script.execute: set_tft_file
- id: tft_file_model
name: ${device_name} Update TFT display - Model
platform: template
@@ -1234,34 +1258,13 @@ select:
- "NSPanel US Landscape (CJK languages)"
initial_option: "Use nextion_update_url"
optimistic: true
restore_value: false
restore_value: true
internal: false
entity_category: config
disabled_by_default: false
icon: mdi:file-sync
set_action:
- lambda: |-
if (tft_file_model->active_index().has_value()) id(tft_model) = tft_file_model->active_index().value();
set_tft_file->execute();
- id: tft_file_branch
name: ${device_name} Update TFT display - Branch
platform: template
options:
- "main"
- "beta"
- "dev"
initial_option: "main"
optimistic: true
restore_value: false
internal: false
entity_category: config
disabled_by_default: true
icon: mdi:file-sync
set_action:
- lambda: |-
if (tft_file_branch->active_index().has_value()) id(tft_branch) = tft_file_branch->active_index().value();
set_tft_file->execute();
- script.execute: set_tft_file
sensor:
- id: !extend display_mode

View File

@@ -34,13 +34,8 @@ esphome:
on_boot:
- priority: 600.0 # This is where most sensors are set up.
then:
- lambda: |-
static const char *const TAG = "esphome.on_boot";
ESP_LOGD(TAG, "After boot check-up starting");
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();
- script.execute: restore_settings
on_shutdown:
then:
- switch.turn_off: screen_power
@@ -507,6 +502,21 @@ api:
then:
- lambda: |-
static const char *const TAG = "service.page_home";
ESP_LOGV(TAG, "date_color: %i", date_color);
ESP_LOGV(TAG, "time_format: %s", time_format.c_str());
ESP_LOGV(TAG, "time_color: %i", time_color);
ESP_LOGV(TAG, "meridiem: %i", meridiem.size());
ESP_LOGV(TAG, "chip_font_size: %i", chip_font_size);
ESP_LOGV(TAG, "custom_buttons_font_size: %i", custom_buttons_font_size);
ESP_LOGV(TAG, "notification_icon: %s", notification_icon.c_str());
ESP_LOGV(TAG, "notification_icon_color_normal: %i", notification_icon_color_normal.size());
ESP_LOGV(TAG, "notification_icon_color_unread: %i", notification_icon_color_unread.size());
ESP_LOGV(TAG, "qrcode: %s", qrcode ? "True" : "False");
ESP_LOGV(TAG, "qrcode_icon: %s", qrcode_icon.c_str());
ESP_LOGV(TAG, "qrcode_icon_color: %i", qrcode_icon_color.size());
ESP_LOGV(TAG, "entities_pages: %s", entities_pages ? "True" : "False");
ESP_LOGV(TAG, "entities_pages_icon: %s", entities_pages_icon.c_str());
ESP_LOGV(TAG, "entities_pages_icon_color: %i", entities_pages_icon_color.size());
// Localization
ESP_LOGV(TAG, "Load localization");
@@ -747,6 +757,18 @@ globals:
restore_value: false
initial_value: 'false'
##### Is global settings loaded #####
- id: is_global_settings_loaded
type: bool
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
@@ -1257,7 +1279,7 @@ select:
- qrcode
initial_option: home
optimistic: true
restore_value: false
restore_value: true
internal: false
entity_category: config
icon: mdi:page-next-outline
@@ -1265,6 +1287,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
@@ -1392,8 +1415,14 @@ switch:
optimistic: true
restore_mode: ALWAYS_OFF
on_turn_on:
- wait_until:
condition:
- lambda: !lambda return id(is_global_settings_loaded);
- lambda: set_component_color->execute("home.bt_notific", id(home_notify_icon_color_unread));
on_turn_off:
- wait_until:
condition:
- lambda: !lambda return id(is_global_settings_loaded);
- lambda: set_component_color->execute("home.bt_notific", id(home_notify_icon_color_normal));
##### Notification sound #####
@@ -1841,6 +1870,7 @@ script:
id(screensaver_display_time_color) = screensaver_time_color;
page_screensaver->execute();
id(is_global_settings_loaded) = true;
id(is_blueprint_updated) = true;
disp1->send_command_printf("api=1");
@@ -2304,6 +2334,9 @@ script:
- id: refresh_notification
mode: restart
then:
- wait_until:
condition:
- lambda: !lambda return id(setup_sequence_completed);
- lambda: |-
bool is_notification = (notification_text->state.empty() and notification_label->state.empty());
disp1->send_command_printf("is_notification=%i", is_notification ? 0 : 1);
@@ -2376,6 +2409,24 @@ script:
id(home_relay2_icon_color) = relay2_icon_color;
ESP_LOGV(TAG, "Finished");
- id: restore_settings
mode: restart
then:
- lambda: |-
static const char *const TAG = "script.restore_settings";
ESP_LOGD(TAG, "Restoring settings");
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, "Finishing");
id(is_restored_settings) = true;
- id: service_call_alarm_control_panel
mode: restart
parameters:
@@ -2556,8 +2607,8 @@ script:
}
else if (foreground.size() == 1) fg565 = foreground[0];
else {
ESP_LOGW(TAG, " Component: %s", component.c_str());
ESP_LOGW(TAG, " Foreground size: %i", foreground.size());
ESP_LOGE(TAG, " Component: %s", component.c_str());
ESP_LOGE(TAG, " Foreground size: %i", foreground.size());
fg565 = -1;
}
ESP_LOGVV(TAG, " Foreground: %i", fg565);

Binary file not shown.