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

This commit is contained in:
2025-08-30 10:54:56 +00:00
parent e21d238ee6
commit 188b6725c5

View File

@@ -1,164 +1,166 @@
blueprint: blueprint:
name: Open Windows/Doors Weather Notification name: "Open Windows/Doors Weather Notification"
description: >- description: >-
Sends a notification if selected windows or doors are open when the weather changes Sends notifications when windows/doors are open during specific weather conditions
to a specific state (e.g., raining) or the temperature crosses a set threshold. or temperature thresholds.
domain: automation domain: automation
input: input:
openings: openings:
name: Windows & Doors name: Windows & Doors
description: Select all windows and doors you want to monitor. description: Select all windows and doors to monitor
selector: selector:
target:
entity: entity:
domain: binary_sensor domain: binary_sensor
device_class: device_class:
- door - door
- window - window
- opening - opening
multiple: true
notify_target: notify_service:
name: Notification Target name: Notification Service
description: Select the device, group, or service to send the notification to. description: The notification service to use (e.g., notify.mobile_app_phone)
selector: selector:
target: text:
# --- Optional Weather Trigger --- # Weather Trigger Section
weather_sensor: weather_entity:
name: (Optional) Weather Sensor name: Weather Entity
description: The weather entity to monitor (e.g., weather.home). description: Weather entity to monitor (e.g., weather.home)
selector: selector:
entity: entity:
domain: weather domain: weather
default: required: false
weather_trigger_states: weather_states:
name: Weather Trigger States name: Trigger Weather States
description: If a weather sensor is selected, notify when the weather changes to any of these states. description: Notify when weather changes to any of these states
selector: selector:
select: select:
multiple: true multiple: true
options: options:
- "cloudy" - clear-night
- "fog" - cloudy
- "hail" - exceptional
- "lightning" - fog
- "lightning-rainy" - hail
- "partlycloudy" - lightning
- "pouring" - lightning-rainy
- "rainy" - partlycloudy
- "snowy" - pouring
- "snowy-rainy" - rainy
- "sunny" - snowy
- "windy" - snowy-rainy
- "windy-variant" - sunny
- "exceptional" - windy
- windy-variant
default: ["rainy", "pouring", "snowy"] default: ["rainy", "pouring", "snowy"]
# --- Optional Temperature Trigger --- # Temperature Trigger Section
temperature_sensor: temperature_sensor:
name: (Optional) Temperature Sensor name: Temperature Sensor
description: The temperature sensor to monitor (e.g., sensor.outside_temperature). description: Temperature sensor to monitor (e.g., sensor.outside_temperature)
selector: selector:
entity: entity:
domain: sensor domain: sensor
device_class: temperature device_class: temperature
default: required: false
temp_above: temp_high_threshold:
name: Notify if Temperature is Above name: High Temperature Threshold
description: Trigger a notification if the temperature rises above this value. description: Notify if temperature exceeds this value
selector: selector:
number: number:
min: -20 min: -20
max: 40 max: 50
unit_of_measurement: "°C" step: 0.5
unit_of_measurement: °C
mode: box
default: 25 default: 25
temp_below: temp_low_threshold:
name: Notify if Temperature is Below name: Low Temperature Threshold
description: Trigger a notification if the temperature drops below this value. description: Notify if temperature drops below this value
selector: selector:
number: number:
min: -20 min: -20
max: 40 max: 50
unit_of_measurement: "°C" step: 0.5
unit_of_measurement: °C
mode: box
default: 10 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. # Weather state change trigger
- platform: state - platform: state
entity_id: !input weather_sensor entity_id: !input weather_entity
id: weather_change id: weather_change
if: |
{{ is_state_attr(trigger.entity_id, 'state', '') == false }}
# 2. Trigger when temperature goes above the threshold. # Temperature triggers
- platform: numeric_state - platform: numeric_state
entity_id: !input temperature_sensor entity_id: !input temperature_sensor
above: !input temp_above above: !input temp_high_threshold
id: temp_hot id: temp_high
# 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_low_threshold
id: temp_cold id: temp_low
# --- Conditions ---
# The action will only run if ALL of these conditions are true.
condition: condition:
# 1. Check if an input was actually provided for the trigger that ran. # Check if any of the monitored openings are open
- condition: or
conditions:
- condition: state
entity_id: "{{ trigger.entity_id }}"
state: 'on'
for: '00:00:05'
action:
- variables:
open_entities: >
{{ expand('binary_sensor') | selectattr('state', 'eq', 'on') |
selectattr('entity_id', 'in', input_openings.entity) |
map(attribute='name') | list }}
open_count: "{{ open_entities | length }}"
- choose:
- conditions:
- condition: trigger
id: weather_change
- condition: template - condition: template
value_template: >- value_template: >-
{{ (trigger.id == 'weather_change' and iif(states(input_weather_sensor), true, false)) or {{ state_attr(trigger.entity_id, 'state') in input_weather_states }}
(trigger.id in ['temp_hot', 'temp_cold'] and iif(states(input_temperature_sensor), true, false)) }} sequence:
- service: "{{ input.notify_service }}"
data:
message: >-
Weather alert: {{ state_attr(trigger.entity_id, 'state') | title }}
detected with {{ open_count }} opening(s) open: {{ open_entities | join(', ') }}
title: "Openings Alert"
# 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:
# 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: - conditions:
- condition: trigger - condition: trigger
id: weather_change id: temp_high
# 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: sequence:
- service: notify.notify - service: "{{ input.notify_service }}"
data: data:
target: !input notify_target message: >-
message: "It's {{ trigger.to_state.state }} outside! {{ open_count }} opening(s) are open: {{ open_entities | join(', ') }}." High temperature ({{ states(input.temperature_sensor) }}°C) detected
title: "Open Window/Door Alert" with {{ open_count }} opening(s) open: {{ open_entities | join(', ') }}
title: "High Temperature Alert"
# Case 2: Temperature is too high
- conditions: - conditions:
- condition: trigger - condition: trigger
id: temp_hot id: temp_low
sequence: sequence:
- service: notify.notify - service: "{{ input.notify_service }}"
data: data:
target: !input notify_target message: >-
message: "It's getting warm ({{ states(input_temperature_sensor) }}°C)! {{ open_count }} opening(s) are open: {{ open_entities | join(', ') }}." Low temperature ({{ states(input.temperature_sensor) }}°C) detected
title: "Open Window/Door Alert" with {{ open_count }} opening(s) open: {{ open_entities | join(', ') }}
title: "Low Temperature Alert"
# Case 3: Temperature is too low mode: single
- 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"