diff --git a/blueprints/automation/wd-close-weather-notification.yaml b/blueprints/automation/wd-close-weather-notification.yaml index 1e946dd..6ec7801 100644 --- a/blueprints/automation/wd-close-weather-notification.yaml +++ b/blueprints/automation/wd-close-weather-notification.yaml @@ -1,5 +1,5 @@ blueprint: - name: Open Windows/Doors Notification (Final) + name: Open Windows/Doors Notification (Final Working Version) description: Notify when windows or doors are open based on weather or temperature thresholds. Supports multiple notify services and multiple weather states. domain: automation input: @@ -46,7 +46,7 @@ blueprint: unit_of_measurement: °C notify_services: name: Notification Services - description: Enter one or multiple notify services (comma-separated) + description: Comma-separated notify services (e.g., notify.mobile_app_phone,notify.alexa_media_livingroom) default: notify.notify selector: text: {} @@ -69,18 +69,20 @@ trigger: action: - variables: selected_openings: !input openings - weather_trigger_states: >- - {{ !input weather_trigger_states.split(',') | map('trim') | list }} + raw_weather_states: !input weather_trigger_states + raw_notify_services: !input notify_services message_template: !input custom_message - notify_services_list: >- - {{ !input notify_services.split(',') | map('trim') | list }} trigger_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/doors + weather_trigger_states: > + {{ raw_weather_states.split(',') | map('trim') | list }} + notify_services_list: > + {{ raw_notify_services.split(',') | map('trim') | list }} + # Build list of currently open windows/doors open_entities: > {% set open_list = [] %} {% for ent_id in selected_openings %} @@ -91,17 +93,17 @@ action: {% endfor %} {{ open_list }} - - service: > - {% for srv in notify_services_list %} - {{ srv }} - {% endfor %} - 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 %} + - repeat: + count: "{{ notify_services_list | count }}" + sequence: + - service: "{{ notify_services_list[repeat.index0] }}" + 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 %}