Support for icon from attributes on Entities pages

This commit is contained in:
Edward Firmo
2023-04-13 13:53:35 +02:00
committed by GitHub
parent 1d2138fefd
commit cfb076a01b

View File

@@ -4806,13 +4806,17 @@ action:
then:
- variables:
repeat_item_state: "{{ states(repeat.item.entity) | default('unavailable') }}"
- if: "{{ repeat.item.icon | length > 0 }}"
repeat_item_icon: >
{% if repeat.item.icon is string and repeat.item.icon | length > 0 %}{{ nextion.icons.all[repeat.item.icon.split(':')[1]] | default(repeat.item.icon) }}
{% elif state_attr(repeat.item.entity, 'icon') | default('') not in ['unavailable', 'unknown', '', None] %}{{ nextion.icons.all[state_attr(repeat.item.entity, 'icon').split(':')[1]] | default(None) }}
{% endif %}
- if: "{{ repeat_item_icon is string and repeat_item_icon | length > 0 }}"
then:
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: "{{ repeat.item.component }}_pic"
message: "{{ repeat.item.icon }}"
message: "{{ repeat_item_icon }}"
continue_on_error: true
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
@@ -5312,7 +5316,7 @@ action:
##### Long Press Entity Name #####
entity_long_name: "{{ last_click_button.name }}"
##### Long Press Entity Icon #####
entity_long_icon: "{{ nextion.icons.all[last_click_button.icon.split(':')[1]] | default(last_click_button.icon if last_click_button.icon is string else '\U0000E2D5') }}" # DEBUG #
entity_long_icon: "{{ nextion.icons.all[last_click_button.icon.split(':')[1]] | default(last_click_button.icon if last_click_button.icon is string else '\U0000E2D5') }}"
##### Long Press Entity Icon Color #####
entity_long_icon_color: "{{ last_click_button.icon_color_rgb if is_number(last_click_button.icon_color_rgb) else ((last_click_button.icon_color_rgb[0] //(2**3)) *(2**11))+((last_click_button.icon_color_rgb[1] //(2**2)) *(2**5))+(last_click_button.icon_color_rgb[2] //(2**3)) }}"
##### Current Page #####