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

This commit is contained in:
2025-08-30 10:37:15 +00:00
parent ad430972fe
commit a2ce440d60

View File

@@ -72,7 +72,7 @@ trigger:
- platform: numeric_state - platform: numeric_state
entity_id: !input temperature_sensor entity_id: !input temperature_sensor
below: !input temp_below below: !input temp_below
condition: condition:
- condition: state - condition: state
entity_id: !input openings entity_id: !input openings
@@ -80,27 +80,33 @@ condition:
action: action:
- variables: - variables:
selected_openings: !input openings
selected_temp_sensor: !input temperature_sensor
selected_weather: !input weather_sensor
selected_notify_target: !input notify_target
selected_custom_message: !input custom_message
open_entities: > open_entities: >
{{ states | selectattr('entity_id','in',selected_openings) | selectattr('state','eq','on') | map(attribute='attributes.friendly_name') | list }} {% set openings = states.binary_sensor | selectattr('entity_id', 'in', !input openings) | selectattr('state', 'eq', 'on') | map(attribute='attributes.friendly_name') | list %}
trigger_state: > {% if openings | length > 0 %}
{% if trigger.platform in ['numeric_state','state'] %} {{ openings }}
{{ trigger.to_state.state }}
{% else %} {% else %}
unknown []
{% endif %} {% endif %}
- if: "{{ open_entities | length > 0 }}"
then:
- service: notify.notify
data:
target: !input notify_target
message: >
{% set trigger_state = 'Unknown' %}
{% if trigger.platform == 'numeric_state' %}
{% if trigger.above is defined %}
{% set trigger_state = 'Temperature > ' + trigger.above | string %}
{% elif trigger.below is defined %}
{% set trigger_state = 'Temperature < ' + trigger.below | string %}
{% endif %}
{% elif trigger.platform == 'state' %}
{% set trigger_state = trigger.to_state.state %}
{% endif %}
- service: notify.notify {% set msg = !input custom_message | replace('{{ trigger_state }}', trigger_state) %}
data: {% set message_parts = [] %}
target: "{{ selected_notify_target }}" {% for entity_name in open_entities %}
message: > {% set message_parts = message_parts + [msg | replace('{{ entity_name }}', entity_name)] %}
{% for entity_name in open_entities %} {% endfor %}
{{ selected_custom_message {{ message_parts | join("\n") }}
| replace('{{ entity_name }}', entity_name)
| replace('{{ trigger_state }}', trigger_state)
}}
{% endfor %}