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 }}"
then:
- variables:
display_target_temperature_state: "{{ states(display_target_temperature) | default('unavailable') if display_target_temperature is string else 'unavailable' }}"
- if: "{{ is_number(display_target_temperature_state) }}"
then:
- *variables-settings_entity
- if: "{{ settings_entity_domain == 'climate' }}"
then:
- service: climate.set_temperature
data:
entity_id: "{{ settings_entity_dict.entity }}"
temperature: "{{ display_target_temperature_state }}"
continue_on_error: true
display_target_temperature_state: >
{{
states(display_target_temperature) | default('unavailable')
if display_target_temperature is string
else 'unavailable'
}}
- condition: "{{ is_number(display_target_temperature_state) }}"
- *variables-settings_entity
- condition: "{{ settings_entity_domain == 'climate' }}"
- service: climate.set_temperature
data:
entity_id: "{{ settings_entity_dict.entity }}"
temperature: "{{ display_target_temperature_state }}"
continue_on_error: true
- choose:
## PAGE HOME ##
- alias: Home page
@@ -3744,53 +3747,35 @@ action:
data:
entity: "{{ nspanel_event }}"
continue_on_error: true
##### NSPanel Date #####
### 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
##### 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 }}"
- &refresh-page_home-date_time
if: "{{ true }}"
then:
### TIME Meridiem Font Color ###
##### NSPanel Date #####
### DATE Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
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: >
{{
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))
}}
continue_on_error: true
### TIME Meridiem Font ###
### TIME Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.meridiem
message: "{{ meridiem }}"
component: home.time
message: "{{ time }}"
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 #####
- variables:
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) }}"
- &refresh-page_home-outdoor_temp
if: "{{ true }}"
then:
### LABEL Outdoor Temp Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.outdoor_temp
message: >
##### NSPanel Outdoor Temp #####
- variables:
outdoor_temp_state: >
{{
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))
states(outdoortemp) | default('unavailable')
if outdoortemp is string and outdoortemp is match 'sensor.'
else 'unavailable'
}}
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
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:
### 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 #####
- variables:
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) }}"
- &refresh-page_home-indoor_temp
if: "{{ true }}"
then:
### ICON Indoor Temp Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.indoortempicon
message: >
{{
page_home.general.indoor_temp.icon.color_rgb
if is_number(page_home.general.indoor_temp.icon.color_rgb)
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))
}}
continue_on_error: true
### ICON Indoor Temp Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.indoortempicon
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') }}"
continue_on_error: true
### 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: "{{ (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
##### NSPanel Indoor Temp #####
- variables:
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:
### ICON Indoor Temp Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
component: home.indoortempicon
message: >
{{
page_home.general.indoor_temp.icon.color_rgb
if is_number(page_home.general.indoor_temp.icon.color_rgb)
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))
}}
continue_on_error: true
### ICON Indoor Temp Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.indoortempicon
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') }}"
continue_on_error: true
### 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: "{{ (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 #####
- *delay-default
- service: "{{ nextion.commands.printf }}"
- &refresh-page_home-weather_pic
service: "{{ nextion.commands.printf }}"
data:
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
@@ -4084,7 +4107,12 @@ action:
- service: "{{ nextion.commands.font_color }}"
data:
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
### ICON Font ###
- *delay-default
@@ -4103,14 +4131,24 @@ action:
- service: "{{ nextion.commands.font_color }}"
data:
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
### LABEL Font ###
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
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
##### Set notify icon #####
@@ -4120,8 +4158,22 @@ action:
then:
- variables:
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_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_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_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 }}"
@@ -4146,7 +4198,12 @@ action:
- service: "{{ nextion.commands.font_color }}"
data:
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
### ICON Font ###
- *delay-default
@@ -4170,7 +4227,12 @@ action:
- service: "{{ nextion.commands.font_color }}"
data:
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
### ICON Font ###
- *delay-default
@@ -4478,29 +4540,41 @@ action:
}}
# ICON Font Color
btn_icon_font: >
{% 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 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'] %} {{ 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)) }}
{% 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 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'] %}{{ 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 }}
{% endif %}
# LABEL Font Color
btn_txt_font: >-
{% 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 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 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 ['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'] %}{{ 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 }}
{% else %}{{ nextion.colors.white }}
{% endif %}
# BRIGHTNESS Font Color
btn_bri_font: "{{ btn_txt_font }}" #"{{ nextion.colors.grey_dark }}"
# ICON Value
btn_icon: >
{% 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.entity and repeat.item.entity.split('.') | count > 1 %} {{ nextion.icons.buttons[repeat.item.entity.split('.')[0] if repeat.item.entity else '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.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 }}
{% endif %}
# LABEL Value
@@ -4508,9 +4582,12 @@ action:
# BRIGHTNESS Value
btn_bri_txt: >-
{% 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 == '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 }}
{% 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 == '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
{% endif -%}
- *delay-default
@@ -4535,7 +4612,12 @@ action:
btn_id: "{{ repeat.item.page }}.{{ repeat.item.component }}"
btn_pic: "{{ nextion.pics.button.off }}"
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_bri_font: "{{ btn_bri_font }}"
btn_icon: "{{ btn_icon }}"
@@ -4557,20 +4639,49 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
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
##### LIGHT ICON - ON / OFF #####
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
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
- *delay-default
- service: "{{ nextion.commands.font_color }}"
data:
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
##### LIGHT State #####
- *delay-default
@@ -4646,7 +4757,12 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
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
- *delay-default
- service: "{{ nextion.commands.font_color }}"
@@ -5801,8 +5917,7 @@ action:
id:
- left_button_state
- right_button_state
- condition: template
value_template: "{{ nspanel_event.page == nextion.pages.home }}"
- "{{ nspanel_event.page == nextion.pages.home }}"
sequence:
- variables:
# Hardware Button PIC
@@ -5818,156 +5933,40 @@ action:
conditions:
- condition: trigger
id: time_state
- condition: template
value_template: "{{ nspanel_event.page == nextion.pages.home }}"
- "{{ nspanel_event.page == nextion.pages.home }}"
sequence:
### 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 ###
- 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
- *refresh-page_home-date_time
##### OUTDOOR TEMP - entity #####
- alias: Outdoor temp - Entity
conditions:
- condition: trigger
id: outdoortemp_state
- condition: template
value_template: "{{ nspanel_event.page == nextion.pages.home and is_number(trigger.event.data.new_state.state) }}"
- "{{ nspanel_event.page == nextion.pages.home and is_number(trigger.event.data.new_state.state) }}"
sequence:
### 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: "{{ trigger.event.data.new_state.state | round(1) }}{{ temperature_units }}"
continue_on_error: true
- *refresh-page_home-outdoor_temp
##### INDOOR TEMP - entity #####
##### INDOOR TEMP #####
- alias: Indoor temp - Entity
conditions:
- condition: trigger
id: indoortemp_state
- condition: template
value_template: "{{ nspanel_event.page == nextion.pages.home and trigger.event.data.new_state.state not in ['unavailable', 'unknown', None] }}"
id:
- indoortemp_state
- nspaneltemp_state
- "{{ nspanel_event.page == nextion.pages.home and is_number(trigger.event.data.new_state.state) }}"
sequence:
### 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
##### 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
- *refresh-page_home-indoor_temp
##### WEATHER STATE - change update #####
- alias: Weather - State changed
conditions:
- condition: trigger
id: weather_state_change
- condition: template
value_template: "{{ nspanel_event.page == nextion.pages.home and trigger.event.data.new_state.state not in ['unavailable', 'unknown', None] }}"
- "{{ nspanel_event.page == nextion.pages.home and trigger.event.data.new_state.state not in ['unavailable', 'unknown', None] }}"
sequence:
- if: "{{ outdoortemp is not match 'sensor.' }}"
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: "{{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
- *refresh-page_home-outdoor_temp
- *delay-default
- *refresh-page_home-weather_pic
##### Sync Climate ##### -> muss noch in page changed climate wwenn climate page fertig
- alias: Climate - Sync
@@ -5981,8 +5980,18 @@ action:
# value_template: "{{ climate_optimistic == false }}"
sequence:
- 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: "{{ nextion.pics.heating.button.off if trigger.event.data.new_state.state == 'off' else nextion.pics.heating.button.on }}"
heating_state: >
{{
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 }}"
data: