Code optimization

Code optimization
This commit is contained in:
Blackymas
2023-04-05 22:57:27 +02:00
committed by GitHub

View File

@@ -4049,20 +4049,8 @@ action:
- variables:
notification_unread_state: "{{ states(notification_unread) | default('unavailable') if notification_unread is string else 'unavailable' }}"
notification_text_state: "{{ states(notification_text) | default(None) if notification_text is string else None }}"
set_button04_icon: >-
{%- if notification_unread_state == 'on' and notification_text_state | length > 0 -%} {{ page_home.buttons[3].icon}}
{%- elif notification_unread_state == 'off' and notification_text_state | length > 0 -%} {{ page_home.buttons[3].icon }}
{%- else -%} {{ nextion.icons.blank }}
{%- endif -%}
set_button04_icon_font: >-
{%- if notification_unread_state == 'on' and notification_text_state | length > 0 -%}
{% set rgb = page_home.buttons[3].color_rgb.on %}
{{ rgb if is_number(rgb) else ((rgb[0] //(2**3)) *(2**11))+((rgb[1] //(2**2)) *(2**5))+(rgb[2] //(2**3)) }}
{%- elif notification_unread_state == 'off' and notification_text_state | length > 0 -%}
{% set rgb = page_home.buttons[3].color_rgb.off %}
{{ rgb if is_number(rgb) else ((rgb[0] //(2**3)) *(2**11))+((rgb[1] //(2**2)) *(2**5))+(rgb[2] //(2**3)) }}
{%- else -%} {{ nextion.colors.grey_light }}
{%- endif -%}
set_button04_icon: "{{ page_home.buttons[3].icon if notification_unread_state in ['on', 'off'] and notification_text_state | length > 0 else nextion.icons.blank }}"
set_button04_icon_font: "{{ (page_home.buttons[3].color_rgb[notification_unread_state] if is_number(page_home.buttons[3].color_rgb[notification_unread_state]) else ((page_home.buttons[3].color_rgb[notification_unread_state][0] //(2**3)) *(2**11))+((page_home.buttons[3].color_rgb[notification_unread_state][1] //(2**2)) *(2**5))+(page_home.buttons[3].color_rgb[notification_unread_state][2] //(2**3))) if notification_unread_state in ['on', 'off'] and notification_text_state | length > 0 else nextion.colors.grey_light }}"
##### SET ICON Font - Notify #####
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
@@ -4777,10 +4765,7 @@ action:
# HVAC Button PIC
- variables:
heating_bt_pic: >-
{%- if hvac_mode == 'off' -%} {{ nextion.pics.heating.button.off }}
{%- else -%} {{ nextion.pics.heating.button.on }}
{%- endif -%}
heating_bt_pic: "{{ nextion.pics.heating.button.off if hvac_mode == 'off' else nextion.pics.heating.button.on }}"
- *delay-default
- service: "{{ nextion.commands.printf }}"
data:
@@ -5829,10 +5814,7 @@ action:
- *variables-weather
- variables:
heating_state: "{{ mui[language].climate.states.off if trigger.event.data.new_state.state == 'off' else mui[language].climate.states.on }}"
heating_bt_pic: >-
{%- if trigger.event.data.new_state.state == 'off' -%} {{ nextion.pics.heating.button.off }}
{%- else -%} {{ nextion.pics.heating.button.on }}
{%- endif -%}
heating_bt_pic: "{{ nextion.pics.heating.button.off if trigger.event.data.new_state.state == 'off' else nextion.pics.heating.button.on }}"
- service: "{{ nextion.commands.text_printf }}"
data: