fix: avoid using not defined attributes

This commit is contained in:
Chris
2022-10-30 21:26:55 +01:00
parent a185fb4dbc
commit 8f8189b963

View File

@@ -1536,9 +1536,9 @@ action:
{%- elif trigger.entity_id == entity32 -%} {{ entity32_name }} {%- elif trigger.entity_id == entity32 -%} {{ entity32_name }}
{%- endif -%} {%- endif -%}
btn_bri_txt: >- btn_bri_txt: >-
{%- if trigger.to_state.entity_id is match "light." and trigger.to_state.state == 'on' -%} {{ (trigger.to_state.attributes.brightness | int * 100 /254) | round(0) }}% {%- 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' -%} {{ (trigger.to_state.attributes.current_position | int) | 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 -%}
{%- endif -%} {%- endif -%}
##### Button PIC ##### ##### Button PIC #####