Pārlūkot izejas kodu

add another light; switch to use reusable scripts

Martin 6 gadi atpakaļ
vecāks
revīzija
945cf7b4c3
1 mainītis faili ar 26 papildinājumiem un 25 dzēšanām
  1. 26 25
      hass/confs/configuration.yaml

+ 26 - 25
hass/confs/configuration.yaml

@@ -65,15 +65,24 @@ sensor:
 #     enable_websocket: false
 
 script:
-  # test_function:
-  #   sequence:
-  #     - service: system_log.write
-  #       data_template:
-  #         message: Test 1 ({{duration}})...
-  #     - delay: '{{duration}}'
-  #     - service: system_log.write
-  #       data:
-  #         message: Test 2...
+  lights_off:
+    sequence:
+      - service: system_log.write
+        data:
+          message: "***** Turning off the lights"
+      - service: homeassistant.turn_off
+        entity_id: switch.wenzhou_tkb_0
+      - service: homeassistant.turn_off
+        entity_id: switch.wenzhou_tkb_1
+  lights_on:
+    sequence:
+      - service: system_log.write
+        data:
+          message: "***** Turning on the lights"
+      - service: homeassistant.turn_on
+        entity_id: switch.wenzhou_tkb_0
+      - service: homeassistant.turn_on
+        entity_id: switch.wenzhou_tkb_1
 
 automation:
   - alias: Log motion detection status
@@ -100,12 +109,12 @@ automation:
         entity_id: sensor.aeotec_multisensor_6_burglar
         from: "3"
         to: "8"
+    condition:
+      - condition: time
+        after: '15:00:00'
+        before: '08:00:00'
     action:
-      - service: system_log.write
-        data:
-          message: "***** State to 8 -- turn on hallway light"
-      - service: homeassistant.turn_on
-        entity_id: switch.wenzhou_tkb_0
+      - service: script.lights_on
 
   - alias: Turn off hallway light (midnight timer)
     trigger:
@@ -113,11 +122,7 @@ automation:
       hours: '0'
       minutes: '0'
     action:
-      - service: system_log.write
-        data:
-          message: "Midnight -- turning off the hallway light"
-      - service: homeassistant.turn_off
-        entity_id: switch.wenzhou_tkb_0
+      - service: script.lights_off
 
   - alias: Turn off hallway light (no motion)
     initial_state: true
@@ -137,13 +142,9 @@ automation:
     condition:
       - condition: time
         after: '00:00:00'
-        before: '16:00:00'
+        before: '17:00:00'
     action:
-      - service: system_log.write
-        data:
-          message: "***** Turning off the hallway light"
-      - service: homeassistant.turn_off
-        entity_id: switch.wenzhou_tkb_0
+      - service: script.lights_off
 
   # - alias: water immersion (weekdays)
   #   initial_state: false