diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index f074d76..51d27f4 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -3523,6 +3523,7 @@ variables: amber: '65024' # rgb(255, 193, 7) "off": '35921' #8a8a8a disabled: '48631' # rgb(189, 189, 189) + unavailable: '6339' command: text_printf: 'esphome.{{ nspanel_name }}_send_command_text_printf' value: 'esphome.{{ nspanel_name }}_send_command_value' diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 1bc2ce2..e7cf7ed 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -271,6 +271,7 @@ api: { id(disp1).set_component_font_color("icon_state", page_icon_color); } + if (page == "climate" and entity == "embedded_climate") id(addon_climate_set_climate_friendly_name).execute(page_label.c_str()); ESP_LOGV("api.service.open_entity_settings_page", "Finished"); ##### Service to play a rtttl tones ##### @@ -991,7 +992,7 @@ text_sensor: }); if (component=="currentpage") { - ESP_LOGV("text_sensor.nspanelevent", "New page: %s", page.c_str()); + ESP_LOGD("text_sensor.nspanelevent", "New page: %s", page.c_str()); ESP_LOGV("text_sensor.nspanelevent", "Trigger HA event"); ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", { @@ -1826,6 +1827,7 @@ script: id(disp1).set_component_font_color(component.c_str(), 1530); // cyan break; } + ESP_LOGV("script.update_climate_icon", "Finished"); ##### ADD-ONS ############################################################ ##### Add-on - Climate ##### @@ -1837,15 +1839,13 @@ script: then: # Reserved for Add-on Climate - lambda: |- - ESP_LOGV("script.addon_climate_service_call", "Starting"); - ESP_LOGV("script.addon_climate_service_call", "Finished"); + ESP_LOGV("script.addon_climate_service_call", "Check for addon_climate"); - id: addon_climate_update_page_home mode: restart then: # Reserved for Add-on Climate - lambda: |- - ESP_LOGV("script.addon_climate_update_page_home", "Starting"); - ESP_LOGV("script.addon_climate_update_page_home", "Finished"); + ESP_LOGV("script.addon_climate_update_page_home", "Check for addon_climate"); - id: addon_climate_set_climate mode: restart parameters: @@ -1853,9 +1853,8 @@ script: then: # Reserved for Add-on Climate - lambda: |- - ESP_LOGV("script.addon_climate_set_climate", "Starting"); + ESP_LOGV("script.addon_climate_set_climate", "Check for addon_climate"); ESP_LOGV("script.addon_climate_set_climate", "embedded_climate: %i", (embedded_climate) ? 1 : 0); - ESP_LOGV("script.addon_climate_set_climate", "Finished"); - id: addon_climate_global_settings mode: restart parameters: @@ -1863,12 +1862,20 @@ script: then: # Reserved for Add-on Climate - lambda: |- - ESP_LOGV("script.addon_climate_global_settings", "Starting"); - ESP_LOGV("script.addon_climate_global_settings", "Finished"); + ESP_LOGV("script.addon_climate_global_settings", "Check for addon_climate"); + ESP_LOGV("script.addon_climate_global_settings", "embedded_climate: %i", (embedded_climate) ? 1 : 0); - id: addon_climate_update_page_climate mode: restart then: # Reserved for Add-on Climate - lambda: |- - ESP_LOGV("script.addon_climate_update_page_climate", "Starting"); - ESP_LOGV("script.addon_climate_update_page_climate", "Finished"); + ESP_LOGV("script.addon_climate_update_page_climate", "Check for addon_climate"); + - id: addon_climate_set_climate_friendly_name + mode: restart + parameters: + friendly_name: string + then: + # Reserved for Add-on Climate + - lambda: |- + ESP_LOGV("script.addon_climate_set_climate_friendly_name", "Check for addon_climate"); + ESP_LOGV("script.addon_climate_set_climate_friendly_name", "friendly_name: %s", friendly_name.c_str()); diff --git a/nspanel_esphome_addon_climate_cool.yaml b/nspanel_esphome_addon_climate_cool.yaml index eb73484..29e1b1c 100644 --- a/nspanel_esphome_addon_climate_cool.yaml +++ b/nspanel_esphome_addon_climate_cool.yaml @@ -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 ##### diff --git a/nspanel_esphome_addon_climate_heat.yaml b/nspanel_esphome_addon_climate_heat.yaml index 5d40499..bf377d9 100644 --- a/nspanel_esphome_addon_climate_heat.yaml +++ b/nspanel_esphome_addon_climate_heat.yaml @@ -16,6 +16,11 @@ substitutions: temp_max: "25" temp_step: "0.5" + ##### DO NOT CHANGE THIS ##### + addon_climate_cool: "false" + addon_climate_heat: "true" + ############################## + 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).show_component("button03"); //Heat - id(disp1).hide_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", (id(thermostat_embedded).mode==climate::CLIMATE_MODE_HEAT) ? 64164 : 48631); - id(disp1).set_component_font_color("climate.button04_icon", 10597); - 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 ##### diff --git a/nspanel_eu.HMI b/nspanel_eu.HMI index f3b40eb..52c7da7 100644 Binary files a/nspanel_eu.HMI and b/nspanel_eu.HMI differ diff --git a/nspanel_eu.tft b/nspanel_eu.tft index 31414fd..c86b697 100644 Binary files a/nspanel_eu.tft and b/nspanel_eu.tft differ diff --git a/nspanel_eu_code/climate.txt b/nspanel_eu_code/climate.txt index cfb0956..14fbd65 100644 --- a/nspanel_eu_code/climate.txt +++ b/nspanel_eu_code/climate.txt @@ -156,7 +156,7 @@ Text page_label Send Component ID : disabled Associated Keyboard: none Text : - Max. Text Size : 30 + Max. Text Size : 100 Text current_icon Attributes @@ -369,6 +369,15 @@ Slider climateslider Lower range limit: 0 Events + Touch Press Event + climatesetting.txt="{\"page\": \"climate\", \"component\": \"touchevent\", \"value\": \"press\", \"entity\": \""+home.entity.txt+"\"}" + printh 92 + prints "touchevent",0 + printh 00 + prints climatesetting.txt,0 + printh 00 + printh FF FF FF + Touch Release Event temp_number.val=climateslider.val*temp_step.val temp_number.val+=temp_offset.val @@ -378,6 +387,13 @@ Slider climateslider covx va0.val,va1.txt,0,0 target_temp.txt+="."+va1.txt timer01.en=1 + climatesetting.txt="{\"page\": \"climate\", \"component\": \"touchevent\", \"value\": \"release\", \"entity\": \""+home.entity.txt+"\"}" + printh 92 + prints "touchevent",0 + printh 00 + prints climatesetting.txt,0 + printh 00 + printh FF FF FF Button button_back Attributes diff --git a/nspanel_us.HMI b/nspanel_us.HMI index e451d82..4cf8d7c 100644 Binary files a/nspanel_us.HMI and b/nspanel_us.HMI differ diff --git a/nspanel_us.tft b/nspanel_us.tft index 0fe81f8..960000a 100644 Binary files a/nspanel_us.tft and b/nspanel_us.tft differ diff --git a/nspanel_us_code/climate.txt b/nspanel_us_code/climate.txt index 0203747..7f7247f 100644 --- a/nspanel_us_code/climate.txt +++ b/nspanel_us_code/climate.txt @@ -156,7 +156,7 @@ Text page_label Send Component ID : disabled Associated Keyboard: none Text : - Max. Text Size : 30 + Max. Text Size : 100 Text current_icon Attributes @@ -369,6 +369,15 @@ Slider climateslider Lower range limit: 0 Events + Touch Press Event + climatesetting.txt="{\"page\": \"climate\", \"component\": \"touchevent\", \"value\": \"press\", \"entity\": \""+home.entity.txt+"\"}" + printh 92 + prints "touchevent",0 + printh 00 + prints climatesetting.txt,0 + printh 00 + printh FF FF FF + Touch Release Event temp_number.val=climateslider.val*temp_step.val temp_number.val+=temp_offset.val @@ -378,6 +387,13 @@ Slider climateslider covx va0.val,va1.txt,0,0 target_temp.txt+="."+va1.txt timer01.en=1 + climatesetting.txt="{\"page\": \"climate\", \"component\": \"touchevent\", \"value\": \"release\", \"entity\": \""+home.entity.txt+"\"}" + printh 92 + prints "touchevent",0 + printh 00 + prints climatesetting.txt,0 + printh 00 + printh FF FF FF Button button_back Attributes diff --git a/nspanel_us_land.HMI b/nspanel_us_land.HMI index 616d895..c857ad3 100644 Binary files a/nspanel_us_land.HMI and b/nspanel_us_land.HMI differ diff --git a/nspanel_us_land.tft b/nspanel_us_land.tft index ec63ac6..08ab458 100644 Binary files a/nspanel_us_land.tft and b/nspanel_us_land.tft differ diff --git a/nspanel_us_land_code/climate.txt b/nspanel_us_land_code/climate.txt index cfb0956..14fbd65 100644 --- a/nspanel_us_land_code/climate.txt +++ b/nspanel_us_land_code/climate.txt @@ -156,7 +156,7 @@ Text page_label Send Component ID : disabled Associated Keyboard: none Text : - Max. Text Size : 30 + Max. Text Size : 100 Text current_icon Attributes @@ -369,6 +369,15 @@ Slider climateslider Lower range limit: 0 Events + Touch Press Event + climatesetting.txt="{\"page\": \"climate\", \"component\": \"touchevent\", \"value\": \"press\", \"entity\": \""+home.entity.txt+"\"}" + printh 92 + prints "touchevent",0 + printh 00 + prints climatesetting.txt,0 + printh 00 + printh FF FF FF + Touch Release Event temp_number.val=climateslider.val*temp_step.val temp_number.val+=temp_offset.val @@ -378,6 +387,13 @@ Slider climateslider covx va0.val,va1.txt,0,0 target_temp.txt+="."+va1.txt timer01.en=1 + climatesetting.txt="{\"page\": \"climate\", \"component\": \"touchevent\", \"value\": \"release\", \"entity\": \""+home.entity.txt+"\"}" + printh 92 + prints "touchevent",0 + printh 00 + prints climatesetting.txt,0 + printh 00 + printh FF FF FF Button button_back Attributes