From 3b6b19b160f9e1a12bad095c1ce3d5bde9f97baa Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Fri, 5 Jan 2024 14:59:37 -0500 Subject: [PATCH] Improve door open alert macro --- packages/notify.yaml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/notify.yaml b/packages/notify.yaml index aa43f22..16a3e7c 100644 --- a/packages/notify.yaml +++ b/packages/notify.yaml @@ -1753,14 +1753,25 @@ script: {%- endmacro -%} {%- macro snark_door_open() -%} - {{ [ - 'Would you like me to calulate how much air conditioning is being wasted? Spoiler Alert, you are not going to like the answer.', - 'I have detected a large number of insects entering the house.', - 'Can a human be so kind and close it?', - 'The air quality in this house has actually improved.', - 'Closing the door would improve the security of the house.', - 'Hey. The door was just opened and this is crazy. But now you know. So close it maybe.' - ] | random }} + {% if is_state('binary_sensor.front_door','on') and is_state('binary_sensor.back_door','on') %} + {% set door = 'front door and back door' %} + {% elif is_state('binary_sensor.front_door','on') %} + {% set door = 'front door' %} + {% elif is_state('binary_sensor.back_door','on') %} + {% set door = 'back door' %} + {% endif %} + {% if door is defined %} + {{ [ + 'Would you like me to calulate how much air conditioning is being wasted? Spoiler Alert, you are not going to like the answer. Close the ' + door + '.', + 'I have detected a large number of insects entering the house. You may want to close the ' + door + '.', + 'The ' + door + ' is open. Can a human be so kind as to close it?', + 'The air quality in this house has actually improved. But you will probably want to close the ' + door + ' anyway.', + 'Closing the ' + door + ' would improve the security of the house.', + 'Hey. The ' + door + ' was just opened and this is crazy. But now you know. So close it maybe.' + ] | random }} + {% else %} + Apparently there is a door open somewhere that should not be. Do not ask me. I just work here. + {% endif %} {%- endmacro -%} {%- macro snark_door_closed() -%}