Dual target climate page

- Solves #909
- Partially solves #1486
- Solves #1481
- Solves #1459
- Solves #1006
- Solves #1106
This commit is contained in:
Edward Firmo
2024-01-01 22:04:51 +01:00
parent 35b0c23be8
commit f09021d859
33 changed files with 592 additions and 794 deletions

View File

@@ -14,7 +14,7 @@ substitutions:
ota_password: ${wifi_password}
ap_password: ${wifi_password}
##### DON'T CHANGE THIS ######
version: "4.2dev.3"
version: "4.2dev.4"
##############################
##### External components #####
@@ -359,6 +359,7 @@ api:
embedded_indoor_temperature: bool
temperature_unit_is_fahrenheit: bool
mui_please_confirm: string
mui_unavailable: string
screensaver_time: bool
screensaver_time_color: int[]
then:
@@ -370,6 +371,7 @@ api:
embedded_indoor_temperature: !lambda "return embedded_indoor_temperature;"
temperature_unit_is_fahrenheit: !lambda "return temperature_unit_is_fahrenheit;"
mui_please_confirm: !lambda "return mui_please_confirm;"
mui_unavailable: !lambda "return mui_unavailable;"
screensaver_time: !lambda "return screensaver_time;"
screensaver_time_color: !lambda "return screensaver_time_color;"
@@ -434,7 +436,11 @@ api:
- service: set_climate
variables:
current_temp: float
supported_features: int
supported_hvac_modes: int
target_temp: float
target_temp_high: float
target_temp_low: float
temp_step: int
total_steps: int
temp_offset: int
@@ -447,7 +453,11 @@ api:
- script.execute:
id: set_climate
current_temp: !lambda "return current_temp;"
supported_features: !lambda "return supported_features;"
supported_hvac_modes: !lambda "return supported_hvac_modes;"
target_temp: !lambda "return target_temp;"
target_temp_high: !lambda "return target_temp_high;"
target_temp_low: !lambda "return target_temp_low;"
temp_step: !lambda "return temp_step;"
total_steps: !lambda "return total_steps;"
temp_offset: !lambda "return temp_offset;"
@@ -869,6 +879,16 @@ globals:
restore_value: false
initial_value: '{"AM", "PM"}'
#### MUI strings ####
- id: mui_please_confirm_global
type: std::string
restore_value: true
initial_value: '"Please confirm"'
- id: mui_unavailable_global
type: std::string
restore_value: true
initial_value: '"Unavailable"'
##### Chips #####
- id: home_chip_font_size
type: uint
@@ -1832,6 +1852,7 @@ script:
embedded_indoor_temperature: bool
temperature_unit_is_fahrenheit: bool
mui_please_confirm: string
mui_unavailable: string
screensaver_time: bool
screensaver_time_color: int[]
then:
@@ -1852,9 +1873,9 @@ script:
id(temp_unit_fahrenheit) = temperature_unit_is_fahrenheit;
display_embedded_temp->execute();
// Confirm page
ESP_LOGV(TAG, "Setup confirm page");
display_wrapped_text->execute("confirm.title", mui_please_confirm.c_str(), 15);
// MUI strings
id(mui_please_confirm_global) = mui_please_confirm;
id(mui_unavailable_global) = mui_unavailable;
// Screen saver page (sleep)
ESP_LOGV(TAG, "Setup screensaver page");
@@ -2154,7 +2175,9 @@ script:
- id: page_confirm
mode: restart
then: # There's nothing here so far
then:
- lambda: |-
if (not id(is_uploading_tft)) display_wrapped_text->execute("confirm.title", id(mui_please_confirm_global).c_str(), 15);
- id: page_cover
mode: restart
@@ -2475,11 +2498,15 @@ script:
disp1->set_backlight_brightness(static_cast<float>(brightness) / 100.0f);
id(display_last_brightness) = brightness;
- id: set_climate
- id: set_climate #DEBUG
mode: restart
parameters:
current_temp: float
supported_features: int
supported_hvac_modes: int
target_temp: float
target_temp_high: float
target_temp_low: float
temp_step: uint
total_steps: uint
temp_offset: int
@@ -2487,43 +2514,63 @@ script:
embedded_climate: bool
then:
- lambda: |-
if (id(is_uploading_tft)) set_climate->stop();
static const char *const TAG = "script.set_climate";
ESP_LOGV(TAG, "Starting");
ESP_LOGV(TAG, " current_temp: %f", current_temp);
ESP_LOGV(TAG, " target_temp: %f", target_temp);
ESP_LOGV(TAG, " temp_step: %d", temp_step);
ESP_LOGV(TAG, " total_steps: %d", total_steps);
ESP_LOGV(TAG, " temp_offset: %i", temp_offset);
ESP_LOGV(TAG, " climate_icon: %s", climate_icon.c_str());
ESP_LOGV(TAG, " embedded_climate: %s", embedded_climate ? "True" : "False");
ESP_LOGV(TAG, " current_temp: %f", current_temp);
ESP_LOGV(TAG, " supported_features: %i", supported_features);
ESP_LOGV(TAG, " supported_hvac_modes: %i", supported_hvac_modes);
ESP_LOGV(TAG, " target_temp: %f", target_temp);
ESP_LOGV(TAG, " target_temp_high: %f", target_temp_high);
ESP_LOGV(TAG, " target_temp_low: %f", target_temp_low);
ESP_LOGV(TAG, " temp_step: %d", temp_step);
ESP_LOGV(TAG, " total_steps: %d", total_steps);
ESP_LOGV(TAG, " temp_offset: %i", temp_offset);
ESP_LOGV(TAG, " climate_icon: %s", climate_icon.c_str());
ESP_LOGV(TAG, " embedded_climate: %s", embedded_climate ? "True" : "False");
if (current_page->state == "climate") {
ESP_LOGV(TAG, "Page climate is visible");
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);
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");
}
if (current_temp > -999)
disp1->set_component_text_printf("current_temp", "%.1f°", current_temp);
else
{
disp1->hide_component("target_icon");
disp1->hide_component("target_temp");
disp1->hide_component("climateslider");
disp1->hide_component("decrease_temp");
disp1->hide_component("increase_temp");
}
disp1->set_component_text_printf("current_temp", id(mui_unavailable_global).c_str());
disp1->set_component_value("hvac_modes", supported_hvac_modes);
if (supported_hvac_modes & 1) { // Heat
if (target_temp_high <= -999 and target_temp > -999) target_temp_high = target_temp;
disp1->set_component_text_printf("target_temp_high", "%.1f°", target_temp_high);
disp1->show_component("target_temp_high");
disp1->set_component_value("slider_high", round(((10*target_temp_high) - temp_offset) / temp_step));
disp1->show_component("slider_high");
} else {
disp1->hide_component("target_temp_high");
disp1->hide_component("slider_high");
}
if (supported_hvac_modes & 2) { // Cool
if (target_temp_low <= -999 and target_temp > -999) target_temp_low = target_temp;
disp1->set_component_text_printf("target_temp_low", "%.1f°", target_temp_low);
disp1->show_component("target_temp_low");
disp1->set_component_value("slider_low", round(((10*target_temp_low) - temp_offset) / temp_step));
disp1->show_component("slider_low");
} else {
disp1->hide_component("target_temp_low");
disp1->hide_component("slider_low");
}
if (supported_hvac_modes > 0) {
disp1->set_component_text_printf("target_icon", "%s", climate_icon.c_str());
disp1->show_component("target_icon");
disp1->show_component("decrease_temp");
disp1->show_component("increase_temp");
} else {
disp1->hide_component("target_icon");
disp1->hide_component("decrease_temp");
disp1->hide_component("increase_temp");
}
disp1->set_component_value("embedded", (embedded_climate) ? 1 : 0);
}
ESP_LOGV(TAG, "Finished");