blueprints/automation/wd-close-weather-notification.yaml aktualisiert

This commit is contained in:
2025-08-30 09:28:10 +00:00
parent a5edf57bd4
commit f894266a35

View File

@@ -1,5 +1,5 @@
blueprint: blueprint:
name: Open Windows/Doors Notification (Final Working) name: Open Windows/Doors Notification (Clean Working Version)
description: Notify when windows or doors are open based on weather or temperature thresholds. Supports multiple notify services and multiple weather states. description: Notify when windows or doors are open based on weather or temperature thresholds. Supports multiple notify services and multiple weather states.
domain: automation domain: automation
input: input:
@@ -46,6 +46,7 @@ blueprint:
unit_of_measurement: °C unit_of_measurement: °C
notify_services: notify_services:
name: Notification Services name: Notification Services
description: Comma-separated notify services (e.g., notify.mobile_app_phone,notify.alexa_media_livingroom)
default: notify.notify default: notify.notify
selector: selector:
text: {} text: {}
@@ -67,54 +68,50 @@ trigger:
action: action:
- variables: - variables:
selected_openings: !input openings # Inputs
openings_list: !input openings
raw_weather_states: !input weather_trigger_states raw_weather_states: !input weather_trigger_states
raw_notify_services: !input notify_services raw_notify_services: !input notify_services
message_template: !input custom_message custom_msg: !input custom_message
# Processed lists
weather_states: "{{ raw_weather_states.split(',') | map('trim') | list }}"
notify_services_list: "{{ raw_notify_services.split(',') | map('trim') | list }}"
# Current trigger state
trigger_state: > trigger_state: >
{% if trigger.platform in ['numeric_state','state'] and trigger.to_state is not none %} {% if trigger.to_state is not none %}
{{ trigger.to_state.state }} {{ trigger.to_state.state }}
{% else %} {% else %}
unknown unknown
{% endif %} {% endif %}
weather_trigger_states: >
{{ raw_weather_states.split(',') | map('trim') | list }} # Determine open windows/doors
notify_services_list: >
{{ raw_notify_services.split(',') | map('trim') | list }}
open_entities: > open_entities: >
{% set open_list = [] %} {% set list = [] %}
{% for ent_id in selected_openings %} {% for ent_id in openings_list %}
{% set state_obj = states(ent_id) %} {% set st = states(ent_id) %}
{% if state_obj is not none and state_obj.state == 'on' %} {% if st is not none and st.state == 'on' %}
{% set _ = open_list.append(state_obj.attributes.friendly_name | default(ent_id)) %} {% set _ = list.append(st.attributes.friendly_name | default(ent_id)) %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{{ open_list }} {{ list }}
# Determine if weather matches selected states
# Determine if weather matches
weather_match: > weather_match: >
{% if states(trigger.entity_id) is not none %} {% if trigger.entity_id == weather_sensor and states(weather_sensor) is not none %}
{{ states(trigger.entity_id).state in weather_trigger_states }} {{ states(weather_sensor).state in weather_states }}
{% else %} {% else %}
false true
{% endif %} {% endif %}
- choose: - choose:
- conditions: - conditions:
- condition: template - condition: template
value_template: "{{ open_entities | count > 0 }}" value_template: "{{ open_entities | count > 0 and weather_match }}"
sequence: sequence:
- choose: - service: notify.all
- conditions: data:
- condition: template message: >
value_template: "{{ trigger.entity_id != None and (trigger.entity_id == temperature_sensor or weather_match) }}" {% set msg = custom_msg | replace('{{ entity_name }}', open_entities | join(', ')) | replace('{{ trigger_state }}', trigger_state) %}
sequence: {{ msg }}
- repeat:
count: "{{ notify_services_list | count }}"
sequence:
- service: "{{ notify_services_list[repeat.index0] }}"
data:
message: >
{{ message_template
| replace('{{ entity_name }}', open_entities | join(', '))
| replace('{{ trigger_state }}', trigger_state)
}}