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

This commit is contained in:
2025-08-30 10:41:43 +00:00
parent 55b81776e3
commit dc25f068be

View File

@@ -1,105 +1,164 @@
blueprint: blueprint:
name: Open Windows/Doors Notification name: Open Windows/Doors Weather Notification
description: Notify when windows or doors are open based on weather state or temperature thresholds. description: >-
Sends a notification if selected windows or doors are open when the weather changes
to a specific state (e.g., raining) or the temperature crosses a set threshold.
domain: automation domain: automation
input: input:
openings: openings:
name: Windows & Doors name: Windows & Doors
description: Select windows and doors to monitor description: Select all windows and doors you want to monitor.
selector: selector:
entity: entity:
domain: binary_sensor domain: binary_sensor
device_class:
- door
- window
- opening
multiple: true multiple: true
notify_target:
name: Notification Target
description: Select the device, group, or service to send the notification to.
selector:
target:
# --- Optional Weather Trigger ---
weather_sensor: weather_sensor:
name: Weather Sensor name: (Optional) Weather Sensor
description: Optional weather entity to trigger notification description: The weather entity to monitor (e.g., weather.home).
selector: selector:
entity: entity:
domain: weather domain: weather
default:
weather_trigger_states: weather_trigger_states:
name: Weather Trigger States name: Weather Trigger States
description: Select weather states that should trigger notification description: If a weather sensor is selected, notify when the weather changes to any of these states.
default:
- storm
- rain
selector: selector:
text: select:
multiline: true multiple: true
temperature_sensor: options:
name: Temperature Sensor - "cloudy"
description: Optional temperature entity to trigger notification - "fog"
selector: - "hail"
entity: - "lightning"
domain: - "lightning-rainy"
- sensor - "partlycloudy"
- weather - "pouring"
device_class: temperature - "rainy"
temp_above: - "snowy"
name: Notify if Temperature Above - "snowy-rainy"
description: Optional threshold to trigger notification - "sunny"
default: 22 - "windy"
selector: - "windy-variant"
number: - "exceptional"
min: -50 default: ["rainy", "pouring", "snowy"]
max: 50
unit_of_measurement: °C
temp_below:
name: Notify if Temperature Below
description: Optional threshold to trigger notification
default: 17
selector:
number:
min: -50
max: 50
unit_of_measurement: °C
notify_target:
name: Notification Target
selector:
entity:
domain: notify
custom_message:
name: Custom Notification Message
default: "{{ entity_name }} is open! Trigger: {{ trigger_state }}"
selector:
text: {}
# --- Optional Temperature Trigger ---
temperature_sensor:
name: (Optional) Temperature Sensor
description: The temperature sensor to monitor (e.g., sensor.outside_temperature).
selector:
entity:
domain: sensor
device_class: temperature
default:
temp_above:
name: Notify if Temperature is Above
description: Trigger a notification if the temperature rises above this value.
selector:
number:
min: -20
max: 40
unit_of_measurement: "°C"
default: 25
temp_below:
name: Notify if Temperature is Below
description: Trigger a notification if the temperature drops below this value.
selector:
number:
min: -20
max: 40
unit_of_measurement: "°C"
default: 10
# --- Triggers ---
# The automation will run when any of these conditions are met.
trigger: trigger:
# 1. Trigger when the weather sensor's state changes.
- platform: state - platform: state
entity_id: !input weather_sensor entity_id: !input weather_sensor
to: "{{ !input weather_trigger_states.split(',') | map('trim') | list }}" id: weather_change
# 2. Trigger when temperature goes above the threshold.
- platform: numeric_state - platform: numeric_state
entity_id: !input temperature_sensor entity_id: !input temperature_sensor
above: !input temp_above above: !input temp_above
id: temp_hot
# 3. Trigger when temperature goes below the threshold.
- platform: numeric_state - platform: numeric_state
entity_id: !input temperature_sensor entity_id: !input temperature_sensor
below: !input temp_below below: !input temp_below
id: temp_cold
# --- Conditions ---
# The action will only run if ALL of these conditions are true.
condition: condition:
- condition: state # 1. Check if an input was actually provided for the trigger that ran.
entity_id: !input openings - condition: template
state: 'on' value_template: >-
{{ (trigger.id == 'weather_change' and iif(states(!input weather_sensor), true, false)) or
(trigger.id in ['temp_hot', 'temp_cold'] and iif(states(!input temperature_sensor), true, false)) }}
# 2. Check if at least one of the selected doors/windows is 'on' (open).
- condition: template
value_template: "{{ expand(!input openings) | selectattr('state', 'eq', 'on') | list | count > 0 }}"
# --- Actions ---
# What the automation will do when triggered and conditions are met.
action: action:
- service: "[[[ return !input.notify_target ]]]" # Define variables to use in the message.
- variables:
open_entities: "{{ expand(!input openings) | selectattr('state', 'eq', 'on') | map(attribute='name') | list }}"
open_count: "{{ open_entities | count }}"
# Use 'choose' to run different actions based on what triggered the automation.
- choose:
# Case 1: Weather changed
- conditions:
- condition: trigger
id: weather_change
# Also check if the new weather state is in our list of trigger states
- condition: template
value_template: "{{ trigger.to_state.state in !input weather_trigger_states }}"
sequence:
- service: notify.notify
data: data:
message: > target: !input notify_target
{% set open_entities = states.binary_sensor | selectattr('entity_id', 'in', !input.openings) | selectattr('state', 'eq', 'on') | map(attribute='attributes.friendly_name') | list %} message: "It's {{ trigger.to_state.state }} outside! {{ open_count }} opening(s) are open: {{ open_entities | join(', ') }}."
{% if open_entities | length > 0 %} title: "Open Window/Door Alert"
{% set trigger_state = 'Unknown' %}
{% if trigger.platform == 'numeric_state' %}
{% if trigger.above is defined %}
{% set trigger_state = 'Temperature > ' + trigger.above | string %}
{% elif trigger.below is defined %}
{% set trigger_state = 'Temperature < ' + trigger.below | string %}
{% endif %}
{% elif trigger.platform == 'state' %}
{% set trigger_state = trigger.to_state.state %}
{% endif %}
{% set msg = !input custom_message | replace('{{ trigger_state }}', trigger_state) %} # Case 2: Temperature is too high
{% set message_parts = [] %} - conditions:
{% for entity_name in open_entities %} - condition: trigger
{% set message_parts = message_parts + [msg | replace('{{ entity_name }}', entity_name)] %} id: temp_hot
{% endfor %} sequence:
{{ message_parts | join("\n") }} - service: notify.notify
{% endif %} data:
target: !input notify_target
message: "It's getting warm ({{ states(!input temperature_sensor) }}°C)! {{ open_count }} opening(s) are open: {{ open_entities | join(', ') }}."
title: "Open Window/Door Alert"
# Case 3: Temperature is too low
- conditions:
- condition: trigger
id: temp_cold
sequence:
- service: notify.notify
data:
target: !input notify_target
message: "It's getting cold ({{ states(!input temperature_sensor) }}°C)! {{ open_count }} opening(s) are open: {{ open_entities | join(', ') }}."
title: "Open Window/Door Alert"