]> git.giorgioravera.it Git - homeassistant.git/commitdiff
Added 10 minutes timeout to turn off bathroom automatic light
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Tue, 7 Apr 2026 07:30:29 +0000 (09:30 +0200)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Tue, 7 Apr 2026 07:30:29 +0000 (09:30 +0200)
automations/lights.yaml

index 775d00beb446d32ba065391ad8df5cb33a2b1014..6dc0bed0b1e531d837d5b614c8cdeef12eab7c00 100644 (file)
@@ -7,14 +7,15 @@
 - alias: "Accendi luce bagno se occupato e casa non vuota"
   id: "accendi_luci_presenza_bagno_grande"
   description: >
-    Se qualcuno è in casa, il bagno è occupato,
-    il sole è basso e siamo tra le 15:00 e le 05:00,
-    accende la luce del bagno grande.
-  trigger:
+    If someone is at home, the bathroom is occupied,
+    the sun is low, and it is between 3:00 p.m. and 5:00 a.m.,
+    turn on the light in the large bathroom and turn it off after a while.
+  triggers:
     - platform: state
       entity_id: binary_sensor.sensore_presenza_bagno_grande_occupancy
       to: "on"
-  condition:
+
+  conditions:
     - condition: state
       entity_id: group.residents
       state: "home"
       entity_id: sun.sun
       attribute: elevation
       below: 1
-  action:
+
+  actions:
     - service: light.turn_on
       target:
         entity_id: light.luce_trono
-  mode: single
+
+    # Wait 10 minutes before checking if the light should be turned off
+    - delay: "00:10:00"
+
+    # Turn off only if there is no more presence in the bathroom
+    - condition: state
+      entity_id: binary_sensor.sensore_presenza_bagno_grande_occupancy
+      state: "off"
+
+    - service: light.turn_off
+      target:
+        entity_id: light.luce_trono
+
+  mode: restart