164 lines
5.5 KiB
YAML
164 lines
5.5 KiB
YAML
blueprint:
|
|
name: Open Windows/Doors Weather Notification
|
|
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
|
|
input:
|
|
openings:
|
|
name: Windows & Doors
|
|
description: Select all windows and doors you want 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:
|
|
target:
|
|
|
|
# --- Optional Weather Trigger ---
|
|
weather_sensor:
|
|
name: (Optional) Weather Sensor
|
|
description: The weather entity to monitor (e.g., weather.home).
|
|
selector:
|
|
entity:
|
|
domain: weather
|
|
default:
|
|
|
|
weather_trigger_states:
|
|
name: Weather Trigger States
|
|
description: If a weather sensor is selected, notify when the weather changes to any of these states.
|
|
selector:
|
|
select:
|
|
multiple: true
|
|
options:
|
|
- "cloudy"
|
|
- "fog"
|
|
- "hail"
|
|
- "lightning"
|
|
- "lightning-rainy"
|
|
- "partlycloudy"
|
|
- "pouring"
|
|
- "rainy"
|
|
- "snowy"
|
|
- "snowy-rainy"
|
|
- "sunny"
|
|
- "windy"
|
|
- "windy-variant"
|
|
- "exceptional"
|
|
default: ["rainy", "pouring", "snowy"]
|
|
|
|
# --- 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:
|
|
# 1. Trigger when the weather sensor's state changes.
|
|
- platform: state
|
|
entity_id: !input weather_sensor
|
|
id: weather_change
|
|
|
|
# 2. Trigger when temperature goes above the threshold.
|
|
- platform: numeric_state
|
|
entity_id: !input temperature_sensor
|
|
above: !input temp_above
|
|
id: temp_hot
|
|
|
|
# 3. Trigger when temperature goes below the threshold.
|
|
- platform: numeric_state
|
|
entity_id: !input temperature_sensor
|
|
below: !input temp_below
|
|
id: temp_cold
|
|
|
|
# --- Conditions ---
|
|
# The action will only run if ALL of these conditions are true.
|
|
condition:
|
|
# 1. Check if an input was actually provided for the trigger that ran.
|
|
- condition: template
|
|
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:
|
|
# 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:
|
|
target: !input notify_target
|
|
message: "It's {{ trigger.to_state.state }} outside! {{ open_count }} opening(s) are open: {{ open_entities | join(', ') }}."
|
|
title: "Open Window/Door Alert"
|
|
|
|
# Case 2: Temperature is too high
|
|
- conditions:
|
|
- condition: trigger
|
|
id: temp_hot
|
|
sequence:
|
|
- service: notify.notify
|
|
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" |