diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index eddf264..fc951a2 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -54,6 +54,12 @@ esphome: platformio_options: build_flags: - -Wno-missing-field-initializers + # - -fdata-sections + # - -ffunction-sections + # - -Wl,--gc-sections + # - -Os + # - -flto + on_boot: - priority: 600.0 # This is where most sensors are set up. then: @@ -98,9 +104,12 @@ esp32: CONFIG_D0WD_PSRAM_CLK_IO: "5" CONFIG_D0WD_PSRAM_CS_IO: "18" CONFIG_ESP32_REV_MIN_3: "y" + CONFIG_SPIRAM_SUPPORT: "y" psram: id: ext_ram + mode: quad + speed: 80MHz ##### WIFI SETUP ##### wifi: @@ -790,7 +799,29 @@ api: value2: string direction: int then: - # Do nothing for now + - lambda: |- + if (!id(is_uploading_tft) and !group_id.empty()) { + uint8_t id = findUtilitiesGroupIndex(group_id.c_str()); + if (id != UINT8_MAX) { + // Update Value 1 + if (!value1.empty() and strcmp(value1.c_str(), UtilitiesGroups[id].value1) != 0) { + copyStringToCharArray(UtilitiesGroups[id].value1, value1); + disp1->set_component_text(group_id.c_str(), value1.c_str()); + } + + // Update Value 2 + if (!value2.empty() and strcmp(value2.c_str(), UtilitiesGroups[id].value2) != 0) { + copyStringToCharArray(UtilitiesGroups[id].value2, value2); + disp1->set_component_text((group_id + "b").c_str(), value2.c_str()); + } + + // Update direction + if (group_id != "grid" and !isnan(direction) and direction != UtilitiesGroups[id].direction) { + UtilitiesGroups[id].direction = direction; + disp1->set_component_value((group_id + "_line_d").c_str(), direction); + } + } + } # Updates an entity to display specific values with dynamic icons, names, and color codes. - service: value @@ -2016,19 +2047,17 @@ script: entity: string then: - lambda: |- - if (!id(is_uploading_tft)) { - if (service != "" and not service.empty()) { - esphome::api::CustomAPIDevice ha_event; - ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", - { - {"device_name", device_name->state.c_str()}, - {"type", "service_call"}, - {"service", service}, - {"key", key}, - {"value", value}, - {"entity", entity} - }); - } + if (!id(is_uploading_tft) and !service.empty()) { + esphome::api::CustomAPIDevice ha_event; + ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", + { + {"device_name", device_name->state.c_str()}, + {"type", "service_call"}, + {"service", service}, + {"key", key}, + {"value", value}, + {"entity", entity} + }); } - id: init_hardware_climate @@ -2561,7 +2590,7 @@ script: else if (key == "vacation") service = "alarm_control_panel.alarm_arm_vacation"; else if (key == "bypass") service = "alarm_control_panel.alarm_arm_custom_bypass"; else if (key == "disarm") service = "alarm_control_panel.alarm_disarm"; - if (service != "" and not service.empty()) + if (not service.empty()) { HomeassistantServiceResponse resp; HomeassistantServiceMap resp_kv; @@ -2569,7 +2598,7 @@ script: resp_kv.key = "entity_id"; resp_kv.value = entity.c_str(); resp.data.push_back(resp_kv); - if (pin != "" and not pin.empty()) + if (not pin.empty()) { resp_kv.key = "code"; resp_kv.value = pin.c_str(); diff --git a/hmi/dev/nspanel_eu_code/utilities.txt b/hmi/dev/nspanel_eu_code/utilities.txt index 34318f1..8ab0cd6 100644 --- a/hmi/dev/nspanel_eu_code/utilities.txt +++ b/hmi/dev/nspanel_eu_code/utilities.txt @@ -27,7 +27,7 @@ Page utilities printh 00 printh FF FF FF -Variable (int32) line_main_d +Variable (int32) home_line_d Attributes ID : 46 Scope: local @@ -419,7 +419,7 @@ Text group06b Text : Max. Text Size : 10 -Slider line_main +Slider home_line Attributes ID : 10 Scope : local @@ -535,14 +535,14 @@ Timer tm_movement Events Timer Event - //line_main - line_main.val+=line_main_d.val - if(line_main.val>=line_main.maxval) + //home_line + home_line.val+=home_line_d.val + if(home_line.val>=home_line.maxval) { - line_main.val=line_main.minval - }else if(line_main.val<=line_main.minval) + home_line.val=home_line.minval + }else if(home_line.val<=home_line.minval) { - line_main.val=line_main.maxval + home_line.val=home_line.maxval } //group01_line group01_line.val+=group01_line_d.val diff --git a/hmi/dev/nspanel_us_code/utilities.txt b/hmi/dev/nspanel_us_code/utilities.txt index 135e8a1..9f028a1 100644 --- a/hmi/dev/nspanel_us_code/utilities.txt +++ b/hmi/dev/nspanel_us_code/utilities.txt @@ -27,7 +27,7 @@ Page utilities printh 00 printh FF FF FF -Variable (int32) line_main_d +Variable (int32) home_line_d Attributes ID : 46 Scope: local @@ -419,7 +419,7 @@ Text group06b Text : Max. Text Size : 10 -Slider line_main +Slider home_line Attributes ID : 10 Scope : local @@ -536,13 +536,13 @@ Timer tm_movement Events Timer Event //line_main - line_main.val+=line_main_d.val - if(line_main.val>=line_main.maxval) + home_line.val+=home_line_d.val + if(home_line.val>=home_line.maxval) { - line_main.val=line_main.minval - }else if(line_main.val<=line_main.minval) + home_line.val=home_line.minval + }else if(home_line.val<=home_line.minval) { - line_main.val=line_main.maxval + home_line.val=home_line.maxval } //group01_line group01_line.val+=group01_line_d.val diff --git a/hmi/dev/nspanel_us_land_code/utilities.txt b/hmi/dev/nspanel_us_land_code/utilities.txt index dd54019..8ab0cd6 100644 --- a/hmi/dev/nspanel_us_land_code/utilities.txt +++ b/hmi/dev/nspanel_us_land_code/utilities.txt @@ -27,7 +27,7 @@ Page utilities printh 00 printh FF FF FF -Variable (int32) line_main_d +Variable (int32) home_line_d Attributes ID : 46 Scope: local @@ -419,7 +419,7 @@ Text group06b Text : Max. Text Size : 10 -Slider line_main +Slider home_line Attributes ID : 10 Scope : local @@ -530,19 +530,19 @@ Timer tm_movement Attributes ID : 45 Scope : local - Period (ms): 50 + Period (ms): 150 Enabled : yes Events Timer Event - //line_main - line_main.val+=line_main_d.val - if(line_main.val>=line_main.maxval) + //home_line + home_line.val+=home_line_d.val + if(home_line.val>=home_line.maxval) { - line_main.val=line_main.minval - }else if(line_main.val<=line_main.minval) + home_line.val=home_line.minval + }else if(home_line.val<=home_line.minval) { - line_main.val=line_main.maxval + home_line.val=home_line.maxval } //group01_line group01_line.val+=group01_line_d.val diff --git a/hmi/nspanel_eu.HMI b/hmi/nspanel_eu.HMI index dfd0bed..7337392 100644 Binary files a/hmi/nspanel_eu.HMI and b/hmi/nspanel_eu.HMI differ diff --git a/hmi/nspanel_eu.tft b/hmi/nspanel_eu.tft index e93436b..550a5b6 100644 Binary files a/hmi/nspanel_eu.tft and b/hmi/nspanel_eu.tft differ diff --git a/hmi/nspanel_us.HMI b/hmi/nspanel_us.HMI index 7d106a5..ce4d7cd 100644 Binary files a/hmi/nspanel_us.HMI and b/hmi/nspanel_us.HMI differ diff --git a/hmi/nspanel_us.tft b/hmi/nspanel_us.tft index cf1b5e4..120816d 100644 Binary files a/hmi/nspanel_us.tft and b/hmi/nspanel_us.tft differ diff --git a/hmi/nspanel_us_land.HMI b/hmi/nspanel_us_land.HMI index b4a04ba..c0f4b4c 100644 Binary files a/hmi/nspanel_us_land.HMI and b/hmi/nspanel_us_land.HMI differ diff --git a/hmi/nspanel_us_land.tft b/hmi/nspanel_us_land.tft index c5efe27..4e8dfb6 100644 Binary files a/hmi/nspanel_us_land.tft and b/hmi/nspanel_us_land.tft differ diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 86b1d34..2607a81 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -6481,12 +6481,6 @@ variables: label: !input utilities_page01_label icon: !input utilities_page01_icon groups: - - name: home - label: !input utilities_page01_home_label - icon: !input utilities_page01_home_icon - value1: !input utilities_page01_home_value1 - value2: !input utilities_page01_home_value2 - color: !input utilities_page01_home_color - name: grid label: !input utilities_page01_grid_label icon: !input utilities_page01_grid_icon @@ -6541,6 +6535,14 @@ variables: color: !input utilities_page01_group06_color line_ref: !input utilities_page01_group06_line_reference line_inverted: !input utilities_page01_group06_line_inverted + - name: home + label: !input utilities_page01_home_label + icon: !input utilities_page01_home_icon + value1: !input utilities_page01_home_value1 + value2: !input utilities_page01_home_value2 + color: !input utilities_page01_home_color + line_ref: !input utilities_page01_main_line_reference + line_inverted: !input utilities_page01_main_line_inverted ###### MEDIA PLAYER REFRESH ##### media_player_update_interval: !input 'media_player_update_interval' @@ -9785,30 +9787,6 @@ action: value: '{{ pages_utilities.title.label }}' value_color: [] continue_on_error: true - ## Show main line - - if: '{{ pages_utilities.cursor.width != 255 }}' - then: - - *delay_default - - service: 'esphome.{{ nspanel_name }}_command' - data: - cmd: 'line_main.wid={{ pages_utilities.cursor.width }}' - continue_on_error: true - - *delay_default - - service: 'esphome.{{ nspanel_name }}_components_visibility' - data: - ids: ["line_main"] - visible: true - continue_on_error: true - - variables: - main_line_ref: !input utilities_page01_main_line_reference - main_line_inverted: !input utilities_page01_main_line_inverted - main_line_ref_state: '{{ states(main_line_ref) | int(0) if main_line_ref is string and main_line_ref.split(".") | count == 2 else 0 }}' - - *delay_default - - service: 'esphome.{{ nspanel_name }}_component_val' - data: - id: line_main_d - val: '{{ (((main_line_ref_state > 0) - (main_line_ref_state < 0)) * (-1 if main_line_inverted else 1)) | int(0) }}' - continue_on_error: true ## Groups - repeat: for_each: '{{ pages_utilities.groups | list }}' @@ -9833,60 +9811,6 @@ action: icon_color: '{{ repeat.item.color }}' visible: '{{ icon_code in all_icons }}' continue_on_error: true - - alias: Utilities - Display value 1 - if: '{{ value1_enabled }}' - then: - - variables: - entity_id: '{{ repeat.item.value1 }}' - unit_of_measurement: '{{ state_attr(entity_id, "unit_of_measurement") | default("") }}' - - *delay_default - - *variable_entity - - service: 'esphome.{{ nspanel_name }}_component_text' - data: - id: '{{ repeat.item.name }}' - txt: *value_with_unit_and_translations - continue_on_error: true - - if: '{{ utilities_constructor }}' - then: - - *delay_default - - service: 'esphome.{{ nspanel_name }}_component_color' - data: - id: '{{ repeat.item.name }}' - color: '{{ repeat.item.color }}' - continue_on_error: true - - *delay_default - - service: 'esphome.{{ nspanel_name }}_components_visibility' - data: - ids: '{{ [repeat.item.name] }}' - visible: true - continue_on_error: true - - alias: Utilities - Display value 2 - if: '{{ value2_enabled }}' - then: - - variables: - entity_id: '{{ repeat.item.value2 }}' - unit_of_measurement: '{{ state_attr(entity_id, "unit_of_measurement") | default("") }}' - - *delay_default - - *variable_entity - - service: 'esphome.{{ nspanel_name }}_component_text' - data: - id: '{{ repeat.item.name }}b' - txt: *value_with_unit_and_translations - continue_on_error: true - - if: '{{ utilities_constructor }}' - then: - - *delay_default - - service: 'esphome.{{ nspanel_name }}_component_color' - data: - id: '{{ repeat.item.name }}b' - color: '{{ repeat.item.color }}' - continue_on_error: true - - *delay_default - - service: 'esphome.{{ nspanel_name }}_components_visibility' - data: - ids: '{{ [repeat.item.name ~ "b"] }}' - visible: true - continue_on_error: true - alias: Utilities - Label if: '{{ label_enabled }}' then: @@ -9908,51 +9832,102 @@ action: ids: '{{ [repeat.item.name ~ "_label"] }}' visible: true continue_on_error: true - - alias: Utilities - Line - if: - - '{{ icon_enabled or value1_enabled or value2_enabled or label_enabled }}' - - '{{ repeat.item.name not in ["home", "grid"] }}' + + - variables: + value1: "" + value2: "" + line_ref_state: > + {{ + states(repeat.item.line_ref) | float(0) + if repeat.item.line_ref is defined and repeat.item.line_ref is string and repeat.item.line_ref.split(".") | count == 2 + else 0 + }} + direction: '{{ (((line_ref_state > 0) - (line_ref_state < 0)) * (-3 if repeat.item.line_inverted is defined and repeat.item.line_inverted else 3)) | int(0) }}' + + - alias: Utilities - Display value 1 + if: '{{ value1_enabled }}' then: - variables: - line_ref_state: > - {{ - states(repeat.item.line_ref) | float(0) - if repeat.item.line_ref is defined and repeat.item.line_ref is string and repeat.item.line_ref.split(".") | count == 2 - else 0 - }} - - *delay_default - - service: 'esphome.{{ nspanel_name }}_component_val' - data: - id: '{{ repeat.item.name }}_line_d' - val: '{{ (((line_ref_state > 0) - (line_ref_state < 0)) * (-3 if repeat.item.line_inverted else 3)) | int(0) }}' - continue_on_error: true + entity_id: '{{ repeat.item.value1 }}' + unit_of_measurement: '{{ state_attr(entity_id, "unit_of_measurement") | default("") }}' + - *variable_entity + - variables: + value1: *value_with_unit_and_translations - if: '{{ utilities_constructor }}' then: - - variables: - rgb565: '{{ int(((repeat.item.color[0] //(2**3)) *(2**11))+((repeat.item.color[1] //(2**2)) *(2**5))+(repeat.item.color[2] //(2**3))) }}' - *delay_default - - service: 'esphome.{{ nspanel_name }}_command' + - service: 'esphome.{{ nspanel_name }}_component_color' data: - cmd: '{{ repeat.item.name }}_line.bco={{ rgb565 }}' + id: '{{ repeat.item.name }}' + color: '{{ repeat.item.color }}' continue_on_error: true - *delay_default - - service: 'esphome.{{ nspanel_name }}_command' - data: - cmd: '{{ repeat.item.name }}_line.bco1={{ rgb565 }}' - continue_on_error: true - - if: '{{ pages_utilities.cursor.width != 255 }}' - then: - - *delay_default - - service: 'esphome.{{ nspanel_name }}_command' - data: - cmd: '{{ repeat.item.name }}_line.wid={{ pages_utilities.cursor.width }}' - continue_on_error: true - - *delay_default - service: 'esphome.{{ nspanel_name }}_components_visibility' data: - ids: '{{ [repeat.item.name ~ "_line"] }}' + ids: '{{ [repeat.item.name] }}' visible: true continue_on_error: true + - alias: Utilities - Display value 2 + if: '{{ value2_enabled }}' + then: + - variables: + entity_id: '{{ repeat.item.value2 }}' + unit_of_measurement: '{{ state_attr(entity_id, "unit_of_measurement") | default("") }}' + - *variable_entity + - variables: + value2: *value_with_unit_and_translations + - if: '{{ utilities_constructor }}' + then: + - *delay_default + - service: 'esphome.{{ nspanel_name }}_component_color' + data: + id: '{{ repeat.item.name }}b' + color: '{{ repeat.item.color }}' + continue_on_error: true + - *delay_default + - service: 'esphome.{{ nspanel_name }}_components_visibility' + data: + ids: '{{ [repeat.item.name ~ "b"] }}' + visible: true + continue_on_error: true + - service: 'esphome.{{ nspanel_name }}_utilities_group_refresh' + data: + group_id: '{{ repeat.item.name }}' + value1: *value_with_unit_and_translations + value2: "" + direction: '{{ direction }}' + continue_on_error: true + - alias: Utilities - Line + if: + - '{{ icon_enabled or value1_enabled or value2_enabled or label_enabled }}' + - '{{ repeat.item.name not in ["grid"] }}' + - '{{ utilities_constructor }}' + then: + - variables: + rgb565: '{{ int(((repeat.item.color[0] //(2**3)) *(2**11))+((repeat.item.color[1] //(2**2)) *(2**5))+(repeat.item.color[2] //(2**3))) }}' + - *delay_default + - service: 'esphome.{{ nspanel_name }}_command' + data: + cmd: '{{ repeat.item.name }}_line.bco={{ rgb565 }}' + continue_on_error: true + - *delay_default + - service: 'esphome.{{ nspanel_name }}_command' + data: + cmd: '{{ repeat.item.name }}_line.bco1={{ rgb565 }}' + continue_on_error: true + - if: '{{ pages_utilities.cursor.width != 255 }}' + then: + - *delay_default + - service: 'esphome.{{ nspanel_name }}_command' + data: + cmd: '{{ repeat.item.name }}_line.wid={{ pages_utilities.cursor.width }}' + continue_on_error: true + - *delay_default + - service: 'esphome.{{ nspanel_name }}_components_visibility' + data: + ids: '{{ [repeat.item.name ~ "_line"] }}' + visible: true + continue_on_error: true ##### Button click ##### - alias: Button click @@ -10574,7 +10549,7 @@ action: list1: '{{ pages_utilities.groups | selectattr("value1", "defined") | selectattr("value1", "eq", trigger.entity_id) | list }}' list2: '{{ pages_utilities.groups | selectattr("value2", "defined") | selectattr("value2", "eq", trigger.entity_id) | list }}' list3: '{{ pages_utilities.groups | selectattr("line_ref", "defined") | selectattr("line_ref", "eq", trigger.entity_id) | list }}' - full_list: '{{ list1 + list2 }}' + full_list: '{{ list1 + list2 + list3 }}' groups: '{{ full_list | map(attribute="name") | unique | list }}' - repeat: for_each: '{{ pages_utilities.groups | selectattr("name", "in", groups) | list }}'