Fix climate icon update

Partially solves https://github.com/Blackymas/NSPanel_HA_Blueprint/discussions/995#discussioncomment-6891454
This commit is contained in:
Edward Firmo
2023-09-02 11:52:31 +02:00
parent cc9caa7017
commit 5cc19470f7
3 changed files with 108 additions and 262 deletions

View File

@@ -1745,6 +1745,88 @@ script:
id(disp1).set_component_font_color(component.c_str(), alarm_color);
ESP_LOGV("script.update_alarm_icon", "Finished");
- id: update_climate_icon
mode: restart
parameters:
component: string
action: int
mode: int
then:
- lambda: |-
ESP_LOGV("script.update_climate_icon", "Starting");
ESP_LOGV("script.update_climate_icon", "component: %s", component.c_str());
ESP_LOGV("script.update_climate_icon", "action: %i", action);
ESP_LOGV("script.update_climate_icon", "mode: %i", mode);
switch (action) // CLIMATE_ACTION_OFF = 0, CLIMATE_ACTION_COOLING = 2, CLIMATE_ACTION_HEATING = 3, CLIMATE_ACTION_IDLE = 4, CLIMATE_ACTION_DRYING = 5, CLIMATE_ACTION_FAN = 6
{
case 0: //CLIMATE_ACTION_OFF
ESP_LOGV("script.update_climate_icon", "Climate 'action' is off. Using 'mode' instead");
switch (mode) // CLIMATE_MODE_OFF = 0, CLIMATE_MODE_HEAT_COOL = 1, CLIMATE_MODE_COOL = 2, CLIMATE_MODE_HEAT = 3, CLIMATE_MODE_FAN_ONLY = 4, CLIMATE_MODE_DRY = 5, CLIMATE_MODE_AUTO = 6
{
case 0: //CLIMATE_MODE_OFF
ESP_LOGV("script.update_climate_icon", "Icon: none");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uFFFF"); // (E424) Don't show icon when off
id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
break;
case 1: //CLIMATE_MODE_HEAT_COOL
ESP_LOGV("script.update_climate_icon", "Icon: autorenew");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE069"); // mdi:autorenew
id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
break;
case 2: //CLIMATE_MODE_COOL
ESP_LOGV("script.update_climate_icon", "Icon: snowflake");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake
id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
break;
case 3: //CLIMATE_MODE_HEAT
ESP_LOGV("script.update_climate_icon", "Icon: fire");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire
id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
break;
case 4: //CLIMATE_MODE_FAN_ONLY
ESP_LOGV("script.update_climate_icon", "Icon: fan");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan
id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
break;
case 5: //CLIMATE_MODE_DRY
ESP_LOGV("script.update_climate_icon", "Icon: water-percent");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent
id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
break;
case 6: //CLIMATE_MODE_AUTO
ESP_LOGV("script.update_climate_icon", "Icon: calendar-sync");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uEE8D"); // mdi:calendar-sync
id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
break;
}
break;
case 2: //CLIMATE_ACTION_COOLING
ESP_LOGV("script.update_climate_icon", "Icon: snowflake");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake
id(disp1).set_component_font_color(component.c_str(), 1055); // blue
break;
case 3: //CLIMATE_ACTION_HEATING
ESP_LOGV("script.update_climate_icon", "Icon: fire");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire
id(disp1).set_component_font_color(component.c_str(), 64164); // deep-orange
break;
case 4: //CLIMATE_ACTION_IDLE
ESP_LOGV("script.update_climate_icon", "Icon: thermometer");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE50E"); // mdi:thermometer
id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
break;
case 5: //CLIMATE_ACTION_DRYING
ESP_LOGV("script.update_climate_icon", "Icon: water-percent");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent
id(disp1).set_component_font_color(component.c_str(), 64704); // orange
break;
case 6: //CLIMATE_ACTION_FAN
ESP_LOGV("script.update_climate_icon", "Icon: fan");
id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan
id(disp1).set_component_font_color(component.c_str(), 1530); // cyan
break;
}
##### ADD-ONS ############################################################
##### Add-on - Climate #####
- id: addon_climate_service_call

View File

