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

110 lines
3.0 KiB
YAML

blueprint:
name: Open Windows/Doors Notification
description: Notify when windows or doors are open based on weather or temperature thresholds.
domain: automation
input:
openings:
name: Windows & Doors
description: Select windows and doors to monitor
selector:
entity:
domain: binary_sensor
multiple: true
weather_sensor:
name: Weather Sensor
description: Optional weather entity to trigger notification
default: []
selector:
entity:
domain: weather
multiple: false
weather_trigger_states:
name: Weather Trigger States (comma-separated)
description: Notify when weather is in any of these states
default: storm,rain
selector:
text: {}
temperature_sensor:
name: Temperature Sensor
description: Optional temperature entity to trigger notification
default: []
selector:
entity:
domain:
- sensor
- weather
device_class: temperature
temp_above:
name: Notify if Temperature Above
default: 22
selector:
number:
min: -50
max: 50
unit_of_measurement: °C
temp_below:
name: Notify if Temperature Below
default: 17
selector:
number:
min: -50
max: 50
unit_of_measurement: °C
notify_service:
name: Notification Service
description: Enter the notify service (e.g., notify.mobile_app_myphone, notify.alexa_media_livingroom)
default: notify.notify
selector:
text: {}
custom_message:
name: Custom Message Template
default: "{{ entity_name }} is open! Trigger: {{ trigger_state }}"
selector:
text: {}
trigger:
- platform: state
entity_id: !input weather_sensor
- platform: numeric_state
entity_id: !input temperature_sensor
above: !input temp_above
- platform: numeric_state
entity_id: !input temperature_sensor
below: !input temp_below
condition:
- condition: state
entity_id: !input openings
state: 'on'
action:
- variables:
selected_openings: !input openings
message_template: !input custom_message
notify_service_name: !input notify_service
# Get only entities that are currently 'on'
open_entities: >
{{ selected_openings
| map('states')
| selectattr('state','eq','on')
| map(attribute='attributes.friendly_name')
| list }}
trigger_state: >
{% if trigger.platform in ['numeric_state','state'] %}
{{ trigger.to_state.state }}
{% else %}
unknown
{% endif %}
- service: "{{ notify_service_name }}"
data:
message: >
{% if open_entities %}
{{ message_template
| replace('{{ entity_name }}', open_entities | join(', '))
| replace('{{ trigger_state }}', trigger_state)
}}
{% else %}
No windows/doors open.
{% endif %}