blueprints/automation/wd-close-weather-notification.yaml aktualisiert
This commit is contained in:
@@ -8,10 +8,11 @@ blueprint:
|
||||
description: Select windows and doors to monitor
|
||||
selector:
|
||||
entity:
|
||||
domain: binary_sensor
|
||||
multiple: true
|
||||
temperature_sensor:
|
||||
name: Temperature Sensor
|
||||
description: Select a sensor or forecast entity for temperature
|
||||
description: Select a temperature sensor or weather entity
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
@@ -83,21 +84,24 @@ trigger:
|
||||
|
||||
action:
|
||||
- variables:
|
||||
# Safely extract temperature from sensor or weather entity
|
||||
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(!input.temperature_sensor, 'temperature') is not none %}
|
||||
{{ state_attr(!input.temperature_sensor, 'temperature') | float }}
|
||||
{% if state_attr(temperature_entity, 'temperature') is not none %}
|
||||
{{ state_attr(temperature_entity, 'temperature') | float }}
|
||||
{% else %}
|
||||
{{ states(!input.temperature_sensor) | map(attribute='state') | map('float', default=0) | min }}
|
||||
{{ states(temperature_entity) | float(0) }}
|
||||
{% endif %}
|
||||
# Determine current condition based on thresholds and bad weather
|
||||
current_condition: >
|
||||
{% set states_list = !input.bad_weather_states.split(',') | map('trim') %}
|
||||
{% if current_temp < !input.temperature_cold_threshold %}
|
||||
{% set states_list = bad_weather_list.split(',') | map('trim') %}
|
||||
{% if current_temp < cold_threshold %}
|
||||
too cold
|
||||
{% elif current_temp > !input.temperature_hot_threshold %}
|
||||
{% elif current_temp > hot_threshold %}
|
||||
too hot
|
||||
{% elif states(!input.weather_entity) | string in states_list %}
|
||||
{% elif states(weather_entity) | string in states_list %}
|
||||
bad weather
|
||||
{% else %}
|
||||
unknown
|
||||
@@ -105,10 +109,10 @@ action:
|
||||
|
||||
- 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
|
||||
{{ !input custom_message
|
||||
| replace('{{ entity_name }}', state_attr(trigger.entity_id,'friendly_name'))
|
||||
| replace('{{ temperature }}', current_temp | string)
|
||||
| replace('{{ condition }}', current_condition)
|
||||
|
||||
Reference in New Issue
Block a user