fix: wrong brightness text

This commit is contained in:
Chris
2022-10-31 10:53:20 +01:00
parent 5bbebcd0c4
commit 2663f2e03b

View File

@@ -1453,7 +1453,7 @@ action:
btn_bri_txt: >-
{%- if trigger.to_state.entity_id is match "light." and trigger.to_state.state == 'on' and trigger.to_state.attributes.brightness is defined -%} {{ (trigger.to_state.attributes.brightness | int * 100 /254) | round(0) }}%
{%- elif trigger.to_state.entity_id is match "cover." and trigger.to_state.state == 'open' and trigger.to_state.attributes.current_position is defined -%} {{ (trigger.to_state.attributes.current_position | int) | round(0) }}%
{%- else -%}
{%- else -%} 0
{%- endif -%}
##### Button PIC #####
@@ -1486,10 +1486,20 @@ action:
component: "{{ component_to_update }}text"
message: "{{ btn_label }}"
##### "BRIGHTNESS" Text #####
- service: "{{ command_text_printf }}"
data:
component: "{{ component_to_update }}bri"
message: "{{ btn_bri_txt }}"
- 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 }}"
#### Left button press
- conditions:
- condition: trigger
@@ -1913,9 +1923,9 @@ action:
# BTN Label
btn_label: "{{ repeat.item.button_label }}"
btn_bri_txt: >-
{%- if repeat.item.entity is match "light." and states(repeat.item.entity).state == 'on' and state_attr(repeat.item.entity, "brightness") != None -%} {{ (state_attr(repeat.item.entity, "brightness") | int(255) * 100 /254) | round(0) }}%
{%- elif repeat.item.entity is match "cover." and states(repeat.item.entity).state == 'open' and state_attr(repeat.item.entity, "current_position") != None -%} {{ (state_attr(repeat.item.entity, "current_position") | int(100)) | round(0) }}%
{%- else -%}
{%- 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(255) * 100 /254) | 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) }}%
{%- else -%} 0
{%- endif -%}
##### SET Buttons ####
@@ -1962,11 +1972,20 @@ action:
##### "BRIGHTNESS" Text #####
- delay:
milliseconds: 11
- service: "{{ command_text_printf }}"
data:
component: "{{ component_to_update }}bri"
message: "{{ btn_bri_txt }}"
- 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 }}"
#### NSPanel boot init weather
- choose:
#### Default weather