From 3b67e6bbc959b5d24f12e7df1574e96085431a56 Mon Sep 17 00:00:00 2001
From: "Suren A. Chilingaryan" <csa@suren.me>
Date: Fri, 7 Apr 2023 17:40:25 +0400
Subject: Trigger motion automation also on door-contact

---
 blueprints/automation/motion/motion_switch.yaml | 27 +++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/blueprints/automation/motion/motion_switch.yaml b/blueprints/automation/motion/motion_switch.yaml
index e28d6da..31ba62c 100644
--- a/blueprints/automation/motion/motion_switch.yaml
+++ b/blueprints/automation/motion/motion_switch.yaml
@@ -10,6 +10,15 @@ blueprint:
           domain: binary_sensor
 #          device_class: motion
 
+    door_entity:
+      name: Door Contact
+      description: Additionally trigger if door opens while no motion detected
+      default: {}
+      selector:
+        entity:
+          domain: binary_sensor
+#          device_class: contact
+
     illumination_test:
       name: Illumination Test
       description: Select how to check if existing illumination is sufficient
@@ -100,6 +109,11 @@ trigger:
     entity_id: !input motion_entity
     from: "off"
     to: "on"
+  - platform: state
+    id: "door"
+    entity_id: !input door_entity
+    from: "off"
+    to: "on"
   - platform: state
     id: "turn_off"
     entity_id: !input motion_entity
@@ -111,8 +125,17 @@ trigger:
 action:
   - choose:
       - conditions:
-          - condition: trigger
-            id: "turn_on"
+          - condition: or
+            conditions:
+             - condition: trigger
+               id: "turn_on"
+             - condition: and
+               conditions:
+                 - condition: trigger
+                   id: "door"
+                 - condition: state
+                   entity_id: !input motion_entity
+                   state: 'off'
         sequence:
           - choose:
               - conditions: 
-- 
cgit v1.2.3