Files
hass-blueprints/blueprints/automation/wd-close-weather-notification.yaml

51 lines
1.4 KiB
YAML

blueprint:
name: Open Windows/Doors Notification (Debug)
description: Debug blueprint to verify open windows/doors and notifications.
domain: automation
input:
openings:
name: Windows & Doors
selector:
entity:
domain: binary_sensor
multiple: true
notify_service:
name: Notification Service
default: notify.notify
selector:
text: {}
custom_message:
name: Custom Message Template
default: "Open windows: {{ entity_name }}"
selector:
text: {}
trigger:
- platform: state
entity_id: !input openings
action:
- variables:
openings_list: !input openings
notify_service_name: !input notify_service
message_template: !input custom_message
open_entities: >
{% set list = [] %}
{% for ent_id in openings_list %}
{% set st = states[ent_id] if ent_id in states else None %}
{% if st is not none and st.state == 'on' %}
{% set _ = list.append(st.attributes.friendly_name | default(ent_id)) %}
{% endif %}
{% endfor %}
{{ list }}
- service: "{{ notify_service_name }}"
data:
message: >
{% if open_entities | count > 0 %}
{{ message_template | replace('{{ entity_name }}', open_entities | join(', ')) }}
{% else %}
No windows are open.
{% endif %}