@@ -63,81 +63,18 @@ script:
- id: !extend addon_climate_update_page_home
mode: restart
then:
- lambda: ESP_LOGV("script.addon_climate_update_page_home", "Starting");
- if:
condition:
- binary_sensor.is_on: nextion_init
then:
- lambda: |-
// Update home.entity variable
ESP_LOGV("script.addon_climate_update_page_home", "Update home.entity variable: %s", (id(is_embedded_thermostat)) ? "embedded_climate" : "");
id(disp1).set_component_text_printf("home.entity", (id(is_embedded_thermostat)) ? "embedded_climate" : "");
- if:
condition:
- lambda: !lambda 'return id(is_embedded_thermostat);'
then:
- lambda: |-
// Update chips
ESP_LOGV("script.addon_climate_update_page_home", "Update chips");
ESP_LOGV("script.refresh_chips_climate", "thermostat_embedded.action=%i", int(id(thermostat_embedded).action));
switch (int(id(thermostat_embedded).action)) // CLIMATE_ACTION_OFF = 0, CLIMATE_ACTION_COOLING = 2, CLIMATE_ACTION_HEATING = 3, CLIMATE_ACTION_IDLE = 4, CLIMATE_ACTION_DRYING = 5, CLIMATE_ACTION_FAN = 6
{
case 0: //CLIMATE_ACTION_OFF
ESP_LOGV("script.refresh_chips_climate", "thermostat_embedded.mode=%i", int(id(thermostat_embedded).mode));
switch (int(id(thermostat_embedded).mode)) // CLIMATE_MODE_OFF = 0, CLIMATE_MODE_HEAT_COOL = 1, CLIMATE_MODE_COOL = 2, CLIMATE_MODE_HEAT = 3, CLIMATE_MODE_FAN_ONLY = 4, CLIMATE_MODE_DRY = 5, CLIMATE_MODE_AUTO = 6
{
case 0: //CLIMATE_MODE_OFF
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uFFFF"); // (E424) Don't show icon when off
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 1: //CLIMATE_MODE_HEAT_COOL
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE069");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 2: //CLIMATE_MODE_COOL
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE716");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 3: //CLIMATE_MODE_HEAT
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE237");
id(disp1).set_component_font_color("home.icon_top_03", 64164);
break;
case 4: //CLIMATE_MODE_FAN_ONLY
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE20F");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 5: //CLIMATE_MODE_DRY
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE58D");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 6: //CLIMATE_MODE_AUTO
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uEE8D");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
}
case 2: //CLIMATE_ACTION_COOLING
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE716");
id(disp1).set_component_font_color("home.icon_top_03", 1055);
break;
case 3: //CLIMATE_ACTION_HEATING
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE237");
id(disp1).set_component_font_color("home.icon_top_03", 64164);
break;
case 4: //CLIMATE_ACTION_IDLE
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE50E"); // mdi:thermometer
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 5: //CLIMATE_ACTION_DRYING
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE58D");
id(disp1).set_component_font_color("home.icon_top_03", 64704);
break;
case 6: //CLIMATE_ACTION_FAN
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE20F");
id(disp1).set_component_font_color("home.icon_top_03", 1530);
break;
}
- lambda: ESP_LOGV("script.addon_climate_update_page_home", "Finished");
- lambda: |-
ESP_LOGV("script.addon_climate_update_page_home", "Starting");
// Update home.entity variable
ESP_LOGV("script.addon_climate_update_page_home", "Update home.entity variable: %s", (id(is_embedded_thermostat)) ? "embedded_climate" : "");
id(disp1).set_component_text_printf("home.entity", (id(is_embedded_thermostat)) ? "embedded_climate" : "");
// Update chips
if (id(is_embedded_thermostat))
{
ESP_LOGV("script.addon_climate_update_page_home", "Update chips");
id(update_climate_icon).execute("home.icon_top_03", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode));
}
ESP_LOGV("script.addon_climate_update_page_home", "Finished");
- id: !extend addon_climate_service_call
then:
@@ -210,62 +147,7 @@ script:
# Update target temp icon
- lambda: |-
ESP_LOGV("script.addon_climate_update_page_climate", "thermostat_embedded.action=%i", int(id(thermostat_embedded).action));
switch (int(id(thermostat_embedded).action)) // CLIMATE_ACTION_OFF = 0, CLIMATE_ACTION_COOLING = 2, CLIMATE_ACTION_HEATING = 3, CLIMATE_ACTION_IDLE = 4, CLIMATE_ACTION_DRYING = 5, CLIMATE_ACTION_FAN = 6
{
case 0: //CLIMATE_ACTION_OFF
ESP_LOGV("script.addon_climate_update_page_climate", "thermostat_embedded.mode=%i", int(id(thermostat_embedded).mode));
switch (int(id(thermostat_embedded).mode)) // CLIMATE_MODE_OFF = 0, CLIMATE_MODE_HEAT_COOL = 1, CLIMATE_MODE_COOL = 2, CLIMATE_MODE_HEAT = 3, CLIMATE_MODE_FAN_ONLY = 4, CLIMATE_MODE_DRY = 5, CLIMATE_MODE_AUTO = 6
{
case 0: //CLIMATE_MODE_OFF
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uFFFF"); // (E424) Don't show icon when off
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
case 1: //CLIMATE_MODE_HEAT_COOL
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE069");
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
case 2: //CLIMATE_MODE_COOL
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE716");
id(disp1).set_component_font_color("climate.target_icon", 1055);
break;
case 3: //CLIMATE_MODE_HEAT
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE237");
id(disp1).set_component_font_color("climate.target_icon", 64164);
break;
case 4: //CLIMATE_MODE_FAN_ONLY
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE20F");
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
case 5: //CLIMATE_MODE_DRY
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE58D");
id(disp1).set_component_font_color("climate.target_icon", 64704);
break;
case 6: //CLIMATE_MODE_AUTO
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uEE8D");
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
}
case 2: //CLIMATE_ACTION_COOLING
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE716");
id(disp1).set_component_font_color("climate.target_icon", 1055);
break;
case 3: //CLIMATE_ACTION_HEATING
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE237");
id(disp1).set_component_font_color("climate.target_icon", 64164);
break;
case 4: //CLIMATE_ACTION_IDLE
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE50E"); // mdi:thermometer
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
case 5: //CLIMATE_ACTION_DRYING
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE58D");
id(disp1).set_component_font_color("climate.target_icon", 64704);
break;
case 6: //CLIMATE_ACTION_FAN
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE20F");
id(disp1).set_component_font_color("climate.target_icon", 1530);
break;
}
id(update_climate_icon).execute("climate.target_icon", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode));
# Update buttons bar
- lambda: |-

