diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index eb94f88..7965291 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -33,7 +33,7 @@ blueprint: 🎉 Roadmap Roadmap can be found here [Roadmap](https://github.com/Blackymas/NSPanel_HA_Blueprint/labels/roadmap) - ℹ️ Version: v.3.3.1 + ℹ️ Version: v.3.3.2 source_url: https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/main/nspanel_blueprint.yaml domain: automation @@ -3512,7 +3512,7 @@ trigger_variables: variables: ##### GENERAL ##### - blueprint_version: '3.3.1' + blueprint_version: '3.3.2' language: !input 'language' date_format_temp: !input 'date_format' #Avoid breaking change for existing users with legacy type format @@ -7460,65 +7460,66 @@ action: sequence: *display_value ##### Slider ##### + - variables: + current_temp: '{{ state_attr(climate_entity, "current_temperature") | float(-999) | round(1) }}' + target_temp: '{{ state_attr(climate_entity, "temperature") | float(-999) * 10 | round(0) | int }}' + temp_offset: '{{ (state_attr(climate_entity, "min_temp") | float(5) * 10) | round(0) | int }}' + max_temp: '{{ (state_attr(climate_entity, "max_temp") | float(25) * 10) | round(0) | int }}' + temp_step: > + {% set target_temp_step = state_attr(climate_entity, "target_temp_step") %} + {% if not is_number(target_temp_step) %} + {% set target_temp_step = state_attr(climate_entity, "target_temperature_step") %} + {% endif %} + {% set target_temp_step = target_temp_step | float(0.5) | abs %} + {{ ((10 * target_temp_step) | round(0) | int) if is_number(target_temp_step) and target_temp_step > 0 else 10 }} + total_steps: '{{ ((max_temp-temp_offset)/temp_step) | round(0) | int }}' - *delay-default - service: '{{ nextion.commands.set_climate }}' data: - state: '{{ states(climate_entity) }}' - hvac_modes: '{{ state_attr(climate_entity, "hvac_modes") }}' - current_temp: '{{ state_attr(climate_entity, "current_temperature") | float(default=-999) | round(1) }}' - target_temp: '{{ state_attr(climate_entity, "temperature") | float(default=-999) * 10 }}' - min_temp: '{{ (state_attr(climate_entity, "min_temp") | round(0, default=5) * 10) | int }}' - max_temp: '{{ (state_attr(climate_entity, "max_temp") | round(0, default=25) * 10) | int }}' + current_temp: '{{ current_temp }}' + target_temp: '{{ target_temp }}' + temp_step: '{{ temp_step }}' + total_steps: '{{ total_steps }}' + slider_val: '{{ ((target_temp - temp_offset) / temp_step) | round(0) | int }}' + temp_offset: '{{ temp_offset }}' continue_on_error: true ##### Buttons ##### - repeat: for_each: '{{ page_climate.buttons.hvac_mode }}' sequence: &update_climate_button - - if: '{{ repeat.item.mode in hvac_modes }}' - then: - - *delay-default - ### ICON Font Color ### - - service: '{{ nextion.commands.font_color }}' - data: - component: 'climate.{{ repeat.item.component }}_icon' - message: > - {{ - nextion.colors[repeat.item.color] - if states(climate_entity) == repeat.item.mode - else nextion.colors.disabled - }} - continue_on_error: true - ### ICON Font ### - - *delay-default - - service: '{{ nextion.commands.text_printf }}' - data: - component: 'climate.{{ repeat.item.component }}_icon' - message: '{{ all_icons[repeat.item.icon] }}' - continue_on_error: true - ### Show button ### - - *delay-default - - service: '{{ nextion.commands.show }}' - data: - component: '{{ repeat.item.component }}_icon' - continue_on_error: true - - *delay-default - - service: '{{ nextion.commands.show }}' - data: - component: '{{ repeat.item.component }}' - continue_on_error: true - else: - ### Hide button ### - - *delay-default - - service: '{{ nextion.commands.hide }}' - data: - component: '{{ repeat.item.component }}' - continue_on_error: true - - *delay-default - - service: '{{ nextion.commands.hide }}' - data: - component: '{{ repeat.item.component }}_icon' - continue_on_error: true + - variables: + mode_supported: '{{ repeat.item.mode in hvac_modes }}' + - *delay-default + ### ICON Font Color ### + - service: '{{ nextion.commands.font_color }}' + data: + component: 'climate.{{ repeat.item.component }}_icon' + message: > + {{ + nextion.colors[repeat.item.color] + if states(climate_entity) == repeat.item.mode + else (nextion.colors.disabled if mode_supported else nextion.colors.grey_dark) + }} + continue_on_error: true + ### ICON Font ### + - *delay-default + - service: '{{ nextion.commands.text_printf }}' + data: + component: 'climate.{{ repeat.item.component }}_icon' + message: '{{ all_icons[repeat.item.icon] }}' + continue_on_error: true + ### Show button ### + - *delay-default + - service: '{{ nextion.commands.show }}' + data: + component: '{{ repeat.item.component }}_icon' + continue_on_error: true + - *delay-default + - service: '{{ nextion.commands.show }}' + data: + component: '{{ repeat.item.component if mode_supported else nextion.commands.hide }}' + continue_on_error: true else: ##### Return to Home page in case is not a climate entity ##### - *jump_page_home @@ -8566,19 +8567,45 @@ action: if trigger.event.data.new_state.attributes.hvac_modes is defined else [] }} - target_temperature: > - {{ - trigger.event.data.new_state.attributes.temperature * 10 + target_temp: > + {{ + trigger.event.data.new_state.attributes.temperature * 10 + if + trigger.event.data.new_state.state != "off" + and trigger.event.data.new_state.attributes.temperature is defined + and is_number(trigger.event.data.new_state.attributes.temperature) + else -999 + }} + temp_offset: > + {{ + trigger.event.data.new_state.attributes.min_temp * 10 + if + trigger.event.data.new_state.state != "off" + and trigger.event.data.new_state.attributes.min_temp is defined + and is_number(trigger.event.data.new_state.attributes.min_temp) + else 50 + }} + temp_step: > + {{ + ((trigger.event.data.new_state.attributes.target_temp_step * 10) | abs) + if + trigger.event.data.new_state.state != "off" + and trigger.event.data.new_state.attributes.target_temp_step is defined + and is_number(trigger.event.data.new_state.attributes.target_temp_step) + else + ( + ((trigger.event.data.new_state.attributes.target_temperature_step * 10) | abs) if trigger.event.data.new_state.state != "off" - and trigger.event.data.new_state.attributes.temperature is defined - and is_number(trigger.event.data.new_state.attributes.temperature) - else -999 - }} - + and trigger.event.data.new_state.attributes.target_temperature_step is defined + and is_number(trigger.event.data.new_state.attributes.target_temperature_step) + else 10 + ) + }} - service: '{{ nextion.commands.set_climate_target_temp }}' data: - target_temp: '{{ target_temperature }}' + target_temp: '{{ target_temp | round(0) | int }}' + slider_val: '{{ ((target_temp - temp_offset) / temp_step) | round(0) | int }}' continue_on_error: true - repeat: for_each: '{{ page_climate.buttons.hvac_mode }}' diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index b1d5afc..07a776f 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -314,7 +314,8 @@ api: #### Service to set climate target_temp #### - service: set_climate_target_temp variables: - target_temp: float + target_temp: int + slider_val: int then: - wait_until: binary_sensor.is_on: nextion_init @@ -322,7 +323,7 @@ api: lambda: |- if (target_temp > -999) { - id(disp1).set_component_value("climateslider", target_temp); + id(disp1).set_component_value("climateslider", slider_val); id(disp1).set_component_value("target_temp", target_temp); id(disp1).show_component("target_icon"); id(disp1).show_component("target_temp"); @@ -344,19 +345,20 @@ api: #### Service to set climate state #### - service: set_climate variables: - state: string - hvac_modes: string current_temp: float - target_temp: float - min_temp: int - max_temp: int + target_temp: int + temp_step: int + total_steps: int + slider_val: int + temp_offset: int then: - wait_until: binary_sensor.is_on: nextion_init - *set_climate_target_temp - lambda: |- - id(disp1).send_command_printf("climateslider.minval=%i", min_temp); - id(disp1).send_command_printf("climateslider.maxval=%i", max_temp); + id(disp1).send_command_printf("climateslider.maxval=%i", total_steps); + id(disp1).set_component_value("temp_offset", temp_offset); + id(disp1).set_component_value("temp_step", temp_step); id(disp1).set_component_text_printf("current_temp", "%.1f°", current_temp); id(disp1).show_component("current_temp"); id(disp1).show_component("current_icon"); @@ -913,7 +915,7 @@ display: - logger.log: "Nextion start - Jump to page 8" - lambda: id(disp1).send_command_printf("page 8"); - logger.log: "Nextion start - Publish ESPHome version" - - lambda: id(disp1).set_component_text_printf("boot.esph_version", "%s", "3.3.1"); ### esphome-version ### + - lambda: id(disp1).set_component_text_printf("boot.esph_version", "%s", "3.3.2"); ### esphome-version ### - logger.log: "Nextion start - Wait for Home Assistant API" - wait_until: api.connected diff --git a/nspanel_eu.HMI b/nspanel_eu.HMI index d9df2b8..42ec5e3 100644 Binary files a/nspanel_eu.HMI and b/nspanel_eu.HMI differ diff --git a/nspanel_eu.tft b/nspanel_eu.tft index 9c650a3..277afa7 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 038d935..170fea9 100644 --- a/nspanel_eu_code/climate.txt +++ b/nspanel_eu_code/climate.txt @@ -44,7 +44,7 @@ Page climate if(timer01.en==1) { timer01.en=0 - covx climateslider.val,va1.txt,0,0 + covx target_temp.val,va1.txt,0,0 climatesetting.txt="{\"page\": \"climate\", \"component\": \"climate_position\", \"value\": "+va1.txt+"}" printh 92 prints "nspanelevent",0 @@ -75,6 +75,18 @@ Variable (string) lastclick Text : Max. Text Size: 100 +Variable (int32) temp_offset + Attributes + ID : 40 + Scope: local + Value: 0 + +Variable (int32) temp_step + Attributes + ID : 41 + Scope: local + Value: 1 + XFloat target_temp Attributes ID : 38 @@ -297,13 +309,15 @@ Slider climateslider Scope : local Dragging : 0 Send Component ID: disabled - Position : 180 - Upper range limit: 250 - Lower range limit: 50 + Position : 20 + Upper range limit: 40 + Lower range limit: 0 Events Touch Release Event target_temp.val=climateslider.val + target_temp.val*=temp_step.val + target_temp.val+=temp_offset.val timer01.en=1 Hotspot decrease_temp @@ -315,8 +329,13 @@ Hotspot decrease_temp Events Touch Press Event - climateslider.val-=1 - target_temp.val=climateslider.val + if(climateslider.val>0) + { + climateslider.val-=1 + target_temp.val=climateslider.val + target_temp.val*=temp_step.val + target_temp.val+=temp_offset.val + } Touch Release Event timer01.en=1 @@ -330,8 +349,13 @@ Hotspot increase_temp Events Touch Press Event - climateslider.val+=1 - target_temp.val=climateslider.val + if(climateslider.val