Files
hass-blueprints/blueprints/automation/wd-close-weather-notification.yaml

167 lines
4.6 KiB
YAML

blueprint:
name: "Open Windows/Doors Weather Notification"
description: >-
Sends notifications when windows/doors are open during specific weather conditions
or temperature thresholds.
domain: automation
input:
openings:
name: Windows & Doors
description: Select all windows and doors to monitor
selector:
target:
entity:
domain: binary_sensor
device_class:
- door
- window
- opening
notify_service:
name: Notification Service
description: The notification service to use (e.g., notify.mobile_app_phone)
selector:
text:
# Weather Trigger Section
weather_entity:
name: Weather Entity
description: Weather entity to monitor (e.g., weather.home)
selector:
entity:
domain: weather
required: false
weather_states:
name: Trigger Weather States
description: Notify when weather changes to any of these states
selector:
select:
multiple: true
options:
- clear-night
- cloudy
- exceptional
- fog
- hail
- lightning
- lightning-rainy
- partlycloudy
- pouring
- rainy
- snowy
- snowy-rainy
- sunny
- windy
- windy-variant
default: ["rainy", "pouring", "snowy"]
# Temperature Trigger Section
temperature_sensor:
name: Temperature Sensor
description: Temperature sensor to monitor (e.g., sensor.outside_temperature)
selector:
entity:
domain: sensor
device_class: temperature
required: false
temp_high_threshold:
name: High Temperature Threshold
description: Notify if temperature exceeds this value
selector:
number:
min: -20
max: 50
step: 0.5
unit_of_measurement: °C
mode: box
default: 25
temp_low_threshold:
name: Low Temperature Threshold
description: Notify if temperature drops below this value
selector:
number:
min: -20
max: 50
step: 0.5
unit_of_measurement: °C
mode: box
default: 10
trigger:
# Weather state change trigger
- platform: state
entity_id: !input weather_entity
id: weather_change
if: |
{{ is_state_attr(trigger.entity_id, 'state', '') == false }}
# Temperature triggers
- platform: numeric_state
entity_id: !input temperature_sensor
above: !input temp_high_threshold
id: temp_high
- platform: numeric_state
entity_id: !input temperature_sensor
below: !input temp_low_threshold
id: temp_low
condition:
# 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
value_template: >-
{{ state_attr(trigger.entity_id, 'state') in input_weather_states }}
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"
- conditions:
- condition: trigger
id: temp_high
sequence:
- service: "{{ input.notify_service }}"
data:
message: >-
High temperature ({{ states(input.temperature_sensor) }}°C) detected
with {{ open_count }} opening(s) open: {{ open_entities | join(', ') }}
title: "High Temperature Alert"
- conditions:
- condition: trigger
id: temp_low
sequence:
- service: "{{ input.notify_service }}"
data:
message: >-
Low temperature ({{ states(input.temperature_sensor) }}°C) detected
with {{ open_count }} opening(s) open: {{ open_entities | join(', ') }}
title: "Low Temperature Alert"
mode: single