View File

@@ -63,81 +63,18 @@ script:
- id: !extend addon_climate_update_page_home
mode: restart
then:
- lambda: ESP_LOGV("script.addon_climate_update_page_home", "Starting");
- if:
condition:
- binary_sensor.is_on: nextion_init
then:
- lambda: |-
// Update home.entity variable
ESP_LOGV("script.addon_climate_update_page_home", "Update home.entity variable: %s", (id(is_embedded_thermostat)) ? "embedded_climate" : "");
id(disp1).set_component_text_printf("home.entity", (id(is_embedded_thermostat)) ? "embedded_climate" : "");
- if:
condition:
- lambda: !lambda 'return id(is_embedded_thermostat);'
then:
- lambda: |-
// Update chips
ESP_LOGV("script.addon_climate_update_page_home", "Update chips");
ESP_LOGV("script.refresh_chips_climate", "thermostat_embedded.action=%i", int(id(thermostat_embedded).action));
switch (int(id(thermostat_embedded).action)) // CLIMATE_ACTION_OFF = 0, CLIMATE_ACTION_COOLING = 2, CLIMATE_ACTION_HEATING = 3, CLIMATE_ACTION_IDLE = 4, CLIMATE_ACTION_DRYING = 5, CLIMATE_ACTION_FAN = 6
{
case 0: //CLIMATE_ACTION_OFF
ESP_LOGV("script.refresh_chips_climate", "thermostat_embedded.mode=%i", int(id(thermostat_embedded).mode));
switch (int(id(thermostat_embedded).mode)) // CLIMATE_MODE_OFF = 0, CLIMATE_MODE_HEAT_COOL = 1, CLIMATE_MODE_COOL = 2, CLIMATE_MODE_HEAT = 3, CLIMATE_MODE_FAN_ONLY = 4, CLIMATE_MODE_DRY = 5, CLIMATE_MODE_AUTO = 6
{
case 0: //CLIMATE_MODE_OFF
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uFFFF"); // (E424) Don't show icon when off
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 1: //CLIMATE_MODE_HEAT_COOL
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE069");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 2: //CLIMATE_MODE_COOL
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE716");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 3: //CLIMATE_MODE_HEAT
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE237");
id(disp1).set_component_font_color("home.icon_top_03", 64164);
break;
case 4: //CLIMATE_MODE_FAN_ONLY
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE20F");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 5: //CLIMATE_MODE_DRY
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE58D");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 6: //CLIMATE_MODE_AUTO
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uEE8D");
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
}
case 2: //CLIMATE_ACTION_COOLING
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE716");
id(disp1).set_component_font_color("home.icon_top_03", 1055);
break;
case 3: //CLIMATE_ACTION_HEATING
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE237");
id(disp1).set_component_font_color("home.icon_top_03", 64164);
break;
case 4: //CLIMATE_ACTION_IDLE
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE50E"); // mdi:thermometer
id(disp1).set_component_font_color("home.icon_top_03", 35921);
break;
case 5: //CLIMATE_ACTION_DRYING
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE58D");
id(disp1).set_component_font_color("home.icon_top_03", 64704);
break;
case 6: //CLIMATE_ACTION_FAN
id(disp1).set_component_text_printf("home.icon_top_03", "%s", "\uE20F");
id(disp1).set_component_font_color("home.icon_top_03", 1530);
break;
}
- lambda: ESP_LOGV("script.addon_climate_update_page_home", "Finished");
- lambda: |-
ESP_LOGV("script.addon_climate_update_page_home", "Starting");
// Update home.entity variable
ESP_LOGV("script.addon_climate_update_page_home", "Update home.entity variable: %s", (id(is_embedded_thermostat)) ? "embedded_climate" : "");
id(disp1).set_component_text_printf("home.entity", (id(is_embedded_thermostat)) ? "embedded_climate" : "");
// Update chips
if (id(is_embedded_thermostat))
{
ESP_LOGV("script.addon_climate_update_page_home", "Update chips");
id(update_climate_icon).execute("home.icon_top_03", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode));
}
ESP_LOGV("script.addon_climate_update_page_home", "Finished");
- id: !extend addon_climate_service_call
then:
@@ -210,62 +147,7 @@ script:
# Update target temp icon
- lambda: |-
ESP_LOGV("script.addon_climate_update_page_climate", "thermostat_embedded.action=%i", int(id(thermostat_embedded).action));
switch (int(id(thermostat_embedded).action)) // CLIMATE_ACTION_OFF = 0, CLIMATE_ACTION_COOLING = 2, CLIMATE_ACTION_HEATING = 3, CLIMATE_ACTION_IDLE = 4, CLIMATE_ACTION_DRYING = 5, CLIMATE_ACTION_FAN = 6
{
case 0: //CLIMATE_ACTION_OFF
ESP_LOGV("script.addon_climate_update_page_climate", "thermostat_embedded.mode=%i", int(id(thermostat_embedded).mode));
switch (int(id(thermostat_embedded).mode)) // CLIMATE_MODE_OFF = 0, CLIMATE_MODE_HEAT_COOL = 1, CLIMATE_MODE_COOL = 2, CLIMATE_MODE_HEAT = 3, CLIMATE_MODE_FAN_ONLY = 4, CLIMATE_MODE_DRY = 5, CLIMATE_MODE_AUTO = 6
{
case 0: //CLIMATE_MODE_OFF
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uFFFF"); // (E424) Don't show icon when off
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
case 1: //CLIMATE_MODE_HEAT_COOL
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE069");
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
case 2: //CLIMATE_MODE_COOL
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE716");
id(disp1).set_component_font_color("climate.target_icon", 1055);
break;
case 3: //CLIMATE_MODE_HEAT
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE237");
id(disp1).set_component_font_color("climate.target_icon", 64164);
break;
case 4: //CLIMATE_MODE_FAN_ONLY
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE20F");
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
case 5: //CLIMATE_MODE_DRY
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE58D");
id(disp1).set_component_font_color("climate.target_icon", 64704);
break;
case 6: //CLIMATE_MODE_AUTO
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uEE8D");
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
}
case 2: //CLIMATE_ACTION_COOLING
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE716");
id(disp1).set_component_font_color("climate.target_icon", 1055);
break;
case 3: //CLIMATE_ACTION_HEATING
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE237");
id(disp1).set_component_font_color("climate.target_icon", 64164);
break;
case 4: //CLIMATE_ACTION_IDLE
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE50E"); // mdi:thermometer
id(disp1).set_component_font_color("climate.target_icon", 35921);
break;
case 5: //CLIMATE_ACTION_DRYING
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE58D");
id(disp1).set_component_font_color("climate.target_icon", 64704);
break;
case 6: //CLIMATE_ACTION_FAN
id(disp1).set_component_text_printf("climate.target_icon", "%s", "\uE20F");
id(disp1).set_component_font_color("climate.target_icon", 1530);
break;
}
id(update_climate_icon).execute("climate.target_icon", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode));
# Update buttons bar
- lambda: |-