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

60 lines
1.9 KiB
YAML

blueprint:
name: Open Windows/Doors Monitor
description: Monitors selected windows/doors and lists the ones that are open.
domain: automation
input:
opening_sensors:
name: Window/Door Sensors
description: Select the sensors to monitor
selector:
entity:
domain: binary_sensor
multiple: true
notify_services:
name: Notification Services
description: Enter notify services separated by commas, e.g. notify.mobile_app_phone,notify.telegram
default: notify.notify
selector:
text:
trigger:
- platform: state
entity_id: !input opening_sensors
action:
- variables:
open_sensors: >
{% set devices = [] %}
{% for sensor in opening_sensors %}
{% if is_state(sensor, 'on') or is_state(sensor, 'open') %}
{% set _ = devices.append(states[sensor].name) %}
{% endif %}
{% endfor %}
notify_list: >
{% set services = !input notify_services | replace(' ', '') | split(',') %}
{{ services }}
- choose:
- conditions: "{{ open_sensors | length > 0 }}"
sequence:
- repeat:
count: "{{ notify_list | length }}"
sequence:
- service: "{{ notify_list[repeat.index0] }}"
data:
title: "Open Windows/Doors"
message: >
The following windows/doors are open:
{% for d in open_sensors %}
- {{ d }}
{% endfor %}
- conditions: "{{ open_sensors | length == 0 }}"
sequence:
- repeat:
count: "{{ notify_list | length }}"
sequence:
- service: "{{ notify_list[repeat.index0] }}"
data:
title: "Window/Door Status"
message: "All selected windows/doors are closed."