Visual improvements on climate page
- Add friendly name when embedded - Solves https://github.com/Blackymas/NSPanel_HA_Blueprint/discussions/995#discussioncomment-6891465 - Make disable icons a bit darker - Solves https://github.com/Blackymas/NSPanel_HA_Blueprint/discussions/995#discussioncomment-6893440 - Add space for page title in EU an US Land versions - Reset page timer when pressing/releasing on the slider - Partially solves #990
This commit is contained in:
@@ -16,6 +16,11 @@ substitutions:
|
||||
temp_max: "25"
|
||||
temp_step: "0.5"
|
||||
|
||||
##### DO NOT CHANGE THIS #####
|
||||
addon_climate_cool: "true"
|
||||
addon_climate_heat: "false"
|
||||
##############################
|
||||
|
||||
climate:
|
||||
- platform: thermostat
|
||||
name: ${device_name} Thermostat
|
||||
@@ -47,6 +52,8 @@ climate:
|
||||
id: addon_climate_update_page_climate
|
||||
- logger.log: Climate state changed - End
|
||||
|
||||
###### All the code bellow this point is shared between addon_climate_cool and addon_climate_heat #####
|
||||
|
||||
globals:
|
||||
##### Is embedded thermostat set as main climate entity? #####
|
||||
- id: is_embedded_thermostat
|
||||
@@ -58,6 +65,11 @@ globals:
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
##### Embeded climate friendly name #####
|
||||
- id: addon_climate_friendly_name
|
||||
type: std::string
|
||||
restore_value: false
|
||||
initial_value: '"${device_name} Thermostat"'
|
||||
|
||||
script:
|
||||
- id: !extend addon_climate_update_page_home
|
||||
@@ -116,59 +128,56 @@ script:
|
||||
ESP_LOGV("script.addon_climate_update_page_climate", "nextion_init: %i", (id(nextion_init)) ? 1 : 0);
|
||||
ESP_LOGV("script.addon_climate_update_page_climate", "current_page: %s", id(current_page).state.c_str());
|
||||
ESP_LOGV("script.addon_climate_update_page_climate", "is_addon_climate_visible: %i", (id(is_addon_climate_visible)) ? 1 : 0);
|
||||
- if:
|
||||
condition:
|
||||
- binary_sensor.is_on: nextion_init
|
||||
- text_sensor.state: # Is climate page visible?
|
||||
id: current_page
|
||||
state: 'climate'
|
||||
- lambda: !lambda return (id(is_addon_climate_visible));
|
||||
then: # Embedded thermostat is visible
|
||||
# Update slider, current temperature & target temperature
|
||||
- script.execute:
|
||||
id: set_climate
|
||||
current_temp: !lambda "return id(thermostat_embedded).current_temperature;"
|
||||
target_temp: !lambda "return id(thermostat_embedded).target_temperature;"
|
||||
temp_step: !lambda "return int(round(${temp_step}*10));"
|
||||
total_steps: !lambda |-
|
||||
float temp_step = ${temp_step};
|
||||
float temp_offset = ${temp_min};
|
||||
float temp_max = ${temp_max};
|
||||
float total_steps = (temp_max-temp_offset)/temp_step;
|
||||
return int(round(total_steps));
|
||||
slider_val: !lambda |-
|
||||
float temp_step = ${temp_step};
|
||||
float temp_offset = ${temp_min};
|
||||
return int(round((10*id(thermostat_embedded).target_temperature-temp_offset)/temp_step));
|
||||
temp_offset: !lambda "return int(round(${temp_min}*10));"
|
||||
climate_icon: ""
|
||||
embedded_climate: True
|
||||
if (id(current_page).state == "climate" and id(is_addon_climate_visible))
|
||||
{
|
||||
id(disp1).set_component_text_printf("page_label", id(addon_climate_friendly_name).c_str());
|
||||
float temp_step = ${temp_step};
|
||||
float temp_offset = ${temp_min};
|
||||
float temp_max = ${temp_max};
|
||||
float total_steps = (temp_max-temp_offset)/temp_step;
|
||||
id(set_climate)->execute
|
||||
(
|
||||
id(thermostat_embedded).current_temperature, // current_temp
|
||||
id(thermostat_embedded).target_temperature, // target_temp
|
||||
int(round(${temp_step}*10)), // temp_step
|
||||
int(round(total_steps)), // total_steps //int(round((10*id(thermostat_embedded).target_temperature-temp_offset)/temp_step)), // slider_val
|
||||
int(round(${temp_min}*10)), // temp_offset
|
||||
"", // climate_icon
|
||||
true // embedded_climate
|
||||
);
|
||||
|
||||
# Update target temp icon
|
||||
- lambda: |-
|
||||
// Update target temp icon
|
||||
ESP_LOGV("script.addon_climate_update_page_climate", "thermostat_embedded.action=%i", int(id(thermostat_embedded).action));
|
||||
id(update_climate_icon).execute("climate.target_icon", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode));
|
||||
|
||||
# Update buttons bar
|
||||
- lambda: |-
|
||||
// Update buttons bar
|
||||
ESP_LOGV("script.addon_climate_update_page_climate", "Updating buttons bar");
|
||||
// Hide not supported hotspots
|
||||
id(disp1).hide_component("button01");
|
||||
id(disp1).hide_component("button02");
|
||||
id(disp1).hide_component("button03"); //Heat
|
||||
id(disp1).show_component("button04"); //Cool
|
||||
if (${addon_climate_heat}) id(disp1).show_component("button03"); else id(disp1).hide_component("button03"); //Heat
|
||||
if (${addon_climate_cool}) id(disp1).show_component("button04"); else id(disp1).hide_component("button04"); //Cool
|
||||
id(disp1).hide_component("button05");
|
||||
id(disp1).hide_component("button06");
|
||||
id(disp1).show_component("button07"); //Off
|
||||
// Set buttons colors
|
||||
id(disp1).set_component_font_color("climate.button01_icon", 10597);
|
||||
id(disp1).set_component_font_color("climate.button02_icon", 10597);
|
||||
id(disp1).set_component_font_color("climate.button03_icon", 10597);
|
||||
id(disp1).set_component_font_color("climate.button04_icon", (id(thermostat_embedded).mode==climate::CLIMATE_MODE_COOL) ? 1055 : 48631);
|
||||
id(disp1).set_component_font_color("climate.button05_icon", 10597);
|
||||
id(disp1).set_component_font_color("climate.button06_icon", 10597);
|
||||
id(disp1).set_component_font_color("climate.button07_icon", (id(thermostat_embedded).mode==climate::CLIMATE_MODE_OFF) ? 35921 : 48631);
|
||||
- lambda: ESP_LOGV("script.addon_climate_update_page_climate", "Finished");
|
||||
id(disp1).set_component_font_color("climate.button01_icon", 6339);
|
||||
id(disp1).set_component_font_color("climate.button02_icon", 6339);
|
||||
id(disp1).set_component_font_color("climate.button03_icon", (id(thermostat_embedded).mode==climate::CLIMATE_MODE_HEAT) ? 64164 : ((${addon_climate_heat}) ? 48631 : 6339));
|
||||
id(disp1).set_component_font_color("climate.button04_icon", (id(thermostat_embedded).mode==climate::CLIMATE_MODE_COOL) ? 1055 : ((${addon_climate_cool}) ? 48631 : 6339));
|
||||
id(disp1).set_component_font_color("climate.button05_icon", 6339);
|
||||
id(disp1).set_component_font_color("climate.button06_icon", 6339);
|
||||
id(disp1).set_component_font_color("climate.button07_icon", (id(thermostat_embedded).mode==climate::CLIMATE_MODE_OFF) ? 10597 : 35921);
|
||||
}
|
||||
ESP_LOGV("script.addon_climate_update_page_climate", "Finished");
|
||||
|
||||
- id: !extend addon_climate_set_climate_friendly_name
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGV("script.addon_climate_set_climate_friendly_name", "Starting");
|
||||
ESP_LOGV("script.addon_climate_set_climate_friendly_name", "friendly_name: %s", friendly_name.c_str());
|
||||
id(addon_climate_friendly_name) = friendly_name;
|
||||
ESP_LOGV("script.addon_climate_set_climate_friendly_name", "Finished");
|
||||
|
||||
switch:
|
||||
##### PHYSICAL SWITCH 0 (Dummy) - Used when relay is not set #####
|
||||
|
||||
Reference in New Issue
Block a user