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:
entity:
domain: binary_sensor
device_class:
- door
- window
- opening
multiple: true
notify_target:
name: Notification Target
description: Select the device, group, or service to send the notification to.
selector: selector:
target: target:
entity:
domain: binary_sensor
device_class:
- door
- window
- opening
# --- Optional Weather Trigger --- notify_service:
weather_sensor: name: Notification Service
name: (Optional) Weather Sensor description: The notification service to use (e.g., notify.mobile_app_phone)
description: The weather entity to monitor (e.g., weather.home). selector:
text:
# Weather Trigger Section
weather_entity:
name: Weather Entity
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: template - condition: or
value_template: >- conditions:
{{ (trigger.id == 'weather_change' and iif(states(input_weather_sensor), true, false)) or - condition: state
(trigger.id in ['temp_hot', 'temp_cold'] and iif(states(input_temperature_sensor), true, false)) }} entity_id: "{{ trigger.entity_id }}"
state: 'on'
for: '00:00:05'
# 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:
# Define variables to use in the message.
- variables: - variables:
open_entities: "{{ expand(input_openings) | selectattr('state', 'eq', 'on') | map(attribute='name') | list }}" open_entities: >
open_count: "{{ open_entities | count }}" {{ expand('binary_sensor') | selectattr('state', 'eq', 'on') |
# Use 'choose' to run different actions based on what triggered the automation. selectattr('entity_id', 'in', input_openings.entity) |
map(attribute='name') | list }}
open_count: "{{ open_entities | length }}"
- choose: - choose:
# Case 1: Weather changed
- conditions: - conditions:
- condition: trigger - condition: trigger
id: weather_change id: weather_change
# Also check if the new weather state is in our list of trigger states
- condition: template - condition: template
value_template: "{{ trigger.to_state.state in input_weather_trigger_states }}" value_template: >-
{{ state_attr(trigger.entity_id, 'state') in input_weather_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(', ') }}." Weather alert: {{ state_attr(trigger.entity_id, 'state') | title }}
title: "Open Window/Door Alert" detected with {{ open_count }} opening(s) open: {{ open_entities | join(', ') }}
title: "Openings Alert"
# Case 2: Temperature is too high
- conditions: - conditions:
- condition: trigger - condition: trigger
id: temp_hot id: temp_high
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(', ') }}." 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 3: Temperature is too low
- conditions: - conditions:
- condition: trigger - condition: trigger
id: temp_cold id: temp_low
sequence: sequence:
- service: notify.notify - service: "{{ input.notify_service }}"
data: data:
target: !input notify_target message: >-
message: "It's getting cold ({{ 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"
mode: single