diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 6381d7f..3836b93 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -7277,245 +7277,185 @@ action: - condition: template value_template: '{{ repeat.item.entity|length > 0 }}' then: - - if: - - condition: template - value_template: '{{ states[repeat.item.entity].state == "unknown" or states[repeat.item.entity].state == "unavailable" }}' + - variables: + ### component_to_update: "{{ repeat.item.button }}" + current_entity_state: "{{ states[repeat.item.entity].state }}" + # Button PIC GRAY/WHITE + btn_pic: >- + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_off }} + {%- elif repeat.item.entity is match "light." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "light." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "switch." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "switch." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "input_boolean." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "input_boolean." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "cover." and current_entity_state == 'open' -%} {{ button_on }} + {%- elif repeat.item.entity is match "cover." and current_entity_state == 'closed' -%} {{ button_off }} + {%- elif repeat.item.entity is match "automation." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "automation." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "button." -%} {{ button_off }} + {%- elif repeat.item.entity is match "input_button." -%} {{ button_off }} + {%- elif repeat.item.entity is match "scene." -%} {{ button_off }} + {%- elif repeat.item.entity is match "script." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "script." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_on }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_off }} + {%- elif repeat.item.entity is match "binary_sensor." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "binary_sensor." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "fan." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "fan." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_on }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_off }} + {%- endif -%} + # TEXT, BRIGHTNESS and ICON Background + btn_bg: >- + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_2 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_color_1 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_color_2 }} + {%- endif -%} + # ICON Font Color + btn_icon_font: >- + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_icon_color_1 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_icon_color_2 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_icon_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_icon_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_icon_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_icon_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_icon_color_1 }} + {%- endif -%} + # LABEL Font Color + btn_txt_font: >- + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_1 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_color_2 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_color_1 }} + {%- endif -%} + # BRIGHTNESS Font Color + btn_bri_font: "{{ button_color_2 }}" + # ICON Value + btn_icon: >- + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_icon_unknown }} + {%- elif repeat.item.button_icon |length > 0 -%} {{ repeat.item.button_icon }} + {%- elif repeat.item.entity is match "light." -%} {{ button_icon_light }} + {%- elif repeat.item.entity is match "switch." -%} {{ button_icon_switch }} + {%- elif repeat.item.entity is match "input_boolean." -%} {{ button_icon_input_boolan }} + {%- elif repeat.item.entity is match "cover." -%} {{ button_icon_cover }} + {%- elif repeat.item.entity is match "automation." -%} {{ button_icon_automation }} + {%- elif repeat.item.entity is match "button." -%} {{ button_icon_button }} + {%- elif repeat.item.entity is match "input_button." -%} {{ button_icon_input_button }} + {%- elif repeat.item.entity is match "scene." -%} {{ button_icon_screne }} + {%- elif repeat.item.entity is match "script." -%} {{ button_icon_script }} + {%- elif repeat.item.entity is match "person." -%} {{ button_icon_person }} + {%- elif repeat.item.entity is match "binary_sensor." -%} {{ button_icon_binary_sensor }} + {%- elif repeat.item.entity is match "fan." -%} {{ button_icon_fan }} + {%- elif repeat.item.entity is match "climate." -%} {{ button_icon_climate }} + {%- endif -%} + # LABEL Value + btn_label: "{{ repeat.item.button_label }}" + # BRIGHTNESS Value + btn_bri_txt: >- + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} 0 + {%- elif repeat.item.entity is match "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 repeat.item.entity is match "cover." and current_entity_state == 'open' and state_attr(repeat.item.entity, "current_position") != None -%} {{ (state_attr(repeat.item.entity, "current_position") | int(100)) | round(0) }}% + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' and state_attr(repeat.item.entity, "current_temperature") != None -%} {{ (state_attr(repeat.item.entity, "current_temperature") | int) | round(0) }}° + {%- else -%} 0 + {%- endif -%} + + ##### SET Buttons Background #### + # + ##### SET Button PIC ##### + - service: "{{ command_printf }}" + data: + cmd: "{{ repeat.item.button }}pic.pic={{ btn_pic }}" + ##### SET ICON Background ##### + - delay: + milliseconds: "{{ delay_value }}" + - service: "{{ command_background_color }}" + data: + component: "{{ repeat.item.button }}icon" + message: "{{ btn_bg }}" + ##### SET TEXT Background ##### + - delay: + milliseconds: "{{ delay_value }}" + - service: "{{ command_background_color }}" + data: + component: "{{ repeat.item.button }}text" + message: "{{ btn_bg }}" + ##### SET BRIGHTNESS Background Color ##### + - delay: + milliseconds: "{{ delay_value }}" + - service: "{{ command_background_color }}" + data: + component: "{{ repeat.item.button }}bri" + message: "{{ btn_bg }}" + + ##### SET Buttons Font Color #### + # + ##### SET ICON Font Color ##### + - delay: + milliseconds: "{{ delay_value }}" + - service: "{{ command_font_color }}" + data: + component: "{{ repeat.item.button }}icon" + message: "{{ btn_icon_font }}" + ##### SET TEXT Font Color ##### + - delay: + milliseconds: "{{ delay_value }}" + - service: "{{ command_font_color }}" + data: + component: "{{ repeat.item.button }}text" + message: "{{ btn_txt_font }}" + ##### SET BRIGHTNESS Font Color ##### + - delay: + milliseconds: "{{ delay_value }}" + - service: "{{ command_font_color }}" + data: + component: "{{ repeat.item.button }}bri" + message: "{{ btn_bri_font }}" + + ##### SET Buttons Text Value #### + # + ##### "ICON" Value ##### + - delay: + milliseconds: "{{ delay_value }}" + - service: "{{ command_text_printf }}" + data: + component: "{{ repeat.item.button }}icon" + message: "{{ btn_icon }}" + ##### "LABEL" Value ##### + - delay: + milliseconds: "{{ delay_value }}" + - service: "{{ command_text_printf }}" + data: + component: "{{ repeat.item.button }}text" + message: "{{ btn_label }}" + + ##### "BRIGHTNESS" Value ##### + - delay: + milliseconds: "{{ delay_value }}" + - if: + - condition: template + value_template: "{{ btn_bri_txt == 0 }}" then: - ##### SET Buttons Background #### - # - ##### SET Button PIC ##### - - service: "{{ command_printf }}" - data: - cmd: "{{ repeat.item.button }}pic.pic={{ button_off }}" - ##### SET ICON Background ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_background_color }}" - data: - component: "{{ repeat.item.button }}icon" - message: "{{ button_color_2 }}" - ##### SET TEXT Background ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_background_color }}" - data: - component: "{{ repeat.item.button }}text" - message: "{{ button_color_2 }}" - ##### SET BRIGHTNESS Background Color ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_background_color }}" + - service: "{{ command_text_printf }}" data: component: "{{ repeat.item.button }}bri" - message: "{{ button_color_2 }}" - - ##### SET Buttons Font Color #### - # - ##### SET ICON Font Color ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_font_color }}" - data: - component: "{{ repeat.item.button }}icon" - message: "{{ button_color_3 }}" - ##### SET TEXT Font Color ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_font_color }}" - data: - component: "{{ repeat.item.button }}text" - message: "{{ button_color_1 }}" - - ##### SET Buttons Text Value #### - # - ##### "ICON" Value ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_text_printf }}" - data: - component: "{{ repeat.item.button }}icon" - message: "{{ button_icon_unknown }}" - ##### "LABEL" Value ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_text_printf }}" - data: - component: "{{ repeat.item.button }}text" - message: "{{ repeat.item.button_label }}" - ##### SET Button ##### + message: " " else: - - variables: - component_to_update: "{{ repeat.item.button }}" - # Button PIC GRAY/WHITE - btn_pic: >- - {%- if repeat.item.entity is match "light." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "light." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "switch." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "switch." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "input_boolean." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "input_boolean." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "cover." and states[repeat.item.entity].state == 'open' -%} {{ button_on }} - {%- elif repeat.item.entity is match "cover." and states[repeat.item.entity].state == 'closed' -%} {{ button_off }} - {%- elif repeat.item.entity is match "automation." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "automation." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "button." -%} {{ button_off }} - {%- elif repeat.item.entity is match "input_button." -%} {{ button_off }} - {%- elif repeat.item.entity is match "scene." -%} {{ button_off }} - {%- elif repeat.item.entity is match "script." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "script." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_on }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_off }} - {%- elif repeat.item.entity is match "binary_sensor." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "binary_sensor." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "fan." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "fan." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_on }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- endif -%} - # TEXT, BRIGHTNESS and ICON Background - btn_bg: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_2 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_color_1 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_color_2 }} - {%- endif -%} - # ICON Font Color - btn_icon_font: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_icon_color_1 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_icon_color_2 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_icon_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_icon_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_icon_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_icon_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_icon_color_1 }} - {%- endif -%} - # LABEL Font Color - btn_txt_font: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_1 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_color_2 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_color_1 }} - {%- endif -%} - # BRIGHTNESS Font Color - btn_bri_font: "{{ button_color_2 }}" - # ICON Value - btn_icon: >- - {%- if repeat.item.button_icon |length > 0 -%} {{ repeat.item.button_icon }} - {%- elif repeat.item.entity is match "light." -%} {{ button_icon_light }} - {%- elif repeat.item.entity is match "switch." -%} {{ button_icon_switch }} - {%- elif repeat.item.entity is match "input_boolean." -%} {{ button_icon_input_boolan }} - {%- elif repeat.item.entity is match "cover." -%} {{ button_icon_cover }} - {%- elif repeat.item.entity is match "automation." -%} {{ button_icon_automation }} - {%- elif repeat.item.entity is match "button." -%} {{ button_icon_button }} - {%- elif repeat.item.entity is match "input_button." -%} {{ button_icon_input_button }} - {%- elif repeat.item.entity is match "scene." -%} {{ button_icon_screne }} - {%- elif repeat.item.entity is match "script." -%} {{ button_icon_script }} - {%- elif repeat.item.entity is match "person." -%} {{ button_icon_person }} - {%- elif repeat.item.entity is match "binary_sensor." -%} {{ button_icon_binary_sensor }} - {%- elif repeat.item.entity is match "fan." -%} {{ button_icon_fan }} - {%- elif repeat.item.entity is match "climate." -%} {{ button_icon_climate }} - {%- endif -%} - # LABEL Value - btn_label: "{{ repeat.item.button_label }}" - # BRIGHTNESS Value - btn_bri_txt: >- - {%- if repeat.item.entity is match "light." and states(repeat.item.entity) == 'on' and state_attr(repeat.item.entity, "brightness") != None -%} {{ (state_attr(repeat.item.entity, "brightness") | int * 100 /255) | round(0) }}% - {%- elif repeat.item.entity is match "cover." and states(repeat.item.entity) == 'open' and state_attr(repeat.item.entity, "current_position") != None -%} {{ (state_attr(repeat.item.entity, "current_position") | int(100)) | round(0) }}% - {%- elif repeat.item.entity is match "climate." and states(repeat.item.entity) != 'off' and state_attr(repeat.item.entity, "current_temperature") != None -%} {{ (state_attr(repeat.item.entity, "current_temperature") | int) | round(0) }}° - {%- else -%} 0 - {%- endif -%} - - ##### SET Buttons Background #### - # - ##### SET Button PIC ##### - - service: "{{ command_printf }}" - data: - cmd: "{{ component_to_update }}pic.pic={{ btn_pic }}" - ##### SET ICON Background ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_background_color }}" - data: - component: "{{ component_to_update }}icon" - message: "{{ btn_bg }}" - ##### SET TEXT Background ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_background_color }}" - data: - component: "{{ component_to_update }}text" - message: "{{ btn_bg }}" - ##### SET BRIGHTNESS Background Color ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_background_color }}" - data: - component: "{{ component_to_update }}bri" - message: "{{ btn_bg }}" - - ##### SET Buttons Font Color #### - # - ##### SET ICON Font Color ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_font_color }}" - data: - component: "{{ component_to_update }}icon" - message: "{{ btn_icon_font }}" - ##### SET TEXT Font Color ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_font_color }}" - data: - component: "{{ component_to_update }}text" - message: "{{ btn_txt_font }}" - ##### SET BRIGHTNESS Font Color ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_font_color }}" - data: - component: "{{ component_to_update }}bri" - message: "{{ btn_bri_font }}" - - ##### SET Buttons Text Value #### - # - ##### "ICON" Value ##### - - delay: - milliseconds: "{{ delay_value }}" - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}icon" - message: "{{ btn_icon }}" - ##### "LABEL" Value ##### - - delay: - milliseconds: "{{ delay_value }}" - - service: "{{ command_text_printf }}" - data: - component: "{{ component_to_update }}text" - message: "{{ btn_label }}" - - ##### "BRIGHTNESS" Value ##### - - delay: - milliseconds: "{{ delay_value }}" - - if: - - condition: template - value_template: "{{ btn_bri_txt == 0 }}" - then: - - service: "{{ command_text_printf }}" - data: - component: "{{ component_to_update }}bri" - message: " " - else: - - service: "{{ command_text_printf }}" - data: - component: "{{ component_to_update }}bri" - message: "{{ btn_bri_txt }}" + component: "{{ repeat.item.button }}bri" + message: "{{ btn_bri_txt }}" ## PAGE BUTTONPAGE02 ## - conditions: '{{ trigger.event.data.new_state.state == page_buttonpage02 }}' @@ -7573,73 +7513,77 @@ action: sequence: - if: - condition: template - value_template: '{{ repeat.item.entity|length > 0 and states[repeat.item.entity].state != "unavailable" and states[repeat.item.entity].state != "unknown" }}' + value_template: '{{ repeat.item.entity|length > 0 }}' then: - variables: - component_to_update: "{{ repeat.item.button }}" + ### component_to_update: "{{ repeat.item.button }}" + current_entity_state: "{{ states[repeat.item.entity].state }}" # Button PIC GRAY/WHITE btn_pic: >- - {%- if repeat.item.entity is match "light." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "light." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "switch." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "switch." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "input_boolean." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "input_boolean." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "cover." and states[repeat.item.entity].state == 'open' -%} {{ button_on }} - {%- elif repeat.item.entity is match "cover." and states[repeat.item.entity].state == 'closed' -%} {{ button_off }} - {%- elif repeat.item.entity is match "automation." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "automation." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_off }} + {%- elif repeat.item.entity is match "light." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "light." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "switch." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "switch." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "input_boolean." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "input_boolean." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "cover." and current_entity_state == 'open' -%} {{ button_on }} + {%- elif repeat.item.entity is match "cover." and current_entity_state == 'closed' -%} {{ button_off }} + {%- elif repeat.item.entity is match "automation." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "automation." and current_entity_state == 'off' -%} {{ button_off }} {%- elif repeat.item.entity is match "button." -%} {{ button_off }} {%- elif repeat.item.entity is match "input_button." -%} {{ button_off }} {%- elif repeat.item.entity is match "scene." -%} {{ button_off }} - {%- elif repeat.item.entity is match "script." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "script." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_on }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_off }} - {%- elif repeat.item.entity is match "binary_sensor." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "binary_sensor." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "fan." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "fan." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_on }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif states[repeat.item.entity].state == 'unknown' -%} {{ button_off }} + {%- elif repeat.item.entity is match "script." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "script." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_on }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_off }} + {%- elif repeat.item.entity is match "binary_sensor." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "binary_sensor." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "fan." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "fan." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_on }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_off }} {%- endif -%} # TEXT, BRIGHTNESS and ICON Background btn_bg: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_2 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_color_1 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_color_2 }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_2 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_color_1 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_color_2 }} {%- endif -%} # ICON Font Color btn_icon_font: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_icon_color_1 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_icon_color_2 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_icon_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_icon_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_icon_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_icon_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_icon_color_1 }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_icon_color_1 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_icon_color_2 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_icon_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_icon_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_icon_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_icon_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_icon_color_1 }} {%- endif -%} # LABEL Font Color btn_txt_font: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_1 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_color_2 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_color_1 }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_1 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_color_2 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_color_1 }} {%- endif -%} # BRIGHTNESS Font Color btn_bri_font: "{{ button_color_2 }}" # ICON Value btn_icon: >- - {%- if repeat.item.button_icon |length > 0 -%} {{ repeat.item.button_icon }} - {%- elif states[repeat.item.entity].state == 'unknown' -%} {{ button_icon_unknown }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_icon_unknown }} + {%- elif repeat.item.button_icon |length > 0 -%} {{ repeat.item.button_icon }} {%- elif repeat.item.entity is match "light." -%} {{ button_icon_light }} {%- elif repeat.item.entity is match "switch." -%} {{ button_icon_switch }} {%- elif repeat.item.entity is match "input_boolean." -%} {{ button_icon_input_boolan }} @@ -7658,9 +7602,10 @@ action: btn_label: "{{ repeat.item.button_label }}" # BRIGHTNESS Value btn_bri_txt: >- - {%- if repeat.item.entity is match "light." and states(repeat.item.entity) == 'on' and state_attr(repeat.item.entity, "brightness") != None -%} {{ (state_attr(repeat.item.entity, "brightness") | int * 100 /255) | round(0) }}% - {%- elif repeat.item.entity is match "cover." and states(repeat.item.entity) == 'open' and state_attr(repeat.item.entity, "current_position") != None -%} {{ (state_attr(repeat.item.entity, "current_position") | int(100)) | round(0) }}% - {%- elif repeat.item.entity is match "climate." and states(repeat.item.entity) != 'off' and state_attr(repeat.item.entity, "current_temperature") != None -%} {{ (state_attr(repeat.item.entity, "current_temperature") | int) | round(0) }}° + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} 0 + {%- elif repeat.item.entity is match "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 repeat.item.entity is match "cover." and current_entity_state == 'open' and state_attr(repeat.item.entity, "current_position") != None -%} {{ (state_attr(repeat.item.entity, "current_position") | int(100)) | round(0) }}% + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' and state_attr(repeat.item.entity, "current_temperature") != None -%} {{ (state_attr(repeat.item.entity, "current_temperature") | int) | round(0) }}° {%- else -%} 0 {%- endif -%} @@ -7669,27 +7614,27 @@ action: ##### SET Button PIC ##### - service: "{{ command_printf }}" data: - cmd: "{{ component_to_update }}pic.pic={{ btn_pic }}" + cmd: "{{ repeat.item.button }}pic.pic={{ btn_pic }}" ##### SET ICON Background ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_background_color }}" data: - component: "{{ component_to_update }}icon" + component: "{{ repeat.item.button }}icon" message: "{{ btn_bg }}" ##### SET TEXT Background ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_background_color }}" data: - component: "{{ component_to_update }}text" + component: "{{ repeat.item.button }}text" message: "{{ btn_bg }}" ##### SET BRIGHTNESS Background Color ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_background_color }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: "{{ btn_bg }}" ##### SET Buttons Font Color #### @@ -7699,21 +7644,21 @@ action: milliseconds: "{{ delay_value }}" - service: "{{ command_font_color }}" data: - component: "{{ component_to_update }}icon" + component: "{{ repeat.item.button }}icon" message: "{{ btn_icon_font }}" ##### SET TEXT Font Color ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_font_color }}" data: - component: "{{ component_to_update }}text" + component: "{{ repeat.item.button }}text" message: "{{ btn_txt_font }}" ##### SET BRIGHTNESS Font Color ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_font_color }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: "{{ btn_bri_font }}" ##### SET Buttons Text Value #### @@ -7723,14 +7668,14 @@ action: milliseconds: "{{ delay_value }}" - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}icon" + component: "{{ repeat.item.button }}icon" message: "{{ btn_icon }}" ##### "LABEL" Value ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}text" + component: "{{ repeat.item.button }}text" message: "{{ btn_label }}" ##### "BRIGHTNESS" Value ##### @@ -7742,12 +7687,12 @@ action: then: - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: " " else: - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: "{{ btn_bri_txt }}" ## PAGE BUTTONPAGE03 ## @@ -7806,73 +7751,77 @@ action: sequence: - if: - condition: template - value_template: '{{ repeat.item.entity|length > 0 and states[repeat.item.entity].state != "unavailable" and states[repeat.item.entity].state != "unknown" }}' + value_template: '{{ repeat.item.entity|length > 0 }}' then: - variables: - component_to_update: "{{ repeat.item.button }}" + ### component_to_update: "{{ repeat.item.button }}" + current_entity_state: "{{ states[repeat.item.entity].state }}" # Button PIC GRAY/WHITE btn_pic: >- - {%- if repeat.item.entity is match "light." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "light." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "switch." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "switch." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "input_boolean." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "input_boolean." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "cover." and states[repeat.item.entity].state == 'open' -%} {{ button_on }} - {%- elif repeat.item.entity is match "cover." and states[repeat.item.entity].state == 'closed' -%} {{ button_off }} - {%- elif repeat.item.entity is match "automation." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "automation." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_off }} + {%- elif repeat.item.entity is match "light." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "light." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "switch." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "switch." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "input_boolean." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "input_boolean." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "cover." and current_entity_state == 'open' -%} {{ button_on }} + {%- elif repeat.item.entity is match "cover." and current_entity_state == 'closed' -%} {{ button_off }} + {%- elif repeat.item.entity is match "automation." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "automation." and current_entity_state == 'off' -%} {{ button_off }} {%- elif repeat.item.entity is match "button." -%} {{ button_off }} {%- elif repeat.item.entity is match "input_button." -%} {{ button_off }} {%- elif repeat.item.entity is match "scene." -%} {{ button_off }} - {%- elif repeat.item.entity is match "script." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "script." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_on }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_off }} - {%- elif repeat.item.entity is match "binary_sensor." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "binary_sensor." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "fan." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "fan." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_on }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif states[repeat.item.entity].state == 'unknown' -%} {{ button_off }} + {%- elif repeat.item.entity is match "script." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "script." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_on }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_off }} + {%- elif repeat.item.entity is match "binary_sensor." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "binary_sensor." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "fan." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "fan." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_on }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_off }} {%- endif -%} # TEXT, BRIGHTNESS and ICON Background btn_bg: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_2 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_color_1 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_color_2 }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_2 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_color_1 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_color_2 }} {%- endif -%} # ICON Font Color btn_icon_font: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_icon_color_1 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_icon_color_2 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_icon_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_icon_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_icon_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_icon_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_icon_color_1 }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_icon_color_1 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_icon_color_2 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_icon_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_icon_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_icon_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_icon_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_icon_color_1 }} {%- endif -%} # LABEL Font Color btn_txt_font: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_1 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_color_2 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_color_1 }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_1 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_color_2 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_color_1 }} {%- endif -%} # BRIGHTNESS Font Color btn_bri_font: "{{ button_color_2 }}" # ICON Value btn_icon: >- - {%- if repeat.item.button_icon |length > 0 -%} {{ repeat.item.button_icon }} - {%- elif states[repeat.item.entity].state == 'unknown' -%} {{ button_icon_unknown }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_icon_unknown }} + {%- elif repeat.item.button_icon |length > 0 -%} {{ repeat.item.button_icon }} {%- elif repeat.item.entity is match "light." -%} {{ button_icon_light }} {%- elif repeat.item.entity is match "switch." -%} {{ button_icon_switch }} {%- elif repeat.item.entity is match "input_boolean." -%} {{ button_icon_input_boolan }} @@ -7891,9 +7840,10 @@ action: btn_label: "{{ repeat.item.button_label }}" # BRIGHTNESS Value btn_bri_txt: >- - {%- if repeat.item.entity is match "light." and states(repeat.item.entity) == 'on' and state_attr(repeat.item.entity, "brightness") != None -%} {{ (state_attr(repeat.item.entity, "brightness") | int * 100 /255) | round(0) }}% - {%- elif repeat.item.entity is match "cover." and states(repeat.item.entity) == 'open' and state_attr(repeat.item.entity, "current_position") != None -%} {{ (state_attr(repeat.item.entity, "current_position") | int(100)) | round(0) }}% - {%- elif repeat.item.entity is match "climate." and states(repeat.item.entity) != 'off' and state_attr(repeat.item.entity, "current_temperature") != None -%} {{ (state_attr(repeat.item.entity, "current_temperature") | int) | round(0) }}° + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} 0 + {%- elif repeat.item.entity is match "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 repeat.item.entity is match "cover." and current_entity_state == 'open' and state_attr(repeat.item.entity, "current_position") != None -%} {{ (state_attr(repeat.item.entity, "current_position") | int(100)) | round(0) }}% + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' and state_attr(repeat.item.entity, "current_temperature") != None -%} {{ (state_attr(repeat.item.entity, "current_temperature") | int) | round(0) }}° {%- else -%} 0 {%- endif -%} @@ -7902,27 +7852,27 @@ action: ##### SET Button PIC ##### - service: "{{ command_printf }}" data: - cmd: "{{ component_to_update }}pic.pic={{ btn_pic }}" + cmd: "{{ repeat.item.button }}pic.pic={{ btn_pic }}" ##### SET ICON Background ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_background_color }}" data: - component: "{{ component_to_update }}icon" + component: "{{ repeat.item.button }}icon" message: "{{ btn_bg }}" ##### SET TEXT Background ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_background_color }}" data: - component: "{{ component_to_update }}text" + component: "{{ repeat.item.button }}text" message: "{{ btn_bg }}" ##### SET BRIGHTNESS Background Color ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_background_color }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: "{{ btn_bg }}" ##### SET Buttons Font Color #### @@ -7932,21 +7882,21 @@ action: milliseconds: "{{ delay_value }}" - service: "{{ command_font_color }}" data: - component: "{{ component_to_update }}icon" + component: "{{ repeat.item.button }}icon" message: "{{ btn_icon_font }}" ##### SET TEXT Font Color ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_font_color }}" data: - component: "{{ component_to_update }}text" + component: "{{ repeat.item.button }}text" message: "{{ btn_txt_font }}" ##### SET BRIGHTNESS Font Color ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_font_color }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: "{{ btn_bri_font }}" ##### SET Buttons Text Value #### @@ -7956,14 +7906,14 @@ action: milliseconds: "{{ delay_value }}" - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}icon" + component: "{{ repeat.item.button }}icon" message: "{{ btn_icon }}" ##### "LABEL" Value ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}text" + component: "{{ repeat.item.button }}text" message: "{{ btn_label }}" ##### "BRIGHTNESS" Value ##### @@ -7975,12 +7925,12 @@ action: then: - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: " " else: - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: "{{ btn_bri_txt }}" ## PAGE BUTTONPAGE04 ## @@ -8039,73 +7989,77 @@ action: sequence: - if: - condition: template - value_template: '{{ repeat.item.entity|length > 0 and states[repeat.item.entity].state != "unavailable" and states[repeat.item.entity].state != "unknown" }}' + value_template: '{{ repeat.item.entity|length > 0 }}' then: - variables: - component_to_update: "{{ repeat.item.button }}" + ### component_to_update: "{{ repeat.item.button }}" + current_entity_state: "{{ states[repeat.item.entity].state }}" # Button PIC GRAY/WHITE btn_pic: >- - {%- if repeat.item.entity is match "light." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "light." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "switch." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "switch." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "input_boolean." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "input_boolean." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "cover." and states[repeat.item.entity].state == 'open' -%} {{ button_on }} - {%- elif repeat.item.entity is match "cover." and states[repeat.item.entity].state == 'closed' -%} {{ button_off }} - {%- elif repeat.item.entity is match "automation." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "automation." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_off }} + {%- elif repeat.item.entity is match "light." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "light." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "switch." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "switch." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "input_boolean." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "input_boolean." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "cover." and current_entity_state == 'open' -%} {{ button_on }} + {%- elif repeat.item.entity is match "cover." and current_entity_state == 'closed' -%} {{ button_off }} + {%- elif repeat.item.entity is match "automation." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "automation." and current_entity_state == 'off' -%} {{ button_off }} {%- elif repeat.item.entity is match "button." -%} {{ button_off }} {%- elif repeat.item.entity is match "input_button." -%} {{ button_off }} {%- elif repeat.item.entity is match "scene." -%} {{ button_off }} - {%- elif repeat.item.entity is match "script." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "script." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_on }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_off }} - {%- elif repeat.item.entity is match "binary_sensor." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "binary_sensor." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "fan." and states[repeat.item.entity].state == 'on' -%} {{ button_on }} - {%- elif repeat.item.entity is match "fan." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_on }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_off }} - {%- elif states[repeat.item.entity].state == 'unknown' -%} {{ button_off }} + {%- elif repeat.item.entity is match "script." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "script." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_on }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_off }} + {%- elif repeat.item.entity is match "binary_sensor." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "binary_sensor." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "fan." and current_entity_state == 'on' -%} {{ button_on }} + {%- elif repeat.item.entity is match "fan." and current_entity_state == 'off' -%} {{ button_off }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_on }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_off }} {%- endif -%} # TEXT, BRIGHTNESS and ICON Background btn_bg: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_2 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_color_1 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_color_2 }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_2 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_color_1 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_color_2 }} {%- endif -%} # ICON Font Color btn_icon_font: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_icon_color_1 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_icon_color_2 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_icon_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_icon_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_icon_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_icon_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_icon_color_1 }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_icon_color_1 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_icon_color_2 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_icon_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_icon_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_icon_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_icon_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_icon_color_1 }} {%- endif -%} # LABEL Font Color btn_txt_font: >- - {%- if repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_1 }} - {%- elif states[repeat.item.entity].state == 'on' or states[repeat.item.entity].state == 'open' -%} {{ button_color_2 }} - {%- elif states[repeat.item.entity].state == 'off' or states[repeat.item.entity].state == 'closed' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state == 'home' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "person." and states[repeat.item.entity].state != 'home' -%} {{ button_color_1 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state != 'off' -%} {{ button_color_2 }} - {%- elif repeat.item.entity is match "climate." and states[repeat.item.entity].state == 'off' -%} {{ button_color_1 }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "button." or repeat.item.entity is match "input_button." or repeat.item.entity is match "scene." -%} {{ button_color_1 }} + {%- elif current_entity_state == 'on' or current_entity_state == 'open' -%} {{ button_color_2 }} + {%- elif current_entity_state == 'off' or current_entity_state == 'closed' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "person." and current_entity_state == 'home' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "person." and current_entity_state != 'home' -%} {{ button_color_1 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' -%} {{ button_color_2 }} + {%- elif repeat.item.entity is match "climate." and current_entity_state == 'off' -%} {{ button_color_1 }} {%- endif -%} # BRIGHTNESS Font Color btn_bri_font: "{{ button_color_2 }}" # ICON Value btn_icon: >- - {%- if repeat.item.button_icon |length > 0 -%} {{ repeat.item.button_icon }} - {%- elif states[repeat.item.entity].state == 'unknown' -%} {{ button_icon_unknown }} + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} {{ button_icon_unknown }} + {%- elif repeat.item.button_icon |length > 0 -%} {{ repeat.item.button_icon }} {%- elif repeat.item.entity is match "light." -%} {{ button_icon_light }} {%- elif repeat.item.entity is match "switch." -%} {{ button_icon_switch }} {%- elif repeat.item.entity is match "input_boolean." -%} {{ button_icon_input_boolan }} @@ -8124,9 +8078,10 @@ action: btn_label: "{{ repeat.item.button_label }}" # BRIGHTNESS Value btn_bri_txt: >- - {%- if repeat.item.entity is match "light." and states(repeat.item.entity) == 'on' and state_attr(repeat.item.entity, "brightness") != None -%} {{ (state_attr(repeat.item.entity, "brightness") | int * 100 /255) | round(0) }}% - {%- elif repeat.item.entity is match "cover." and states(repeat.item.entity) == 'open' and state_attr(repeat.item.entity, "current_position") != None -%} {{ (state_attr(repeat.item.entity, "current_position") | int(100)) | round(0) }}% - {%- elif repeat.item.entity is match "climate." and states(repeat.item.entity) != 'off' and state_attr(repeat.item.entity, "current_temperature") != None -%} {{ (state_attr(repeat.item.entity, "current_temperature") | int) | round(0) }}° + {%- if current_entity_state == 'unknown' or current_entity_state == 'unavailable' -%} 0 + {%- elif repeat.item.entity is match "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 repeat.item.entity is match "cover." and current_entity_state == 'open' and state_attr(repeat.item.entity, "current_position") != None -%} {{ (state_attr(repeat.item.entity, "current_position") | int(100)) | round(0) }}% + {%- elif repeat.item.entity is match "climate." and current_entity_state != 'off' and state_attr(repeat.item.entity, "current_temperature") != None -%} {{ (state_attr(repeat.item.entity, "current_temperature") | int) | round(0) }}° {%- else -%} 0 {%- endif -%} @@ -8135,27 +8090,27 @@ action: ##### SET Button PIC ##### - service: "{{ command_printf }}" data: - cmd: "{{ component_to_update }}pic.pic={{ btn_pic }}" + cmd: "{{ repeat.item.button }}pic.pic={{ btn_pic }}" ##### SET ICON Background ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_background_color }}" data: - component: "{{ component_to_update }}icon" + component: "{{ repeat.item.button }}icon" message: "{{ btn_bg }}" ##### SET TEXT Background ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_background_color }}" data: - component: "{{ component_to_update }}text" + component: "{{ repeat.item.button }}text" message: "{{ btn_bg }}" ##### SET BRIGHTNESS Background Color ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_background_color }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: "{{ btn_bg }}" ##### SET Buttons Font Color #### @@ -8165,21 +8120,21 @@ action: milliseconds: "{{ delay_value }}" - service: "{{ command_font_color }}" data: - component: "{{ component_to_update }}icon" + component: "{{ repeat.item.button }}icon" message: "{{ btn_icon_font }}" ##### SET TEXT Font Color ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_font_color }}" data: - component: "{{ component_to_update }}text" + component: "{{ repeat.item.button }}text" message: "{{ btn_txt_font }}" ##### SET BRIGHTNESS Font Color ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_font_color }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: "{{ btn_bri_font }}" ##### SET Buttons Text Value #### @@ -8189,14 +8144,14 @@ action: milliseconds: "{{ delay_value }}" - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}icon" + component: "{{ repeat.item.button }}icon" message: "{{ btn_icon }}" ##### "LABEL" Value ##### - delay: milliseconds: "{{ delay_value }}" - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}text" + component: "{{ repeat.item.button }}text" message: "{{ btn_label }}" ##### "BRIGHTNESS" Value ##### @@ -8208,12 +8163,12 @@ action: then: - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: " " else: - service: "{{ command_text_printf }}" data: - component: "{{ component_to_update }}bri" + component: "{{ repeat.item.button }}bri" message: "{{ btn_bri_txt }}" ## PAGE NOTIFICATION ##