blueprints/automation/wd-close-weather-notification.yaml aktualisiert
This commit is contained in:
@@ -5,29 +5,23 @@ blueprint:
|
||||
input:
|
||||
openings:
|
||||
name: Windows & Doors
|
||||
description: Select windows and doors to monitor
|
||||
selector:
|
||||
entity:
|
||||
domain: binary_sensor
|
||||
multiple: true
|
||||
weather_sensor:
|
||||
name: Weather Sensor
|
||||
description: Optional weather entity to trigger notification
|
||||
default: []
|
||||
selector:
|
||||
entity:
|
||||
domain: weather
|
||||
multiple: false
|
||||
weather_trigger_states:
|
||||
name: Weather Trigger States (comma-separated)
|
||||
description: Notify when weather is in any of these states
|
||||
default: storm,rain
|
||||
selector:
|
||||
text: {}
|
||||
temperature_sensor:
|
||||
name: Temperature Sensor
|
||||
description: Optional temperature entity to trigger notification
|
||||
default: []
|
||||
selector:
|
||||
entity:
|
||||
domain:
|
||||
@@ -52,7 +46,6 @@ blueprint:
|
||||
unit_of_measurement: °C
|
||||
notify_service:
|
||||
name: Notification Service
|
||||
description: Enter the notify service (e.g., notify.mobile_app_myphone, notify.alexa_media_livingroom)
|
||||
default: notify.notify
|
||||
selector:
|
||||
text: {}
|
||||
@@ -72,40 +65,37 @@ trigger:
|
||||
entity_id: !input temperature_sensor
|
||||
below: !input temp_below
|
||||
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: !input openings
|
||||
state: 'on'
|
||||
|
||||
action:
|
||||
- variables:
|
||||
selected_openings: !input openings
|
||||
message_template: !input custom_message
|
||||
notify_service_name: !input notify_service
|
||||
open_entities: >
|
||||
{% set open_list = [] %}
|
||||
{% for ent_id in selected_openings %}
|
||||
{% set state_obj = states(ent_id) %}
|
||||
{% if state_obj and state_obj.state == 'on' %}
|
||||
{% set _ = open_list.append(state_obj.attributes.friendly_name | default(ent_id)) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ open_list }}
|
||||
trigger_state: >
|
||||
{% if trigger.platform in ['numeric_state','state'] %}
|
||||
{{ trigger.to_state.state }}
|
||||
{% else %}
|
||||
unknown
|
||||
{% endif %}
|
||||
# Build list of open windows dynamically
|
||||
open_entities: >
|
||||
{% set open_list = [] %}
|
||||
{% for ent_id in selected_openings %}
|
||||
{% set state_obj = states(ent_id) %}
|
||||
{% if state_obj is not none and state_obj.state == 'on' %}
|
||||
{% set _ = open_list.append(state_obj.attributes.friendly_name | default(ent_id)) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ open_list }}
|
||||
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{{ open_entities | length > 0 }}"
|
||||
sequence:
|
||||
- service: "{{ notify_service_name }}"
|
||||
data:
|
||||
message: >
|
||||
{% if open_entities %}
|
||||
{{ message_template
|
||||
| replace('{{ entity_name }}', open_entities | join(', '))
|
||||
| replace('{{ trigger_state }}', trigger_state)
|
||||
}}
|
||||
{% else %}
|
||||
No windows/doors open.
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user