diff --git a/blueprints/automation/wd-close-weather-notification.yaml b/blueprints/automation/wd-close-weather-notification.yaml index 1f7ee62..4ef410c 100644 --- a/blueprints/automation/wd-close-weather-notification.yaml +++ b/blueprints/automation/wd-close-weather-notification.yaml @@ -71,12 +71,11 @@ action: message_template: !input custom_message notify_service_name: !input notify_service trigger_state: > - {% if trigger.platform in ['numeric_state','state'] %} + {% if trigger.platform in ['numeric_state','state'] and trigger.to_state is not none %} {{ trigger.to_state.state }} {% else %} unknown {% endif %} - # Build list of open windows dynamically open_entities: > {% set open_list = [] %} {% for ent_id in selected_openings %} @@ -87,15 +86,14 @@ action: {% endfor %} {{ open_list }} - - choose: - - conditions: - - condition: template - value_template: "{{ open_entities | length > 0 }}" - sequence: - - service: "{{ notify_service_name }}" - data: - message: > - {{ message_template - | replace('{{ entity_name }}', open_entities | join(', ')) - | replace('{{ trigger_state }}', trigger_state) - }} + - service: "{{ notify_service_name }}" + data: + message: > + {% if open_entities | count > 0 %} + {{ message_template + | replace('{{ entity_name }}', open_entities | join(', ')) + | replace('{{ trigger_state }}', trigger_state) + }} + {% else %} + No windows/doors open. + {% endif %}