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

This commit is contained in:
2025-08-30 03:49:51 +00:00
parent 15bac78167
commit a0737f3fdd

View File

@@ -8,18 +8,39 @@ 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 temperature sensor description: Select a sensor or forecast entity for temperature
selector: selector:
entity: entity:
domain: sensor filter:
device_class: temperature domain:
- sensor
- weather
device_class:
- temperature
temperature_cold_threshold:
name: Cold Temperature Threshold
description: Notify if temperature drops below this value
default: 15
selector:
number:
min: -50
max: 50
unit_of_measurement: °C
temperature_hot_threshold:
name: Hot Temperature Threshold
description: Notify if temperature rises above this value
default: 28
selector:
number:
min: -50
max: 50
unit_of_measurement: °C
weather_entity: weather_entity:
name: Weather Forecast Entity name: Weather Forecast Entity
description: Select a weather forecast entity description: Select a weather forecast entity for bad weather detection
selector: selector:
entity: entity:
domain: weather domain: weather
@@ -62,10 +83,21 @@ trigger:
action: action:
- variables: - variables:
current_temp: "{{ states(!input.temperature_sensor) | map(attribute='state') | map('float') | min }}" # Safely extract temperature from sensor or weather entity
current_temp: >
{% if state_attr(!input.temperature_sensor, 'temperature') is not none %}
{{ state_attr(!input.temperature_sensor, 'temperature') | float }}
{% else %}
{{ states(!input.temperature_sensor) | map(attribute='state') | map('float', default=0) | min }}
{% 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 = !input.bad_weather_states.split(',') | map('trim') %}
{% if states(!input.weather_entity) | string in states_list %} {% if current_temp < !input.temperature_cold_threshold %}
too cold
{% elif current_temp > !input.temperature_hot_threshold %}
too hot
{% elif states(!input.weather_entity) | string in states_list %}
bad weather bad weather
{% else %} {% else %}
unknown unknown
@@ -75,8 +107,10 @@ action:
data: data:
target: "{{ !input.notify_target }}" target: "{{ !input.notify_target }}"
message: > message: >
{{ !input.custom_message {% if state_attr(trigger.entity_id, 'device_class') in ['window','door'] %}
| replace('{{ entity_name }}', states(trigger.entity_id).attributes.friendly_name) {{ !input.custom_message
| replace('{{ temperature }}', current_temp | string) | replace('{{ entity_name }}', state_attr(trigger.entity_id,'friendly_name'))
| replace('{{ condition }}', current_condition) | replace('{{ temperature }}', current_temp | string)
}} | replace('{{ condition }}', current_condition)
}}
{% endif %}