diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 409a420..a527975 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -3576,7 +3576,6 @@ variables: set_button: 'esphome.{{ nspanel_name }}_set_button' set_entity: 'esphome.{{ nspanel_name }}_set_entity' set_climate: 'esphome.{{ nspanel_name }}_set_climate' - set_climate_target_temp: 'esphome.{{ nspanel_name }}_set_climate_target_temp' icons: buttons: automation: "\uF6FC" #F6FC @@ -7460,36 +7459,44 @@ 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: - 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 + - &climate-update_slider + if: '{{ true }}' + then: + - 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 + if states(climate_entity) not in ["unavailable", "unknown", "", None, "off"] + else -999 + }} + 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: + 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: + - &climate-update_buttons + repeat: for_each: '{{ page_climate.buttons.hvac_mode }}' - sequence: &update_climate_button - - variables: - mode_supported: '{{ repeat.item.mode in hvac_modes }}' + sequence: + - condition: '{{ repeat.item.mode in hvac_modes }}' - *delay-default ### ICON Font Color ### - service: '{{ nextion.commands.font_color }}' @@ -7499,7 +7506,7 @@ action: {{ nextion.colors[repeat.item.color] if states(climate_entity) == repeat.item.mode - else (nextion.colors.disabled if mode_supported else nextion.colors.grey_dark) + else nextion.colors.disabled }} continue_on_error: true ### ICON Font ### @@ -7509,16 +7516,11 @@ action: component: 'climate.{{ repeat.item.component }}_icon' message: '{{ all_icons[repeat.item.icon] }}' continue_on_error: true - ### Show button ### + ### Enable button click ### - *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 }}' + component: '{{ repeat.item.component }}' continue_on_error: true else: ##### Return to Home page in case is not a climate entity ##### @@ -8161,9 +8163,7 @@ action: target: entity_id: '{{ climate_entity }}' continue_on_error: true - - repeat: - for_each: '{{ page_climate.buttons.hvac_mode }}' - sequence: *update_climate_button + - *climate-update_buttons - alias: Button page - Button press conditions: @@ -8561,55 +8561,8 @@ action: sequence: - variables: climate_entity: '{{ trigger.event.data.entity_id }}' - hvac_modes: > - {{ - trigger.event.data.new_state.attributes.hvac_modes - if trigger.event.data.new_state.attributes.hvac_modes is defined - else [] - }} - 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.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_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 }}' - sequence: *update_climate_button + - *climate-update_slider + - *climate-update_buttons ########## TRIGGER - HOME PAGE ########### diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 07a776f..e9960ce 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -311,16 +311,19 @@ api: id(disp1).send_command_printf("page qrcode"); id(disp1).set_component_text_printf("qrcode.qrcode_value", "%s", qrdata.c_str()); - #### Service to set climate target_temp #### - - service: set_climate_target_temp + #### Service to set climate state #### + - service: set_climate variables: + current_temp: float 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: |- + - lambda: |- if (target_temp > -999) { id(disp1).set_component_value("climateslider", slider_val); @@ -341,20 +344,6 @@ api: id(disp1).hide_component("decrease_temp"); id(disp1).hide_component("increase_temp"); } - - #### Service to set climate state #### - - service: set_climate - variables: - current_temp: float - 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.maxval=%i", total_steps); id(disp1).set_component_value("temp_offset", temp_offset); diff --git a/nspanel_eu.HMI b/nspanel_eu.HMI index 42ec5e3..0255635 100644 Binary files a/nspanel_eu.HMI and b/nspanel_eu.HMI differ diff --git a/nspanel_eu.tft b/nspanel_eu.tft index 277afa7..9a13070 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 170fea9..e69de29 100644 --- a/nspanel_eu_code/climate.txt +++ b/nspanel_eu_code/climate.txt @@ -1,583 +0,0 @@ -Page climate - Attributes - ID : 0 - Scope : local - Dragging : 0 - Send Component ID : disabled - Locked : no - Swide up page ID : disabled - Swide down page ID : disabled - Swide left page ID : disabled - Swide right page ID: disabled - - Events - Preinitialize Event - printh 92 - prints "nspanelevent",0 - printh 00 - prints "{\"page\": \"climate\", \"component\": \"currentpage\", \"value\": \"pagechange\"}",0 - printh 00 - printh FF FF FF - vis target_icon,0 - vis target_temp,0 - vis current_temp,0 - vis current_icon,0 - vis climateslider,0 - - Touch Press Event - printh 92 - prints "touchevent",0 - printh 00 - prints "{\"page\": \"climate\", \"component\": \"touchevent\", \"value\": \"press\"}",0 - printh 00 - printh FF FF FF - - Touch Release Event - printh 92 - prints "touchevent",0 - printh 00 - prints "{\"page\": \"climate\", \"component\": \"touchevent\", \"value\": \"release\"}",0 - printh 00 - printh FF FF FF - - Page Exit Event - if(timer01.en==1) - { - timer01.en=0 - covx target_temp.val,va1.txt,0,0 - climatesetting.txt="{\"page\": \"climate\", \"component\": \"climate_position\", \"value\": "+va1.txt+"}" - printh 92 - prints "nspanelevent",0 - printh 00 - prints climatesetting.txt,0 - printh 00 - printh FF FF FF - } - -Variable (string) va1 - Attributes - ID : 27 - Scope : local - Text : - Max. Text Size: 10 - -Variable (string) climatesetting - Attributes - ID : 28 - Scope : local - Text : - Max. Text Size: 100 - -Variable (string) lastclick - Attributes - ID : 37 - Scope : local - 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 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Value : 0 - -Text current_temp - Attributes - ID : 3 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 6 - -Text climate_label - Attributes - ID : 8 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 30 - -Text current_icon - Attributes - ID : 10 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text target_icon - Attributes - ID : 11 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text value01_icon - Attributes - ID : 12 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text value01 - Attributes - ID : 13 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text value02_icon - Attributes - ID : 14 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text value02 - Attributes - ID : 15 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text value03_icon - Attributes - ID : 16 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text value03 - Attributes - ID : 17 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text value04_icon - Attributes - ID : 18 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text value04 - Attributes - ID : 19 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text button01_icon - Attributes - ID : 20 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text button02_icon - Attributes - ID : 21 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text button03_icon - Attributes - ID : 22 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text button04_icon - Attributes - ID : 23 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text button05_icon - Attributes - ID : 24 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text button06_icon - Attributes - ID : 25 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text button07_icon - Attributes - ID : 26 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : - Max. Text Size : 10 - -Text t0 - Attributes - ID : 29 - Scope : local - Dragging : 0 - Send Component ID : disabled - Associated Keyboard: none - Text : ° - Max. Text Size : 6 - -Picture climate_exit - Attributes - ID : 6 - Scope : local - Dragging : 0 - Send Component ID: disabled - -Slider climateslider - Attributes - ID : 9 - Scope : local - Dragging : 0 - Send Component ID: disabled - 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 - Attributes - ID : 4 - Scope : local - Dragging : 0 - Send Component ID: disabled - - Events - Touch Press Event - 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 - -Hotspot increase_temp - Attributes - ID : 5 - Scope : local - Dragging : 0 - Send Component ID: disabled - - Events - Touch Press Event - if(climateslider.valswipedx) - { - //page - } - // Right to Left - swipec2=0-swipedx - if(swipec100) - { - //page - } - // Down to Up - swipec2=0-swipedy - if(swipec<-100) - { - //page - } - } -