blueprints/automation/wd-close-weather-notification.yaml aktualisiert
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
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.
|
||||
domain: automation
|
||||
input:
|
||||
@@ -46,6 +46,7 @@ blueprint:
|
||||
unit_of_measurement: °C
|
||||
notify_services:
|
||||
name: Notification Services
|
||||
description: Comma-separated notify services (e.g., notify.mobile_app_phone,notify.alexa_media_livingroom)
|
||||
default: notify.notify
|
||||
selector:
|
||||
text: {}
|
||||
@@ -67,54 +68,50 @@ trigger:
|
||||
|
||||
action:
|
||||
- variables:
|
||||
selected_openings: !input openings
|
||||
# Inputs
|
||||
openings_list: !input openings
|
||||
raw_weather_states: !input weather_trigger_states
|
||||
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: >
|
||||
{% 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 }}
|
||||
{% else %}
|
||||
unknown
|
||||
{% endif %}
|
||||
weather_trigger_states: >
|
||||
{{ raw_weather_states.split(',') | map('trim') | list }}
|
||||
notify_services_list: >
|
||||
{{ raw_notify_services.split(',') | map('trim') | list }}
|
||||
|
||||
# Determine open windows/doors
|
||||
open_entities: >
|
||||
{% set open_list = [] %}
|
||||
{% for ent_id in selected_openings %}
|
||||
{% set state_obj = states(ent_id) %}
|
||||
{% if state_obj is not none and state_obj.state == 'on' %}
|
||||
{% set _ = open_list.append(state_obj.attributes.friendly_name | default(ent_id)) %}
|
||||
{% set list = [] %}
|
||||
{% for ent_id in openings_list %}
|
||||
{% set st = states(ent_id) %}
|
||||
{% if st is not none and st.state == 'on' %}
|
||||
{% set _ = list.append(st.attributes.friendly_name | default(ent_id)) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ open_list }}
|
||||
# Determine if weather matches selected states
|
||||
{{ list }}
|
||||
|
||||
# Determine if weather matches
|
||||
weather_match: >
|
||||
{% if states(trigger.entity_id) is not none %}
|
||||
{{ states(trigger.entity_id).state in weather_trigger_states }}
|
||||
{% if trigger.entity_id == weather_sensor and states(weather_sensor) is not none %}
|
||||
{{ states(weather_sensor).state in weather_states }}
|
||||
{% else %}
|
||||
false
|
||||
true
|
||||
{% endif %}
|
||||
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{{ open_entities | count > 0 }}"
|
||||
value_template: "{{ open_entities | count > 0 and weather_match }}"
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{{ trigger.entity_id != None and (trigger.entity_id == temperature_sensor or weather_match) }}"
|
||||
sequence:
|
||||
- repeat:
|
||||
count: "{{ notify_services_list | count }}"
|
||||
sequence:
|
||||
- service: "{{ notify_services_list[repeat.index0] }}"
|
||||
- service: notify.all
|
||||
data:
|
||||
message: >
|
||||
{{ message_template
|
||||
| replace('{{ entity_name }}', open_entities | join(', '))
|
||||
| replace('{{ trigger_state }}', trigger_state)
|
||||
}}
|
||||
{% set msg = custom_msg | replace('{{ entity_name }}', open_entities | join(', ')) | replace('{{ trigger_state }}', trigger_state) %}
|
||||
{{ msg }}
|
||||
|
||||
Reference in New Issue
Block a user