blueprints/automation/wd-close-weather-notification.yaml aktualisiert
This commit is contained in:
@@ -55,7 +55,8 @@ blueprint:
|
|||||||
notify_target:
|
notify_target:
|
||||||
name: Notification Target
|
name: Notification Target
|
||||||
selector:
|
selector:
|
||||||
target: {}
|
entity:
|
||||||
|
domain: notify
|
||||||
custom_message:
|
custom_message:
|
||||||
name: Custom Notification Message
|
name: Custom Notification Message
|
||||||
default: "{{ entity_name }} is open! Trigger: {{ trigger_state }}"
|
default: "{{ entity_name }} is open! Trigger: {{ trigger_state }}"
|
||||||
@@ -79,34 +80,26 @@ condition:
|
|||||||
state: 'on'
|
state: 'on'
|
||||||
|
|
||||||
action:
|
action:
|
||||||
- variables:
|
- service: "[[[ return !input.notify_target ]]]"
|
||||||
open_entities: >
|
data:
|
||||||
{% set openings = states.binary_sensor | selectattr('entity_id', 'in', !input openings) | selectattr('state', 'eq', 'on') | map(attribute='attributes.friendly_name') | list %}
|
message: >
|
||||||
{% if openings | length > 0 %}
|
{% set open_entities = states.binary_sensor | selectattr('entity_id', 'in', !input.openings) | selectattr('state', 'eq', 'on') | map(attribute='attributes.friendly_name') | list %}
|
||||||
{{ openings }}
|
{% if open_entities | length > 0 %}
|
||||||
{% else %}
|
{% set trigger_state = 'Unknown' %}
|
||||||
[]
|
{% if trigger.platform == 'numeric_state' %}
|
||||||
{% endif %}
|
{% if trigger.above is defined %}
|
||||||
- if: "{{ open_entities | length > 0 }}"
|
{% set trigger_state = 'Temperature > ' + trigger.above | string %}
|
||||||
then:
|
{% elif trigger.below is defined %}
|
||||||
- service: notify.notify
|
{% set trigger_state = 'Temperature < ' + trigger.below | string %}
|
||||||
data:
|
|
||||||
target: !input notify_target
|
|
||||||
message: >
|
|
||||||
{% set trigger_state = 'Unknown' %}
|
|
||||||
{% if trigger.platform == 'numeric_state' %}
|
|
||||||
{% if trigger.above is defined %}
|
|
||||||
{% set trigger_state = 'Temperature > ' + trigger.above | string %}
|
|
||||||
{% elif trigger.below is defined %}
|
|
||||||
{% set trigger_state = 'Temperature < ' + trigger.below | string %}
|
|
||||||
{% endif %}
|
|
||||||
{% elif trigger.platform == 'state' %}
|
|
||||||
{% set trigger_state = trigger.to_state.state %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% elif trigger.platform == 'state' %}
|
||||||
|
{% set trigger_state = trigger.to_state.state %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% set msg = !input custom_message | replace('{{ trigger_state }}', trigger_state) %}
|
{% set msg = !input custom_message | replace('{{ trigger_state }}', trigger_state) %}
|
||||||
{% set message_parts = [] %}
|
{% set message_parts = [] %}
|
||||||
{% for entity_name in open_entities %}
|
{% for entity_name in open_entities %}
|
||||||
{% set message_parts = message_parts + [msg | replace('{{ entity_name }}', entity_name)] %}
|
{% set message_parts = message_parts + [msg | replace('{{ entity_name }}', entity_name)] %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{{ message_parts | join("\n") }}
|
{{ message_parts | join("\n") }}
|
||||||
|
{% endif %}
|
||||||
Reference in New Issue
Block a user