blueprints/automation/wd-close-weather-notification.yaml aktualisiert
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
blueprint:
|
blueprint:
|
||||||
name: Open Windows/Doors Notification (Clean Working Version)
|
name: Open Windows/Doors Notification (Clean Final)
|
||||||
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. Triggers on weather, temperature, or manual execution. Only sends notifications if windows/doors are open.
|
||||||
domain: automation
|
domain: automation
|
||||||
input:
|
input:
|
||||||
openings:
|
openings:
|
||||||
@@ -44,15 +44,14 @@ blueprint:
|
|||||||
min: -50
|
min: -50
|
||||||
max: 50
|
max: 50
|
||||||
unit_of_measurement: °C
|
unit_of_measurement: °C
|
||||||
notify_services:
|
notify_service:
|
||||||
name: Notification Services
|
name: Notification Service
|
||||||
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: {}
|
||||||
custom_message:
|
custom_message:
|
||||||
name: Custom Message Template
|
name: Custom Message Template
|
||||||
default: "{{ entity_name }} is open! Trigger: {{ trigger_state }}"
|
default: "{{ entity_name }} is open! Trigger: {{ trigger_info }}"
|
||||||
selector:
|
selector:
|
||||||
text: {}
|
text: {}
|
||||||
|
|
||||||
@@ -70,23 +69,32 @@ action:
|
|||||||
- variables:
|
- variables:
|
||||||
# Inputs
|
# Inputs
|
||||||
openings_list: !input openings
|
openings_list: !input openings
|
||||||
|
weather_sensor_id: !input weather_sensor
|
||||||
|
temperature_sensor_id: !input temperature_sensor
|
||||||
raw_weather_states: !input weather_trigger_states
|
raw_weather_states: !input weather_trigger_states
|
||||||
raw_notify_services: !input notify_services
|
notify_service_name: !input notify_service
|
||||||
custom_msg: !input custom_message
|
message_template: !input custom_message
|
||||||
|
temp_above_threshold: !input temp_above
|
||||||
|
temp_below_threshold: !input temp_below
|
||||||
|
|
||||||
# Processed lists
|
# Process weather states
|
||||||
weather_states: "{{ raw_weather_states.split(',') | map('trim') | list }}"
|
weather_states: "{{ raw_weather_states.split(',') | map('trim') | list }}"
|
||||||
notify_services_list: "{{ raw_notify_services.split(',') | map('trim') | list }}"
|
|
||||||
|
|
||||||
# Current trigger state
|
# Current weather and temperature
|
||||||
trigger_state: >
|
current_weather: >
|
||||||
{% if trigger.to_state is not none %}
|
{% if states(weather_sensor_id) is not none %}
|
||||||
{{ trigger.to_state.state }}
|
{{ states(weather_sensor_id).state }}
|
||||||
|
{% else %}
|
||||||
|
unknown
|
||||||
|
{% endif %}
|
||||||
|
current_temperature: >
|
||||||
|
{% if states(temperature_sensor_id) is not none %}
|
||||||
|
{{ states(temperature_sensor_id).state }}
|
||||||
{% else %}
|
{% else %}
|
||||||
unknown
|
unknown
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# Determine open windows/doors
|
# Detect open windows/doors
|
||||||
open_entities: >
|
open_entities: >
|
||||||
{% set list = [] %}
|
{% set list = [] %}
|
||||||
{% for ent_id in openings_list %}
|
{% for ent_id in openings_list %}
|
||||||
@@ -97,10 +105,26 @@ action:
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{{ list }}
|
{{ list }}
|
||||||
|
|
||||||
# Determine if weather matches
|
# Determine trigger info for message
|
||||||
|
trigger_info: >
|
||||||
|
{% if trigger.platform == 'state' and trigger.entity_id == weather_sensor_id %}
|
||||||
|
Weather: {{ current_weather }}
|
||||||
|
{% elif trigger.platform == 'numeric_state' and trigger.entity_id == temperature_sensor_id %}
|
||||||
|
Temperature: {{ current_temperature }}°C
|
||||||
|
{% else %}
|
||||||
|
Manual trigger
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Filter conditions
|
||||||
weather_match: >
|
weather_match: >
|
||||||
{% if trigger.entity_id == weather_sensor and states(weather_sensor) is not none %}
|
{% if trigger.platform == 'state' and trigger.entity_id == weather_sensor_id %}
|
||||||
{{ states(weather_sensor).state in weather_states }}
|
{{ current_weather in weather_states }}
|
||||||
|
{% else %}
|
||||||
|
true
|
||||||
|
{% endif %}
|
||||||
|
temperature_match: >
|
||||||
|
{% if trigger.platform == 'numeric_state' and trigger.entity_id == temperature_sensor_id %}
|
||||||
|
{{ (trigger.to_state.state | float >= temp_above_threshold) or (trigger.to_state.state | float <= temp_below_threshold) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
true
|
true
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -108,10 +132,12 @@ action:
|
|||||||
- choose:
|
- choose:
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ open_entities | count > 0 and weather_match }}"
|
value_template: "{{ open_entities | count > 0 and weather_match and temperature_match }}"
|
||||||
sequence:
|
sequence:
|
||||||
- service: notify.all
|
- service: "{{ notify_service_name }}"
|
||||||
data:
|
data:
|
||||||
message: >
|
message: >
|
||||||
{% set msg = custom_msg | replace('{{ entity_name }}', open_entities | join(', ')) | replace('{{ trigger_state }}', trigger_state) %}
|
{{ message_template
|
||||||
{{ msg }}
|
| replace('{{ entity_name }}', open_entities | join(', '))
|
||||||
|
| replace('{{ trigger_info }}', trigger_info)
|
||||||
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user