From 1a46c85e6e8e64d16d6b9d52cf3b9511a150f8c8 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 22 May 2023 13:56:34 +0200 Subject: [PATCH] Enable users select alignment for entity values (#753) * Enable users select alignment for entity values Users will be able to select the alignment for the column with values on the entity pages. The options are: - Right (default) - Center - Left solves #732 * Add support to `xcen` on `set_entity` --- nspanel_blueprint.yaml | 27 +++++++++++++++++++++++++++ nspanel_esphome.yaml | 5 +++++ 2 files changed, 32 insertions(+) diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 9cd8424..1b4dd12 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -2252,6 +2252,22 @@ blueprint: *Icon color which should be displayed (default color is set)* default: [200, 204, 200] #52857 Grey super light selector: *color-selector + entitypages_value_alignment: + name: Value column alignment + description: > + *Entity pages* + *Select the alignment for the column containing the values on the entity pages.* + default: "0" + selector: + select: + multiple: false + options: + - label: "Right (default)" + value: "0" + - label: "Center" + value: "1" + - label: "Left" + value: "2" ##### Entity page 01 - Entities ##### ##### PLACEHOLDER ###################################################################### placeholder12: @@ -7299,6 +7315,16 @@ action: - &variables-entity_pages variables: ##### Entity pages ##### + entitypages_value_alignment_temp: !input 'entitypages_value_alignment' + entitypages_value_alignment: > + {{ + entitypages_value_alignment_temp | int + if + is_number(entitypages_value_alignment_temp) and + entitypages_value_alignment_temp | int >= 0 and + entitypages_value_alignment_temp | int <= 2 + else 0 + }} entity_pages_labels: - label: !input 'entity_page01_label' - label: !input 'entity_page02_label' @@ -7506,6 +7532,7 @@ action: {%- else -%} {{ state_attr(repeat.item.entity, "friendly_name") | default(mui[language].no_name) }} {%- endif -%} ent_value: '{{ repeat_item_state ~ ((state_attr(repeat.item.entity, "unit_of_measurement") | default("")) if state_attr(repeat.item.entity, "unit_of_measurement") is string else "") }}' + ent_value_xcen: '{{ entitypages_value_alignment }}' continue_on_error: true ## PAGE WEATHER (WEATHER01 to WEATHER05) ## diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 819c762..0d76931 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -410,6 +410,7 @@ api: ent_icon: string ent_label: string ent_value: string + ent_value_xcen: string then: - wait_until: binary_sensor.is_on: nextion_init @@ -417,12 +418,16 @@ api: // ESP_LOGD("nextion", "set entity %s", ent_id.c_str()); std::string enticon = ent_id.c_str() + std::string("_pic"); std::string entlabel = ent_id.c_str() + std::string("_label"); + std::string entxcen = ent_id.c_str() + std::string(".xcen=") + ent_value_xcen.c_str(); id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str()); if (strcmp(ent_icon.c_str(), "0") != 0) { id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str()); } id(disp1).set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str()); id(disp1).set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str()); + if (strcmp(ent_value_xcen.c_str(), "0") != 0) { + id(disp1).send_command_printf("%s", entxcen.c_str()); + } ##### START - GLOBALS CONFIGURATION ##### globals: