From 5d523eabd6d133b77d3a23b386cc17e7163137f8 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:20:29 +0200 Subject: [PATCH] Supports icon from attributes for chips --- nspanel_blueprint.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 9c5d41b..4f2dd5f 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -4031,6 +4031,11 @@ action: - variables: repeat_item_state: "{{ states(repeat.item.entity) | default('unavailable') }}" repeat_item_state_is_on: "{{ repeat_item_state in ['on', 'open'] }}" + repeat_item_icon: > + {% if repeat_item_state_is_on and repeat.item.icon is string and repeat.item.icon | length > 0 %}{{ nextion.icons.all[repeat.item.icon.split(':')[1]] | default(repeat.item.icon) }} + {% elif repeat_item_state_is_on and state_attr(repeat.item.entity, 'icon') | default('') not in ['unavailable', 'unknown', '', None] %}{{ nextion.icons.all[state_attr(repeat.item.entity, 'icon').split(':')[1]] | default(nextion.icons.blank) }} + {% else %}{{ nextion.icons.blank }} + {% endif %} - if: "{{ repeat_item_state_is_on }}" then: ### ICON Font Color ### @@ -4045,7 +4050,7 @@ action: - service: "{{ nextion.commands.text_printf }}" data: component: "{{ repeat.item.component }}" - message: "{{ nextion.icons.all[repeat.item.icon.split(':')[1]] | default(repeat.item.icon if repeat.item.icon is string else '\U0000E2D5') if repeat_item_state_is_on else nextion.icons.blank }}" + message: "{{ repeat_item_icon }}" continue_on_error: true # {{ is_state(repeat.item.entity, 'on') | default(False) if repeat.item.entity is string else 'unavailable' }}