blueprints/automation/wd-close-weather-notification.yaml aktualisiert
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
blueprint:
|
blueprint:
|
||||||
name: Open Windows/Doors Notification
|
name: Open Windows/Doors Notification (Debug)
|
||||||
description: Notify when windows or doors are open, triggered by weather, temperature, or manual execution.
|
description: Debug blueprint to verify open windows/doors and notifications.
|
||||||
domain: automation
|
domain: automation
|
||||||
input:
|
input:
|
||||||
openings:
|
openings:
|
||||||
@@ -9,41 +9,6 @@ blueprint:
|
|||||||
entity:
|
entity:
|
||||||
domain: binary_sensor
|
domain: binary_sensor
|
||||||
multiple: true
|
multiple: true
|
||||||
weather_sensor:
|
|
||||||
name: Weather Sensor
|
|
||||||
selector:
|
|
||||||
entity:
|
|
||||||
domain: weather
|
|
||||||
multiple: false
|
|
||||||
weather_trigger_states:
|
|
||||||
name: Weather Trigger States (comma-separated)
|
|
||||||
default: storm,rain
|
|
||||||
selector:
|
|
||||||
text: {}
|
|
||||||
temperature_sensor:
|
|
||||||
name: Temperature Sensor
|
|
||||||
selector:
|
|
||||||
entity:
|
|
||||||
domain:
|
|
||||||
- sensor
|
|
||||||
- weather
|
|
||||||
device_class: temperature
|
|
||||||
temp_above:
|
|
||||||
name: Notify if Temperature Above
|
|
||||||
default: 22
|
|
||||||
selector:
|
|
||||||
number:
|
|
||||||
min: -50
|
|
||||||
max: 50
|
|
||||||
unit_of_measurement: °C
|
|
||||||
temp_below:
|
|
||||||
name: Notify if Temperature Below
|
|
||||||
default: 17
|
|
||||||
selector:
|
|
||||||
number:
|
|
||||||
min: -50
|
|
||||||
max: 50
|
|
||||||
unit_of_measurement: °C
|
|
||||||
notify_service:
|
notify_service:
|
||||||
name: Notification Service
|
name: Notification Service
|
||||||
default: notify.notify
|
default: notify.notify
|
||||||
@@ -51,34 +16,20 @@ blueprint:
|
|||||||
text: {}
|
text: {}
|
||||||
custom_message:
|
custom_message:
|
||||||
name: Custom Message Template
|
name: Custom Message Template
|
||||||
default: "{{ entity_name }} is open! Trigger: {{ trigger_info }}"
|
default: "Open windows: {{ entity_name }}"
|
||||||
selector:
|
selector:
|
||||||
text: {}
|
text: {}
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id: !input weather_sensor
|
entity_id: !input openings
|
||||||
- platform: numeric_state
|
|
||||||
entity_id: !input temperature_sensor
|
|
||||||
above: !input temp_above
|
|
||||||
- platform: numeric_state
|
|
||||||
entity_id: !input temperature_sensor
|
|
||||||
below: !input temp_below
|
|
||||||
|
|
||||||
action:
|
action:
|
||||||
- variables:
|
- variables:
|
||||||
openings_list: !input openings
|
openings_list: !input openings
|
||||||
weather_sensor_id: !input weather_sensor
|
|
||||||
temperature_sensor_id: !input temperature_sensor
|
|
||||||
raw_weather_states: !input weather_trigger_states
|
|
||||||
notify_service_name: !input notify_service
|
notify_service_name: !input notify_service
|
||||||
message_template: !input custom_message
|
message_template: !input custom_message
|
||||||
temp_above_threshold: !input temp_above
|
|
||||||
temp_below_threshold: !input temp_below
|
|
||||||
|
|
||||||
weather_states: "{{ raw_weather_states.split(',') | map('trim') | list }}"
|
|
||||||
|
|
||||||
# Detect currently open windows
|
|
||||||
open_entities: >
|
open_entities: >
|
||||||
{% set list = [] %}
|
{% set list = [] %}
|
||||||
{% for ent_id in openings_list %}
|
{% for ent_id in openings_list %}
|
||||||
@@ -89,42 +40,11 @@ action:
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{{ list }}
|
{{ list }}
|
||||||
|
|
||||||
# Determine trigger info safely
|
- service: "{{ notify_service_name }}"
|
||||||
trigger_info: >
|
data:
|
||||||
{% if trigger is defined and trigger.platform == 'state' and trigger.entity_id == weather_sensor_id %}
|
message: >
|
||||||
Weather: {{ states[weather_sensor_id].state }}
|
{% if open_entities | count > 0 %}
|
||||||
{% elif trigger is defined and trigger.platform == 'numeric_state' and trigger.entity_id == temperature_sensor_id %}
|
{{ message_template | replace('{{ entity_name }}', open_entities | join(', ')) }}
|
||||||
Temperature: {{ states[temperature_sensor_id].state }}°C
|
|
||||||
{% else %}
|
{% else %}
|
||||||
Manual trigger
|
No windows are open.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# Weather match check
|
|
||||||
weather_match: >
|
|
||||||
{% if trigger is defined and trigger.platform == 'state' and trigger.entity_id == weather_sensor_id %}
|
|
||||||
{{ states[weather_sensor_id].state in weather_states }}
|
|
||||||
{% else %}
|
|
||||||
true
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# Temperature match check
|
|
||||||
temperature_match: >
|
|
||||||
{% if trigger is defined and trigger.platform == 'numeric_state' and trigger.entity_id == temperature_sensor_id %}
|
|
||||||
{% set temp = states[temperature_sensor_id].state | float %}
|
|
||||||
{{ temp >= temp_above_threshold or temp <= temp_below_threshold }}
|
|
||||||
{% else %}
|
|
||||||
true
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
- choose:
|
|
||||||
- conditions:
|
|
||||||
- condition: template
|
|
||||||
value_template: "{{ open_entities | count > 0 and weather_match and temperature_match }}"
|
|
||||||
sequence:
|
|
||||||
- service: "{{ notify_service_name }}"
|
|
||||||
data:
|
|
||||||
message: >
|
|
||||||
{{ message_template
|
|
||||||
| replace('{{ entity_name }}', open_entities | join(', '))
|
|
||||||
| replace('{{ trigger_info }}', trigger_info)
|
|
||||||
}}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user