From 0127933e93654db3dcb5fdefcbfcaeeaa885b2c2 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 8 Dec 2022 16:52:12 -0500 Subject: [PATCH] Cleaner way to do the security notification #48 #60 --- packages/security.yaml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/security.yaml b/packages/security.yaml index 587d0c6..ac76b17 100644 --- a/packages/security.yaml +++ b/packages/security.yaml @@ -188,25 +188,23 @@ automation: title: Lockdown Issue notification_id: lockdown_issue message: >- + {% set extdoors = expand('binary_sensor.exterior_doors') | selectattr('state','eq','on') | map(attribute='name') | list | join(', ') %} + {% set windows = expand('binary_sensor.windows') | selectattr('state','eq','on') | map(attribute='name') | list | join(', ') %} A lockdown issue has been caused by the following sensors: - {% if is_state('binary_sensor.exterior_doors','on') %} - {{ expand('binary_sensor.exterior_doors') | selectattr('state','eq','on') | map(attribute='name') | list | join(', ') }} - {% endif %} - {% if is_state('binary_sensor.windows','on') %} - {{ expand('binary_sensor.windows') | selectattr('state','eq','on') | map(attribute='name') | list | join(', ') }} - {% endif %} + + Doors:{% if is_state('binary_sensor.exterior_doors','on') %} {{ extdoors }} {% else %} None {% endif %} + Windows:{% if is_state('binary_sensor.windows','on') %} {{ windows }} {% else %} None {% endif %} - service: script.text_urgent_alert data: who: 'parents' title: 'Security Not Armed!' message: >- + {% set extdoors = expand('binary_sensor.exterior_doors') | selectattr('state','eq','on') | map(attribute='name') | list | join(', ') %} + {% set windows = expand('binary_sensor.windows') | selectattr('state','eq','on') | map(attribute='name') | list | join(', ') %} A lockdown issue has been caused by the following sensors: - {% if is_state('binary_sensor.exterior_doors','on') %} - {{ expand('binary_sensor.exterior_doors') | selectattr('state','eq','on') | map(attribute='name') | list | join(', ') }} - {% endif %} - {% if is_state('binary_sensor.windows','on') %} - {{ expand('binary_sensor.windows') | selectattr('state','eq','on') | map(attribute='name') | list | join(', ') }} - {% endif %} + + Doors:{% if is_state('binary_sensor.exterior_doors','on') %} {{ extdoors }} {% else %} None {% endif %} + Windows:{% if is_state('binary_sensor.windows','on') %} {{ windows }} {% else %} None {% endif %} - service: scene.create data: scene_id: light_state_before_lockdown_issue