Used aliases for element on home page (#697)

- Removed duplicated code used to update element in the home page and used aliases instead.
- Breaking down long lined to improve readability.
This commit is contained in:
Edward Firmo
2023-04-20 13:08:31 +02:00
committed by GitHub
parent e78b77de9e
commit f01f3d5e4e

View File

@@ -3724,17 +3724,20 @@ action:
- if: "{{ old_state.page == nextion.pages.climate and climate_optimistic }}" - if: "{{ old_state.page == nextion.pages.climate and climate_optimistic }}"
then: then:
- variables: - variables:
display_target_temperature_state: "{{ states(display_target_temperature) | default('unavailable') if display_target_temperature is string else 'unavailable' }}" display_target_temperature_state: >
- if: "{{ is_number(display_target_temperature_state) }}" {{
then: states(display_target_temperature) | default('unavailable')
- *variables-settings_entity if display_target_temperature is string
- if: "{{ settings_entity_domain == 'climate' }}" else 'unavailable'
then: }}
- service: climate.set_temperature - condition: "{{ is_number(display_target_temperature_state) }}"
data: - *variables-settings_entity
entity_id: "{{ settings_entity_dict.entity }}" - condition: "{{ settings_entity_domain == 'climate' }}"
temperature: "{{ display_target_temperature_state }}" - service: climate.set_temperature
continue_on_error: true data:
entity_id: "{{ settings_entity_dict.entity }}"
temperature: "{{ display_target_temperature_state }}"
continue_on_error: true
- choose: - choose:
## PAGE HOME ## ## PAGE HOME ##
- alias: Home page - alias: Home page
@@ -3744,53 +3747,35 @@ action:
data: data:
entity: "{{ nspanel_event }}" entity: "{{ nspanel_event }}"
continue_on_error: true continue_on_error: true
##### NSPanel Date ##### - &refresh-page_home-date_time
### DATE Font Color ### if: "{{ true }}"
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.date
message: >
{{
page_home.general.date.label.color_rgb
if is_number(page_home.general.date.label.color_rgb)
else ((page_home.general.date.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.date.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.date.label.color_rgb[2] //(2**3))
}}
continue_on_error: true
### DATE Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.date
message: "{{ (dict.values(mui[language].weekdays) | list)[now().weekday()] ~ ', ' ~ as_timestamp(now()) | timestamp_custom(date_format) }}"
continue_on_error: true
##### NSPanel Time #####
### TIME Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.time
message: >
{{
page_home.general.time.label.color_rgb
if is_number(page_home.general.time.label.color_rgb)
else ((page_home.general.time.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.time.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.time.label.color_rgb[2] //(2**3))
}}
continue_on_error: true
### TIME Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.time
message: "{{ time }}"
continue_on_error: true
- if: "{{ meridiem }}"
then: then:
### TIME Meridiem Font Color ### ##### NSPanel Date #####
### DATE Font Color ###
- *delay-default - *delay-default
- service: "{{ nextion.commands.font_color }}" - service: "{{ nextion.commands.font_color }}"
data: data:
component: home.meridiem component: home.date
message: >
{{
page_home.general.date.label.color_rgb
if is_number(page_home.general.date.label.color_rgb)
else ((page_home.general.date.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.date.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.date.label.color_rgb[2] //(2**3))
}}
continue_on_error: true
### DATE Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.date
message: "{{ (dict.values(mui[language].weekdays) | list)[now().weekday()] ~ ', ' ~ as_timestamp(now()) | timestamp_custom(date_format) }}"
continue_on_error: true
##### NSPanel Time #####
### TIME Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.time
message: > message: >
{{ {{
page_home.general.time.label.color_rgb page_home.general.time.label.color_rgb
@@ -3798,87 +3783,125 @@ action:
else ((page_home.general.time.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.time.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.time.label.color_rgb[2] //(2**3)) else ((page_home.general.time.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.time.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.time.label.color_rgb[2] //(2**3))
}} }}
continue_on_error: true continue_on_error: true
### TIME Meridiem Font ### ### TIME Font ###
- *delay-default - *delay-default
- service: "{{ nextion.commands.text_printf }}" - service: "{{ nextion.commands.text_printf }}"
data: data:
component: home.meridiem component: home.time
message: "{{ meridiem }}" message: "{{ time }}"
continue_on_error: true continue_on_error: true
- if: "{{ meridiem }}"
then:
### TIME Meridiem Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.meridiem
message: >
{{
page_home.general.time.label.color_rgb
if is_number(page_home.general.time.label.color_rgb)
else ((page_home.general.time.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.time.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.time.label.color_rgb[2] //(2**3))
}}
continue_on_error: true
### TIME Meridiem Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.meridiem
message: "{{ meridiem }}"
continue_on_error: true
##### NSPanel Outdoor Temp ##### - &refresh-page_home-outdoor_temp
- variables: if: "{{ true }}"
outdoor_temp_state: "{{ states(outdoortemp) | default('unavailable') if outdoortemp is string else 'unavailable' }}"
outdoor_temp: "{{ outdoor_temp_state if is_number(outdoor_temp_state) else state_attr(weather_entity, 'temperature') | default('unavailable') if weather_entity is string else 'unavailable' }}"
- if: "{{ is_number(outdoor_temp) }}"
then: then:
### LABEL Outdoor Temp Font Color ### ##### NSPanel Outdoor Temp #####
- *delay-default - variables:
- service: "{{ nextion.commands.font_color }}" outdoor_temp_state: >
data:
component: home.outdoor_temp
message: >
{{ {{
page_home.general.outdoor_temp.label.color_rgb states(outdoortemp) | default('unavailable')
if is_number(page_home.general.outdoor_temp.label.color_rgb) if outdoortemp is string and outdoortemp is match 'sensor.'
else ((page_home.general.outdoor_temp.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.outdoor_temp.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.outdoor_temp.label.color_rgb[2] //(2**3)) else 'unavailable'
}} }}
continue_on_error: true outdoor_temp: >
### LABEL Outdoor Temp Font ### {{
- *delay-default outdoor_temp_state if is_number(outdoor_temp_state)
- service: "{{ nextion.commands.text_printf }}" else state_attr(weather_entity, 'temperature') | default('unavailable')
data: if weather_entity is string else 'unavailable'
component: home.outdoor_temp }}
message: "{{ outdoor_temp | round(1) ~ temperature_units }}" - if: "{{ is_number(outdoor_temp) }}"
continue_on_error: true then:
### LABEL Outdoor Temp Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.outdoor_temp
message: >
{{
page_home.general.outdoor_temp.label.color_rgb
if is_number(page_home.general.outdoor_temp.label.color_rgb)
else ((page_home.general.outdoor_temp.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.outdoor_temp.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.outdoor_temp.label.color_rgb[2] //(2**3))
}}
continue_on_error: true
### LABEL Outdoor Temp Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.outdoor_temp
message: "{{ outdoor_temp | round(1) ~ temperature_units }}"
continue_on_error: true
##### NSPanel Indoor Temp ##### - &refresh-page_home-indoor_temp
- variables: if: "{{ true }}"
indoor_temp_state: "{{ states(indoortemp) | default('unavailable') if indoortemp is string and indoortemp is match 'sensor.' else states(nspaneltemp) }}"
- if: "{{ is_number(indoor_temp_state) }}"
then: then:
### ICON Indoor Temp Font Color ### ##### NSPanel Indoor Temp #####
- *delay-default - variables:
- service: "{{ nextion.commands.font_color }}" indoor_temp_state: "{{ states(indoortemp) | default('unavailable') if indoortemp is string and indoortemp is match 'sensor.' else states(nspaneltemp) }}"
data: - if: "{{ is_number(indoor_temp_state) }}"
component: home.indoortempicon then:
message: > ### ICON Indoor Temp Font Color ###
{{ - *delay-default
page_home.general.indoor_temp.icon.color_rgb - service: "{{ nextion.commands.font_color }}"
if is_number(page_home.general.indoor_temp.icon.color_rgb) data:
else ((page_home.general.indoor_temp.icon.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.indoor_temp.icon.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.indoor_temp.icon.color_rgb[2] //(2**3)) component: home.indoortempicon
}} message: >
continue_on_error: true {{
### ICON Indoor Temp Font ### page_home.general.indoor_temp.icon.color_rgb
- *delay-default if is_number(page_home.general.indoor_temp.icon.color_rgb)
- service: "{{ nextion.commands.text_printf }}" else ((page_home.general.indoor_temp.icon.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.indoor_temp.icon.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.indoor_temp.icon.color_rgb[2] //(2**3))
data: }}
component: home.indoortempicon continue_on_error: true
message: "{{ nextion.icons.all[page_home.general.indoor_temp.icon.icon.split(':')[1]] | default(page_home.general.indoor_temp.icon.icon if page_home.general.indoor_temp.icon.icon is string else '\U0000E2D5') }}" ### ICON Indoor Temp Font ###
continue_on_error: true - *delay-default
### LABEL Indoor Temp Font Color ### - service: "{{ nextion.commands.text_printf }}"
- *delay-default data:
- service: "{{ nextion.commands.font_color }}" component: home.indoortempicon
data: message: "{{ nextion.icons.all[page_home.general.indoor_temp.icon.icon.split(':')[1]] | default(page_home.general.indoor_temp.icon.icon if page_home.general.indoor_temp.icon.icon is string else '\U0000E2D5') }}"
component: home.current_temp continue_on_error: true
message: > ### LABEL Indoor Temp Font Color ###
{{ - *delay-default
page_home.general.indoor_temp.label.color_rgb - service: "{{ nextion.commands.font_color }}"
if is_number(page_home.general.indoor_temp.label.color_rgb) data:
else ((page_home.general.indoor_temp.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.indoor_temp.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.indoor_temp.label.color_rgb[2] //(2**3)) component: home.current_temp
}} message: >
continue_on_error: true {{
### LABEL Indoor Temp Font ### page_home.general.indoor_temp.label.color_rgb
- *delay-default if is_number(page_home.general.indoor_temp.label.color_rgb)
- service: "{{ nextion.commands.text_printf }}" else ((page_home.general.indoor_temp.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.indoor_temp.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.indoor_temp.label.color_rgb[2] //(2**3))
data: }}
component: home.current_temp continue_on_error: true
message: "{{ (indoor_temp_state | round(1) ~ temperature_units) if is_number(indoor_temp_state) else (mui[language].unavailable if indoor_temp_state in ['unavailable', 'unknown', None] else indoor_temp_state) }}" ### LABEL Indoor Temp Font ###
continue_on_error: true - *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.current_temp
message: "{{ (indoor_temp_state | round(1) ~ temperature_units) if is_number(indoor_temp_state) else (mui[language].unavailable if indoor_temp_state in ['unavailable', 'unknown', None] else indoor_temp_state) }}"
continue_on_error: true
##### Weather Icon Home Page ##### ##### Weather Icon Home Page #####
- *delay-default - *delay-default
- service: "{{ nextion.commands.printf }}" - &refresh-page_home-weather_pic
service: "{{ nextion.commands.printf }}"
data: data:
cmd: home.weather.pic={{ nextion.pics.weather[states(weather_entity) | default('unavailable') if weather_entity is string else 'unavailable'] | default(None) }} cmd: home.weather.pic={{ nextion.pics.weather[states(weather_entity) | default('unavailable') if weather_entity is string else 'unavailable'] | default(None) }}
continue_on_error: true continue_on_error: true
@@ -4084,7 +4107,12 @@ action:
- service: "{{ nextion.commands.font_color }}" - service: "{{ nextion.commands.font_color }}"
data: data:
component: "{{ repeat.item.page }}.{{ repeat.item.component }}_icon" component: "{{ repeat.item.page }}.{{ repeat.item.component }}_icon"
message: "{{ repeat.item.icon_color_rgb if is_number(repeat.item.icon_color_rgb) else ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.icon_color_rgb[2] //(2**3)) }}" message: >
{{
repeat.item.icon_color_rgb
if is_number(repeat.item.icon_color_rgb)
else ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.icon_color_rgb[2] //(2**3))
}}
continue_on_error: true continue_on_error: true
### ICON Font ### ### ICON Font ###
- *delay-default - *delay-default
@@ -4103,14 +4131,24 @@ action:
- service: "{{ nextion.commands.font_color }}" - service: "{{ nextion.commands.font_color }}"
data: data:
component: "{{ repeat.item.page }}.{{ repeat.item.component }}_state" component: "{{ repeat.item.page }}.{{ repeat.item.component }}_state"
message: "{{ repeat.item.label_color_rgb if is_number(repeat.item.label_color_rgb) else ((repeat.item.label_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.label_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.label_color_rgb[2] //(2**3)) }}" message: >
{{
repeat.item.label_color_rgb
if is_number(repeat.item.label_color_rgb)
else ((repeat.item.label_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.label_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.label_color_rgb[2] //(2**3))
}}
continue_on_error: true continue_on_error: true
### LABEL Font ### ### LABEL Font ###
- *delay-default - *delay-default
- service: "{{ nextion.commands.text_printf }}" - service: "{{ nextion.commands.text_printf }}"
data: data:
component: "{{ repeat.item.page }}.{{ repeat.item.component }}_state" component: "{{ repeat.item.page }}.{{ repeat.item.component }}_state"
message: "{{ (repeat_item_state | round(1) ~ state_attr(repeat.item.entity, 'unit_of_measurement') | default('')) if is_number(repeat_item_state) else repeat_item_state }}" message: >
{{
(repeat_item_state | round(1) ~ state_attr(repeat.item.entity, 'unit_of_measurement') | default(''))
if is_number(repeat_item_state)
else repeat_item_state
}}
continue_on_error: true continue_on_error: true
##### Set notify icon ##### ##### Set notify icon #####
@@ -4120,8 +4158,22 @@ action:
then: then:
- variables: - variables:
notification_text_state: "{{ states(notification_text) | default(None) if notification_text is string else None }}" notification_text_state: "{{ states(notification_text) | default(None) if notification_text is string else None }}"
set_button04_icon: "{{ nextion.icons.all[page_home.buttons[3].icon.split(':')[1]] | default(page_home.buttons[3].icon if page_home.buttons[3].icon is string else '\U0000E2D5') if notification_unread_state == 'on' and notification_text_state | length > 0 else nextion.icons.blank }}" set_button04_icon: >
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 }}" {{
nextion.icons.all[page_home.buttons[3].icon.split(':')[1]] | default(page_home.buttons[3].icon if page_home.buttons[3].icon is string else '\U0000E2D5')
if notification_unread_state == 'on' 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 ##### ##### SET ICON Font - Notify #####
- *delay-default - *delay-default
- service: "{{ nextion.commands.text_printf }}" - service: "{{ nextion.commands.text_printf }}"
@@ -4146,7 +4198,12 @@ action:
- service: "{{ nextion.commands.font_color }}" - service: "{{ nextion.commands.font_color }}"
data: data:
component: home.button05_icon component: home.button05_icon
message: "{{ page_home.buttons[4].color_rgb.on if is_number(page_home.buttons[4].color_rgb.on) else ((page_home.buttons[4].color_rgb.on[0] //(2**3)) *(2**11))+((page_home.buttons[4].color_rgb.on[1] //(2**2)) *(2**5))+(page_home.buttons[4].color_rgb.on[2] //(2**3)) }}" message: >
{{
page_home.buttons[4].color_rgb.on
if is_number(page_home.buttons[4].color_rgb.on)
else ((page_home.buttons[4].color_rgb.on[0] //(2**3)) *(2**11))+((page_home.buttons[4].color_rgb.on[1] //(2**2)) *(2**5))+(page_home.buttons[4].color_rgb.on[2] //(2**3))
}}
continue_on_error: true continue_on_error: true
### ICON Font ### ### ICON Font ###
- *delay-default - *delay-default
@@ -4170,7 +4227,12 @@ action:
- service: "{{ nextion.commands.font_color }}" - service: "{{ nextion.commands.font_color }}"
data: data:
component: home.button06_icon component: home.button06_icon
message: "{{ page_home.buttons[5].color_rgb.on if is_number(page_home.buttons[5].color_rgb.on) else ((page_home.buttons[5].color_rgb.on[0] //(2**3)) *(2**11))+((page_home.buttons[5].color_rgb.on[1] //(2**2)) *(2**5))+(page_home.buttons[5].color_rgb.on[2] //(2**3)) }}" message: >
{{
page_home.buttons[5].color_rgb.on
if is_number(page_home.buttons[5].color_rgb.on)
else ((page_home.buttons[5].color_rgb.on[0] //(2**3)) *(2**11))+((page_home.buttons[5].color_rgb.on[1] //(2**2)) *(2**5))+(page_home.buttons[5].color_rgb.on[2] //(2**3))
}}
continue_on_error: true continue_on_error: true
### ICON Font ### ### ICON Font ###
- *delay-default - *delay-default
@@ -4478,29 +4540,41 @@ action:
}} }}
# ICON Font Color # ICON Font Color
btn_icon_font: > btn_icon_font: >
{% if not current_entity_state_available %} {{ nextion.colors.red }} {% if not current_entity_state_available %}{{ nextion.colors.red }}
{% elif current_entity_state in ['off', 'closed', 'closing'] or (item_domain == 'person' and current_entity_state != 'home') %} {{ nextion.colors.grey_light }} {% elif current_entity_state in ['off', 'closed', 'closing'] or (item_domain == 'person' and current_entity_state != 'home') %}{{ nextion.colors.grey_light }}
{% elif item_domain in ['button', 'input_button', 'scene'] and trigger.id is match 'current_state_entity' %} {{ repeat.item.icon_color_rgb if is_number(repeat.item.icon_color_rgb) else ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.icon_color_rgb[2] //(2**3)) }} {% elif item_domain in ['button', 'input_button', 'scene'] and trigger.id is match 'current_state_entity' %}
{% elif item_domain in ['button', 'input_button', 'scene'] %} {{ nextion.colors.grey_light }} {{
{% elif current_entity_state in ['on', 'open', 'opening', 'home'] or (item_domain == 'climate' and current_entity_state != 'off') %} {{ repeat.item.icon_color_rgb if is_number(repeat.item.icon_color_rgb) else ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.icon_color_rgb[2] //(2**3)) }} repeat.item.icon_color_rgb
if is_number(repeat.item.icon_color_rgb)
else ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.icon_color_rgb[2] //(2**3))
}}
{% elif item_domain in ['button', 'input_button', 'scene'] %}{{ nextion.colors.grey_light }}
{% elif current_entity_state in ['on', 'open', 'opening', 'home'] or (item_domain == 'climate' and current_entity_state != 'off') %}
{{
repeat.item.icon_color_rgb
if is_number(repeat.item.icon_color_rgb)
else ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.icon_color_rgb[2] //(2**3))
}}
{% else %}{{ nextion.colors.red }} {% else %}{{ nextion.colors.red }}
{% endif %} {% endif %}
# LABEL Font Color # LABEL Font Color
btn_txt_font: >- btn_txt_font: >-
{% if not current_entity_state_available %} {{ nextion.colors.white }} {% if not current_entity_state_available %} {{ nextion.colors.white }}
{% elif current_entity_state in ['off', 'closed', 'closing'] or (item_domain == 'person' and current_entity_state != 'home') %} {{ nextion.colors.white }} {% elif current_entity_state in ['off', 'closed', 'closing'] or (item_domain == 'person' and current_entity_state != 'home') %}{{ nextion.colors.white }}
{% elif item_domain in ['button', 'input_button', 'scene'] and trigger.id is match 'current_state_entity' %} {{ nextion.colors.grey_dark }} {% elif item_domain in ['button', 'input_button', 'scene'] and trigger.id is match 'current_state_entity' %}{{ nextion.colors.grey_dark }}
{% elif item_domain in ['button', 'input_button', 'scene'] %} {{ nextion.colors.white }} {% elif item_domain in ['button', 'input_button', 'scene'] %}{{ nextion.colors.white }}
{% elif current_entity_state in ['on', 'open', 'opening', 'home'] or (item_domain == 'climate' and current_entity_state != 'off') %} {{ nextion.colors.grey_dark }} {% elif current_entity_state in ['on', 'open', 'opening', 'home'] or (item_domain == 'climate' and current_entity_state != 'off') %}{{ nextion.colors.grey_dark }}
{% else %}{{ nextion.colors.white }} {% else %}{{ nextion.colors.white }}
{% endif %} {% endif %}
# BRIGHTNESS Font Color # BRIGHTNESS Font Color
btn_bri_font: "{{ btn_txt_font }}" #"{{ nextion.colors.grey_dark }}" btn_bri_font: "{{ btn_txt_font }}" #"{{ nextion.colors.grey_dark }}"
# ICON Value # ICON Value
btn_icon: > btn_icon: >
{% if not current_entity_state_available %} {{ nextion.icons.buttons.unknown }} {% if not current_entity_state_available %}{{ nextion.icons.buttons.unknown }}
{% elif repeat.item.icon | length > 0 %} {{ nextion.icons.all[repeat.item.icon.split(':')[1]] | default(repeat.item.icon if repeat.item.icon is string else '\U0000E2D5') }} {% elif repeat.item.icon | length > 0 %}
{% elif repeat.item.entity and repeat.item.entity.split('.') | count > 1 %} {{ nextion.icons.buttons[repeat.item.entity.split('.')[0] if repeat.item.entity else 'unknown'] }} {{ nextion.icons.all[repeat.item.icon.split(':')[1]] | default(repeat.item.icon if repeat.item.icon is string else '\U0000E2D5') }}
{% elif repeat.item.entity and repeat.item.entity.split('.') | count > 1 %}
{{ nextion.icons.buttons[repeat.item.entity.split('.')[0] if repeat.item.entity else 'unknown'] }}
{% else %}{{ nextion.icons.buttons.unknown }} {% else %}{{ nextion.icons.buttons.unknown }}
{% endif %} {% endif %}
# LABEL Value # LABEL Value
@@ -4508,9 +4582,12 @@ action:
# BRIGHTNESS Value # BRIGHTNESS Value
btn_bri_txt: >- btn_bri_txt: >-
{% if not current_entity_state_available %} 0 {% if not current_entity_state_available %} 0
{% elif item_domain == 'light' and current_entity_state == 'on' and state_attr(repeat.item.entity, 'brightness') != None %} {{ (state_attr(repeat.item.entity, 'brightness') | int * 100 /255) | round(0) }}% {% elif item_domain == 'light' and current_entity_state == 'on' and state_attr(repeat.item.entity, 'brightness') != None %}
{% elif item_domain == 'cover' and current_entity_state in ['open', 'opening', 'closing'] and state_attr(repeat.item.entity, 'current_position') != None %} {{ (state_attr(repeat.item.entity, 'current_position') | int(100)) | round(0) }}% {{ (state_attr(repeat.item.entity, 'brightness') | int * 100 /255) | round(0) }}%
{% elif item_domain == 'climate' and current_entity_state != 'off' and state_attr(repeat.item.entity, "current_temperature") != None %} {{ (state_attr(repeat.item.entity, "current_temperature") | float) | round(0) }}{{ temperature_units }} {% elif item_domain == 'cover' and current_entity_state in ['open', 'opening', 'closing'] and state_attr(repeat.item.entity, 'current_position') != None %}
{{ (state_attr(repeat.item.entity, 'current_position') | int(100)) | round(0) }}%
{% elif item_domain == 'climate' and current_entity_state != 'off' and state_attr(repeat.item.entity, "current_temperature") != None %}
{{ (state_attr(repeat.item.entity, "current_temperature") | float) | round(0) }}{{ temperature_units }}
{% else -%} 0 {% else -%} 0
{% endif -%} {% endif -%}
- *delay-default - *delay-default
@@ -4535,7 +4612,12 @@ action:
btn_id: "{{ repeat.item.page }}.{{ repeat.item.component }}" btn_id: "{{ repeat.item.page }}.{{ repeat.item.component }}"
btn_pic: "{{ nextion.pics.button.off }}" btn_pic: "{{ nextion.pics.button.off }}"
btn_bg: "{{ nextion.colors.grey_dark }}" btn_bg: "{{ nextion.colors.grey_dark }}"
btn_icon_font: "{{ repeat.item.icon_color_rgb if is_number(repeat.item.icon_color_rgb) else ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.icon_color_rgb[2] //(2**3)) }}" btn_icon_font: >
{{
repeat.item.icon_color_rgb
if is_number(repeat.item.icon_color_rgb)
else ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.icon_color_rgb[2] //(2**3))
}}
btn_txt_font: "{{ nextion.colors.white }}" btn_txt_font: "{{ nextion.colors.white }}"
btn_bri_font: "{{ btn_bri_font }}" btn_bri_font: "{{ btn_bri_font }}"
btn_icon: "{{ btn_icon }}" btn_icon: "{{ btn_icon }}"
@@ -4557,20 +4639,49 @@ action:
- service: "{{ nextion.commands.text_printf }}" - service: "{{ nextion.commands.text_printf }}"
data: data:
component: lightsettings.light_name component: lightsettings.light_name
message: "{{ settings_entity_dict.name if settings_entity_dict.name is defined and settings_entity_dict.name is string and settings_entity_dict.name | length > 0 else state_attr(settings_entity_dict.entity, 'friendly_name') if state_attr(settings_entity_dict.entity, 'friendly_name') | length > 0 else ('Light' ~ (': ' ~ settings_entity_dict.component) if settings_entity_dict.component is string and settings_entity_dict.component | length > 0) }}" message: >
{{
settings_entity_dict.name
if settings_entity_dict.name is defined and settings_entity_dict.name is string and settings_entity_dict.name | length > 0
else
(
state_attr(settings_entity_dict.entity, 'friendly_name')
if state_attr(settings_entity_dict.entity, 'friendly_name') | length > 0
else
(
'Light' ~ (': ' ~ settings_entity_dict.component)
if settings_entity_dict.component is string and settings_entity_dict.component | length > 0
)
)
}}
continue_on_error: true continue_on_error: true
##### LIGHT ICON - ON / OFF ##### ##### LIGHT ICON - ON / OFF #####
- *delay-default - *delay-default
- service: "{{ nextion.commands.text_printf }}" - service: "{{ nextion.commands.text_printf }}"
data: data:
component: lightsettings.icon_state component: lightsettings.icon_state
message: "{{ nextion.icons.all[settings_entity_dict.icon.split(':')[1]] | default(settings_entity_dict.icon if settings_entity_dict.icon is defined and settings_entity_dict.icon is string else nextion.icons.buttons.light) if settings_entity_dict.icon not in ['unavailable', 'unknown', None] and settings_entity_dict.icon | length > 0 else nextion.icons.buttons.light }}" message: >
{{
nextion.icons.all[settings_entity_dict.icon.split(':')[1]] | default(settings_entity_dict.icon if settings_entity_dict.icon is defined and settings_entity_dict.icon is string else nextion.icons.buttons.light)
if settings_entity_dict.icon not in ['unavailable', 'unknown', None] and settings_entity_dict.icon | length > 0
else nextion.icons.buttons.light
}}
continue_on_error: true continue_on_error: true
- *delay-default - *delay-default
- service: "{{ nextion.commands.font_color }}" - service: "{{ nextion.commands.font_color }}"
data: data:
component: lightsettings.icon_state component: lightsettings.icon_state
message: "{{ (settings_entity_dict.icon_color_rgb if is_number(settings_entity_dict.icon_color_rgb) else ((settings_entity_dict.icon_color_rgb[0] //(2**3)) *(2**11))+((settings_entity_dict.icon_color_rgb[1] //(2**2)) *(2**5))+(settings_entity_dict.icon_color_rgb[2] //(2**3))) if is_state(settings_entity_dict.entity, 'on') else nextion.colors.grey_light }}" message: >
{{
(
settings_entity_dict.icon_color_rgb
if is_number(settings_entity_dict.icon_color_rgb)
else
((settings_entity_dict.icon_color_rgb[0] //(2**3)) *(2**11))+((settings_entity_dict.icon_color_rgb[1] //(2**2)) *(2**5))+(settings_entity_dict.icon_color_rgb[2] //(2**3))
)
if is_state(settings_entity_dict.entity, 'on')
else nextion.colors.grey_light
}}
continue_on_error: true continue_on_error: true
##### LIGHT State ##### ##### LIGHT State #####
- *delay-default - *delay-default
@@ -4646,7 +4757,12 @@ action:
- service: "{{ nextion.commands.text_printf }}" - service: "{{ nextion.commands.text_printf }}"
data: data:
component: coversettings.icon_state component: coversettings.icon_state
message: "{{ nextion.icons.all[settings_entity_dict.icon.split(':')[1]] | default(settings_entity_dict.icon if settings_entity_dict.icon is defined and settings_entity_dict.icon is string else nextion.icons.buttons.cover) if settings_entity_dict.icon not in ['unavailable', 'unknown', None] and settings_entity_dict.icon | length > 0 else nextion.icons.buttons.cover }}" message: >
{{
nextion.icons.all[settings_entity_dict.icon.split(':')[1]] | default(settings_entity_dict.icon if settings_entity_dict.icon is defined and settings_entity_dict.icon is string else nextion.icons.buttons.cover)
if settings_entity_dict.icon not in ['unavailable', 'unknown', None] and settings_entity_dict.icon | length > 0
else nextion.icons.buttons.cover
}}
continue_on_error: true continue_on_error: true
- *delay-default - *delay-default
- service: "{{ nextion.commands.font_color }}" - service: "{{ nextion.commands.font_color }}"
@@ -5801,8 +5917,7 @@ action:
id: id:
- left_button_state - left_button_state
- right_button_state - right_button_state
- condition: template - "{{ nspanel_event.page == nextion.pages.home }}"
value_template: "{{ nspanel_event.page == nextion.pages.home }}"
sequence: sequence:
- variables: - variables:
# Hardware Button PIC # Hardware Button PIC
@@ -5818,156 +5933,40 @@ action:
conditions: conditions:
- condition: trigger - condition: trigger
id: time_state id: time_state
- condition: template - "{{ nspanel_event.page == nextion.pages.home }}"
value_template: "{{ nspanel_event.page == nextion.pages.home }}"
sequence: sequence:
### TIME Font Color ### - *refresh-page_home-date_time
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.time
message: "{{ page_home.general.time.label.color_rgb if is_number(page_home.general.time.label.color_rgb) else ((page_home.general.time.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.time.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.time.label.color_rgb[2] //(2**3)) }}"
continue_on_error: true
### TIME Font ###
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.time
message: "{{ time }}"
continue_on_error: true
### TIME Meridiem Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.meridiem
message: "{{ page_home.general.time.label.color_rgb if is_number(page_home.general.time.label.color_rgb) else ((page_home.general.time.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.time.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.time.label.color_rgb[2] //(2**3)) }}"
continue_on_error: true
### TIME Meridiem Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.meridiem
message: "{{ meridiem }}"
continue_on_error: true
### DATE Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.date
message: "{{ page_home.general.date.label.color_rgb if is_number(page_home.general.date.label.color_rgb) else ((page_home.general.date.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.date.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.date.label.color_rgb[2] //(2**3)) }}"
continue_on_error: true
### DATE Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.date
message: "{{ (dict.values(mui[language].weekdays) | list)[now().weekday()] ~ ', ' ~ as_timestamp(now()) | timestamp_custom(date_format) }}"
continue_on_error: true
##### OUTDOOR TEMP - entity ##### ##### OUTDOOR TEMP - entity #####
- alias: Outdoor temp - Entity - alias: Outdoor temp - Entity
conditions: conditions:
- condition: trigger - condition: trigger
id: outdoortemp_state id: outdoortemp_state
- condition: template - "{{ nspanel_event.page == nextion.pages.home and is_number(trigger.event.data.new_state.state) }}"
value_template: "{{ nspanel_event.page == nextion.pages.home and is_number(trigger.event.data.new_state.state) }}"
sequence: sequence:
### LABEL Outdoor Temp Font Color ### - *refresh-page_home-outdoor_temp
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.outdoor_temp
message: "{{ page_home.general.outdoor_temp.label.color_rgb if is_number(page_home.general.outdoor_temp.label.color_rgb) else ((page_home.general.outdoor_temp.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.outdoor_temp.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.outdoor_temp.label.color_rgb[2] //(2**3)) }}"
continue_on_error: true
### LABEL Outdoor Temp Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.outdoor_temp
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ temperature_units }}"
continue_on_error: true
##### INDOOR TEMP - entity ##### ##### INDOOR TEMP #####
- alias: Indoor temp - Entity - alias: Indoor temp - Entity
conditions: conditions:
- condition: trigger - condition: trigger
id: indoortemp_state id:
- condition: template - indoortemp_state
value_template: "{{ nspanel_event.page == nextion.pages.home and trigger.event.data.new_state.state not in ['unavailable', 'unknown', None] }}" - nspaneltemp_state
- "{{ nspanel_event.page == nextion.pages.home and is_number(trigger.event.data.new_state.state) }}"
sequence: sequence:
### LABEL Indoor Temp Font Color ### - *refresh-page_home-indoor_temp
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.current_temp
message: "{{ page_home.general.indoor_temp.label.color_rgb if is_number(page_home.general.indoor_temp.label.color_rgb) else ((page_home.general.indoor_temp.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.indoor_temp.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.indoor_temp.label.color_rgb[2] //(2**3)) }}"
continue_on_error: true
### LABEL Indoor Temp Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.current_temp
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ temperature_units }}"
continue_on_error: true
##### INDOOR TEMP - nspanel #####
- alias: Indoor temp - NSPanel
conditions:
- condition: trigger
id: nspaneltemp_state
- condition: template
value_template: "{{ nspanel_event.page == nextion.pages.home and is_number(trigger.event.data.new_state.state) }}"
sequence:
- if: "{{ indoortemp is not match 'sensor.' }}"
then:
### LABEL Indoor Temp Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.current_temp
message: "{{ page_home.general.indoor_temp.label.color_rgb if is_number(page_home.general.indoor_temp.label.color_rgb) else ((page_home.general.indoor_temp.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.indoor_temp.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.indoor_temp.label.color_rgb[2] //(2**3)) }}"
continue_on_error: true
### LABEL Indoor Temp Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.current_temp
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ temperature_units }}"
continue_on_error: true
##### WEATHER STATE - change update ##### ##### WEATHER STATE - change update #####
- alias: Weather - State changed - alias: Weather - State changed
conditions: conditions:
- condition: trigger - condition: trigger
id: weather_state_change id: weather_state_change
- condition: template - "{{ nspanel_event.page == nextion.pages.home and trigger.event.data.new_state.state not in ['unavailable', 'unknown', None] }}"
value_template: "{{ nspanel_event.page == nextion.pages.home and trigger.event.data.new_state.state not in ['unavailable', 'unknown', None] }}"
sequence: sequence:
- if: "{{ outdoortemp is not match 'sensor.' }}" - *refresh-page_home-outdoor_temp
then: - *delay-default
### LABEL Outdoor Temp Font Color ### - *refresh-page_home-weather_pic
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.outdoor_temp
message: "{{ page_home.general.outdoor_temp.label.color_rgb if is_number(page_home.general.outdoor_temp.label.color_rgb) else ((page_home.general.outdoor_temp.label.color_rgb[0] //(2**3)) *(2**11))+((page_home.general.outdoor_temp.label.color_rgb[1] //(2**2)) *(2**5))+(page_home.general.outdoor_temp.label.color_rgb[2] //(2**3)) }}"
continue_on_error: true
### LABEL Outdoor Temp Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.outdoor_temp
message: "{{trigger.event.data.new_state.attributes.temperature | round(1)}}{{ temperature_units }}"
continue_on_error: true
- service: "{{ nextion.commands.text_printf }}"
data:
component: climate.outdoor_temp
message: "{{trigger.event.data.new_state.attributes.temperature | round(1)}}{{ temperature_units }}"
- service: "{{ nextion.commands.printf }}"
data:
cmd: home.weather.pic={{ nextion.pics.weather[trigger.event.data.new_state.state | default('unknown')] }}
continue_on_error: true
##### Sync Climate ##### -> muss noch in page changed climate wwenn climate page fertig ##### Sync Climate ##### -> muss noch in page changed climate wwenn climate page fertig
- alias: Climate - Sync - alias: Climate - Sync
@@ -5981,8 +5980,18 @@ action:
# value_template: "{{ climate_optimistic == false }}" # value_template: "{{ climate_optimistic == false }}"
sequence: sequence:
- variables: - variables:
heating_state: "{{ mui[language].climate.states.off if trigger.event.data.new_state.state == 'off' else mui[language].climate.states.on }}" heating_state: >
heating_bt_pic: "{{ nextion.pics.heating.button.off if trigger.event.data.new_state.state == 'off' else nextion.pics.heating.button.on }}" {{
mui[language].climate.states.off
if trigger.event.data.new_state.state == 'off'
else mui[language].climate.states.on
}}
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 }}" - service: "{{ nextion.commands.text_printf }}"
data: data: