From 0fc298f77524a43b050b64d3e565747e4d501926 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Erik=20Hedenstr=C3=B6m?= <erik@hedenstroem.com>
Date: Mon, 9 Oct 2023 18:45:42 +0000
Subject: [PATCH] Added closet light automation

---
 automation/bicycle-charger-notification.yaml |  2 +-
 automation/closet-light.yml                  | 51 ++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 automation/closet-light.yml

diff --git a/automation/bicycle-charger-notification.yaml b/automation/bicycle-charger-notification.yaml
index 28bbf38..594a368 100644
--- a/automation/bicycle-charger-notification.yaml
+++ b/automation/bicycle-charger-notification.yaml
@@ -1,6 +1,6 @@
 blueprint:
   name: Bicycle Charger Notification
-  description: Get notified when the bicycle battery is fully charged
+  description: Get notified when the bicycle battery is fully charged.
   domain: automation
   input:
     power_switch:
diff --git a/automation/closet-light.yml b/automation/closet-light.yml
new file mode 100644
index 0000000..648f35a
--- /dev/null
+++ b/automation/closet-light.yml
@@ -0,0 +1,51 @@
+blueprint:
+  name: Closet Light Timer
+  description: Turn on closet light for 5 minutes when door is opened or light is turned on.
+  domain: automation
+  input:
+    closet_door:
+      name: Closet Door Sensor
+      description: The open/close sensor for the closet door.
+      selector:
+        entity:
+          domain: binary_sensor
+    closet_light:
+      name: Closet Light
+      description: The light in the closet.
+      selector:
+        entity:
+          domain: light
+
+mode: single
+
+trigger:
+  - platform: state
+    entity_id:
+      - !input closet_door
+  - platform: state
+    entity_id:
+      - !input closet_light
+    to: "on"
+    for:
+      hours: 0
+      minutes: 5
+      seconds: 0
+
+action:
+  - choose:
+      - conditions:
+          - condition: state
+            entity_id: !input closet_light
+            state: "on"
+        sequence:
+          - service: light.turn_off
+            target:
+              entity_id: !input closet_light
+      - conditions:
+          - condition: state
+            entity_id: !input closet_door
+            state: "on"
+        sequence:
+          - service: light.turn_on
+            target:
+              entity_id: !input closet_light
-- 
GitLab