blueprints/automation/wd-close-weather-notification.yaml aktualisiert
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
blueprint:
|
||||
name: Open Windows/Doors Weather & Temperature Notification
|
||||
description: Notify when windows or doors are open during bad weather or extreme temperatures, with a customizable message.
|
||||
name: Open Windows/Doors Weather & Temperature Notification (Weather Trigger)
|
||||
description: Notify when windows or doors are open during bad weather or extreme temperatures, triggered by weather or temperature changes.
|
||||
domain: automation
|
||||
input:
|
||||
openings:
|
||||
@@ -23,7 +23,6 @@ blueprint:
|
||||
- temperature
|
||||
temperature_cold_threshold:
|
||||
name: Cold Temperature Threshold
|
||||
description: Notify if temperature drops below this value
|
||||
default: 15
|
||||
selector:
|
||||
number:
|
||||
@@ -32,7 +31,6 @@ blueprint:
|
||||
unit_of_measurement: °C
|
||||
temperature_hot_threshold:
|
||||
name: Hot Temperature Threshold
|
||||
description: Notify if temperature rises above this value
|
||||
default: 28
|
||||
selector:
|
||||
number:
|
||||
@@ -41,13 +39,11 @@ blueprint:
|
||||
unit_of_measurement: °C
|
||||
weather_entity:
|
||||
name: Weather Forecast Entity
|
||||
description: Select a weather forecast entity for bad weather detection
|
||||
selector:
|
||||
entity:
|
||||
domain: weather
|
||||
bad_weather_states:
|
||||
name: Bad Weather States
|
||||
description: List of weather states that should trigger a notification
|
||||
default:
|
||||
- storm
|
||||
- rain
|
||||
@@ -56,12 +52,10 @@ blueprint:
|
||||
multiline: true
|
||||
notify_target:
|
||||
name: Notification Target
|
||||
description: Who to notify
|
||||
selector:
|
||||
target: {}
|
||||
min_open_time:
|
||||
name: Minimum Open Time
|
||||
description: Duration in minutes before notifying
|
||||
default: 20
|
||||
selector:
|
||||
number:
|
||||
@@ -70,51 +64,52 @@ blueprint:
|
||||
unit_of_measurement: minutes
|
||||
custom_message:
|
||||
name: Custom Notification Message
|
||||
description: Use {{ entity_name }}, {{ temperature }}, and {{ condition }} as placeholders
|
||||
default: "{{ entity_name }} is open! Condition: {{ condition }}, Current temperature: {{ temperature }}°C"
|
||||
selector:
|
||||
text: {}
|
||||
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: !input openings
|
||||
to: 'on'
|
||||
for:
|
||||
minutes: !input min_open_time
|
||||
entity_id: !input weather_entity
|
||||
- platform: state
|
||||
entity_id: !input temperature_sensor
|
||||
|
||||
condition:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{% set cold_threshold = !input.temperature_cold_threshold %}
|
||||
{% set hot_threshold = !input.temperature_hot_threshold %}
|
||||
{% set bad_states = !input.bad_weather_states.split(',') | map('trim') %}
|
||||
{% set current_temp = states(!input.temperature_sensor) | float(0) %}
|
||||
{% set current_weather = states(!input.weather_entity) %}
|
||||
{% set condition_met = (current_temp < cold_threshold) or (current_temp > hot_threshold) or (current_weather in bad_states) %}
|
||||
{% set any_open = states | selectattr('entity_id','in',!input.openings) | selectattr('state','eq','on') | list | length > 0 %}
|
||||
{{ condition_met and any_open }}
|
||||
|
||||
action:
|
||||
- variables:
|
||||
temperature_entity: !input temperature_sensor
|
||||
weather_entity: !input weather_entity
|
||||
cold_threshold: !input temperature_cold_threshold
|
||||
hot_threshold: !input temperature_hot_threshold
|
||||
bad_weather_list: !input bad_weather_states
|
||||
current_temp: >
|
||||
{% if state_attr(temperature_entity, 'temperature') is not none %}
|
||||
{{ state_attr(temperature_entity, 'temperature') | float }}
|
||||
{% else %}
|
||||
{{ states(temperature_entity) | float(0) }}
|
||||
{% endif %}
|
||||
current_condition: >
|
||||
{% set states_list = bad_weather_list.split(',') | map('trim') %}
|
||||
{% if current_temp < cold_threshold %}
|
||||
too cold
|
||||
{% elif current_temp > hot_threshold %}
|
||||
too hot
|
||||
{% elif states(weather_entity) | string in states_list %}
|
||||
bad weather
|
||||
{% else %}
|
||||
unknown
|
||||
current_temp: "{{ states(!input.temperature_sensor) | float(0) }}"
|
||||
current_weather: "{{ states(!input.weather_entity) }}"
|
||||
bad_states: "{{ !input.bad_weather_states.split(',') | map('trim') }}"
|
||||
condition_text: >
|
||||
{% if current_temp < cold_threshold %}too cold
|
||||
{% elif current_temp > hot_threshold %}too hot
|
||||
{% elif current_weather in bad_states %}bad weather
|
||||
{% else %}unknown
|
||||
{% endif %}
|
||||
open_entities: >
|
||||
{{ states | selectattr('entity_id','in',!input.openings) | selectattr('state','eq','on') | map(attribute='attributes.friendly_name') | list }}
|
||||
|
||||
- service: notify.notify
|
||||
data:
|
||||
target: "{{ !input notify_target }}"
|
||||
target: "{{ !input.notify_target }}"
|
||||
message: >
|
||||
{% if state_attr(trigger.entity_id, 'device_class') in ['window','door'] %}
|
||||
{{ !input custom_message
|
||||
| replace('{{ entity_name }}', state_attr(trigger.entity_id,'friendly_name'))
|
||||
{% for entity_name in open_entities %}
|
||||
{{ !input.custom_message
|
||||
| replace('{{ entity_name }}', entity_name)
|
||||
| replace('{{ temperature }}', current_temp | string)
|
||||
| replace('{{ condition }}', current_condition)
|
||||
| replace('{{ condition }}', condition_text)
|
||||
}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user