116 lines
3.8 KiB
YAML
116 lines
3.8 KiB
YAML
blueprint:
|
|
name: Open Windows/Doors Weather & Temperature Notification (Weather Trigger)
|
|
description: Notify when windows or doors are open during bad weather or extreme temperatures, triggered by weather or temperature changes.
|
|
domain: automation
|
|
input:
|
|
openings:
|
|
name: Windows & Doors
|
|
description: Select windows and doors to monitor
|
|
selector:
|
|
entity:
|
|
domain: binary_sensor
|
|
multiple: true
|
|
temperature_sensor:
|
|
name: Temperature Sensor
|
|
description: Select a temperature sensor or weather entity
|
|
selector:
|
|
entity:
|
|
filter:
|
|
domain:
|
|
- sensor
|
|
- weather
|
|
device_class:
|
|
- temperature
|
|
temperature_cold_threshold:
|
|
name: Cold Temperature Threshold
|
|
default: 15
|
|
selector:
|
|
number:
|
|
min: -50
|
|
max: 50
|
|
unit_of_measurement: °C
|
|
temperature_hot_threshold:
|
|
name: Hot Temperature Threshold
|
|
default: 28
|
|
selector:
|
|
number:
|
|
min: -50
|
|
max: 50
|
|
unit_of_measurement: °C
|
|
weather_entity:
|
|
name: Weather Forecast Entity
|
|
selector:
|
|
entity:
|
|
domain: weather
|
|
bad_weather_states:
|
|
name: Bad Weather States
|
|
default:
|
|
- storm
|
|
- rain
|
|
selector:
|
|
text:
|
|
multiline: true
|
|
notify_target:
|
|
name: Notification Target
|
|
selector:
|
|
target: {}
|
|
min_open_time:
|
|
name: Minimum Open Time
|
|
default: 20
|
|
selector:
|
|
number:
|
|
min: 1
|
|
max: 120
|
|
unit_of_measurement: minutes
|
|
custom_message:
|
|
name: Custom Notification Message
|
|
default: "{{ entity_name }} is open! Condition: {{ condition }}, Current temperature: {{ temperature }}°C"
|
|
selector:
|
|
text: {}
|
|
|
|
trigger:
|
|
- platform: state
|
|
entity_id: !input weather_entity
|
|
- platform: state
|
|
entity_id: !input temperature_sensor
|
|
|
|
condition:
|
|
- condition: template
|
|
value_template: >
|
|
{% set cold_threshold = !input.temperature_cold_threshold %}
|
|
{% set hot_threshold = !input.temperature_hot_threshold %}
|
|
{% set bad_states = !input.bad_weather_states.split(',') | map('trim') %}
|
|
{% set current_temp = states(!input.temperature_sensor) | float(0) %}
|
|
{% set current_weather = states(!input.weather_entity) %}
|
|
{% set condition_met = (current_temp < cold_threshold) or (current_temp > hot_threshold) or (current_weather in bad_states) %}
|
|
{% set any_open = states | selectattr('entity_id','in',!input.openings) | selectattr('state','eq','on') | list | length > 0 %}
|
|
{{ condition_met and any_open }}
|
|
|
|
action:
|
|
- variables:
|
|
cold_threshold: !input temperature_cold_threshold
|
|
hot_threshold: !input temperature_hot_threshold
|
|
current_temp: "{{ states(!input.temperature_sensor) | float(0) }}"
|
|
current_weather: "{{ states(!input.weather_entity) }}"
|
|
bad_states: "{{ !input.bad_weather_states.split(',') | map('trim') }}"
|
|
condition_text: >
|
|
{% if current_temp < cold_threshold %}too cold
|
|
{% elif current_temp > hot_threshold %}too hot
|
|
{% elif current_weather in bad_states %}bad weather
|
|
{% else %}unknown
|
|
{% endif %}
|
|
open_entities: >
|
|
{{ states | selectattr('entity_id','in',!input.openings) | selectattr('state','eq','on') | map(attribute='attributes.friendly_name') | list }}
|
|
|
|
- service: notify.notify
|
|
data:
|
|
target: "{{ !input.notify_target }}"
|
|
message: >
|
|
{% for entity_name in open_entities %}
|
|
{{ !input.custom_message
|
|
| replace('{{ entity_name }}', entity_name)
|
|
| replace('{{ temperature }}', current_temp | string)
|
|
| replace('{{ condition }}', condition_text)
|
|
}}
|
|
{% endfor %}
|