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