blueprints/automation/wd-close-weather-notification.yaml aktualisiert

This commit is contained in:
2025-08-30 03:53:42 +00:00
parent 3de3965b96
commit 2ce7c185be

View File

@@ -1,6 +1,6 @@
blueprint: blueprint:
name: Open Windows/Doors Weather & Temperature Notification name: Open Windows/Doors Weather & Temperature Notification (Weather Trigger)
description: Notify when windows or doors are open during bad weather or extreme temperatures, with a customizable message. description: Notify when windows or doors are open during bad weather or extreme temperatures, triggered by weather or temperature changes.
domain: automation domain: automation
input: input:
openings: openings:
@@ -23,7 +23,6 @@ blueprint:
- temperature - temperature
temperature_cold_threshold: temperature_cold_threshold:
name: Cold Temperature Threshold name: Cold Temperature Threshold
description: Notify if temperature drops below this value
default: 15 default: 15
selector: selector:
number: number:
@@ -32,7 +31,6 @@ blueprint:
unit_of_measurement: °C unit_of_measurement: °C
temperature_hot_threshold: temperature_hot_threshold:
name: Hot Temperature Threshold name: Hot Temperature Threshold
description: Notify if temperature rises above this value
default: 28 default: 28
selector: selector:
number: number:
@@ -41,13 +39,11 @@ blueprint:
unit_of_measurement: °C unit_of_measurement: °C
weather_entity: weather_entity:
name: Weather Forecast Entity name: Weather Forecast Entity
description: Select a weather forecast entity for bad weather detection
selector: selector:
entity: entity:
domain: weather domain: weather
bad_weather_states: bad_weather_states:
name: Bad Weather States name: Bad Weather States
description: List of weather states that should trigger a notification
default: default:
- storm - storm
- rain - rain
@@ -56,12 +52,10 @@ blueprint:
multiline: true multiline: true
notify_target: notify_target:
name: Notification Target name: Notification Target
description: Who to notify
selector: selector:
target: {} target: {}
min_open_time: min_open_time:
name: Minimum Open Time name: Minimum Open Time
description: Duration in minutes before notifying
default: 20 default: 20
selector: selector:
number: number:
@@ -70,51 +64,52 @@ blueprint:
unit_of_measurement: minutes unit_of_measurement: minutes
custom_message: custom_message:
name: Custom Notification Message name: Custom Notification Message
description: Use {{ entity_name }}, {{ temperature }}, and {{ condition }} as placeholders
default: "{{ entity_name }} is open! Condition: {{ condition }}, Current temperature: {{ temperature }}°C" default: "{{ entity_name }} is open! Condition: {{ condition }}, Current temperature: {{ temperature }}°C"
selector: selector:
text: {} text: {}
trigger: trigger:
- platform: state - platform: state
entity_id: !input openings entity_id: !input weather_entity
to: 'on' - platform: state
for: entity_id: !input temperature_sensor
minutes: !input min_open_time
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: action:
- variables: - variables:
temperature_entity: !input temperature_sensor
weather_entity: !input weather_entity
cold_threshold: !input temperature_cold_threshold cold_threshold: !input temperature_cold_threshold
hot_threshold: !input temperature_hot_threshold hot_threshold: !input temperature_hot_threshold
bad_weather_list: !input bad_weather_states current_temp: "{{ states(!input.temperature_sensor) | float(0) }}"
current_temp: > current_weather: "{{ states(!input.weather_entity) }}"
{% if state_attr(temperature_entity, 'temperature') is not none %} bad_states: "{{ !input.bad_weather_states.split(',') | map('trim') }}"
{{ state_attr(temperature_entity, 'temperature') | float }} condition_text: >
{% else %} {% if current_temp < cold_threshold %}too cold
{{ states(temperature_entity) | float(0) }} {% elif current_temp > hot_threshold %}too hot
{% endif %} {% elif current_weather in bad_states %}bad weather
current_condition: > {% else %}unknown
{% set states_list = bad_weather_list.split(',') | map('trim') %}
{% if current_temp < cold_threshold %}
too cold
{% elif current_temp > hot_threshold %}
too hot
{% elif states(weather_entity) | string in states_list %}
bad weather
{% else %}
unknown
{% endif %} {% endif %}
open_entities: >
{{ states | selectattr('entity_id','in',!input.openings) | selectattr('state','eq','on') | map(attribute='attributes.friendly_name') | list }}
- service: notify.notify - service: notify.notify
data: data:
target: "{{ !input notify_target }}" target: "{{ !input.notify_target }}"
message: > message: >
{% if state_attr(trigger.entity_id, 'device_class') in ['window','door'] %} {% for entity_name in open_entities %}
{{ !input custom_message {{ !input.custom_message
| replace('{{ entity_name }}', state_attr(trigger.entity_id,'friendly_name')) | replace('{{ entity_name }}', entity_name)
| replace('{{ temperature }}', current_temp | string) | replace('{{ temperature }}', current_temp | string)
| replace('{{ condition }}', current_condition) | replace('{{ condition }}', condition_text)
}} }}
{% endif %} {% endfor %}