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

This commit is contained in:
2025-08-30 03:52:22 +00:00
parent a0737f3fdd
commit 3de3965b96

View File

@@ -8,10 +8,11 @@ blueprint:
description: Select windows and doors to monitor description: Select windows and doors to monitor
selector: selector:
entity: entity:
domain: binary_sensor
multiple: true multiple: true
temperature_sensor: temperature_sensor:
name: Temperature Sensor name: Temperature Sensor
description: Select a sensor or forecast entity for temperature description: Select a temperature sensor or weather entity
selector: selector:
entity: entity:
filter: filter:
@@ -83,21 +84,24 @@ trigger:
action: action:
- variables: - variables:
# Safely extract temperature from sensor or weather entity temperature_entity: !input temperature_sensor
weather_entity: !input weather_entity
cold_threshold: !input temperature_cold_threshold
hot_threshold: !input temperature_hot_threshold
bad_weather_list: !input bad_weather_states
current_temp: > current_temp: >
{% if state_attr(!input.temperature_sensor, 'temperature') is not none %} {% if state_attr(temperature_entity, 'temperature') is not none %}
{{ state_attr(!input.temperature_sensor, 'temperature') | float }} {{ state_attr(temperature_entity, 'temperature') | float }}
{% else %} {% else %}
{{ states(!input.temperature_sensor) | map(attribute='state') | map('float', default=0) | min }} {{ states(temperature_entity) | float(0) }}
{% endif %} {% endif %}
# Determine current condition based on thresholds and bad weather
current_condition: > current_condition: >
{% set states_list = !input.bad_weather_states.split(',') | map('trim') %} {% set states_list = bad_weather_list.split(',') | map('trim') %}
{% if current_temp < !input.temperature_cold_threshold %} {% if current_temp < cold_threshold %}
too cold too cold
{% elif current_temp > !input.temperature_hot_threshold %} {% elif current_temp > hot_threshold %}
too hot too hot
{% elif states(!input.weather_entity) | string in states_list %} {% elif states(weather_entity) | string in states_list %}
bad weather bad weather
{% else %} {% else %}
unknown unknown
@@ -105,10 +109,10 @@ action:
- 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'] %} {% if state_attr(trigger.entity_id, 'device_class') in ['window','door'] %}
{{ !input.custom_message {{ !input custom_message
| replace('{{ entity_name }}', state_attr(trigger.entity_id,'friendly_name')) | replace('{{ entity_name }}', state_attr(trigger.entity_id,'friendly_name'))
| replace('{{ temperature }}', current_temp | string) | replace('{{ temperature }}', current_temp | string)
| replace('{{ condition }}', current_condition) | replace('{{ condition }}', current_condition)