Ver Fonte

switch lights-on condition from time to sun.elevation

Martin há 6 anos atrás
pai
commit
c49a6f328d
1 ficheiros alterados com 21 adições e 16 exclusões
  1. 21 16
      hass/confs/configuration.yaml

+ 21 - 16
hass/confs/configuration.yaml

@@ -4,7 +4,7 @@ homeassistant:
   name: Home
   latitude: 52.1187
   longitude: 5.0994
-  elevation: 0
+  elevation: 10
   unit_system: metric
   time_zone: Europe/Dublin
   customize: !include customize.yaml
@@ -46,6 +46,11 @@ sensor:
       # - highClouds
       # - dewpointTemperature
 
+  - platform: template
+    sensors:
+      solar_angle:
+        unit_of_measurement: 'degrees'
+        value_template: "{{ state_attr('sun.sun', 'elevation') }}"
 
 # used for snips
 # mqtt:
@@ -98,7 +103,7 @@ automation:
         data_template:
           message: "sensor.aeotec_multisensor_6_burglar state: {{ states('sensor.aeotec_multisensor_6_burglar') }}"
 
-  - alias: Turn on hallway light (motion)
+  - alias: Turn on lights (motion)
     initial_state: true
     trigger:
       - platform: state
@@ -110,21 +115,13 @@ automation:
         from: "3"
         to: "8"
     condition:
-      - condition: time
-        after: '15:00:00'
-        before: '08:00:00'
+      - condition: numeric_state
+        entity_id: sensor.solar_angle
+        below: 0
     action:
       - service: script.lights_on
 
-  - alias: Turn off hallway light (midnight timer)
-    trigger:
-      platform: time_pattern
-      hours: '0'
-      minutes: '0'
-    action:
-      - service: script.lights_off
-
-  - alias: Turn off hallway light (no motion)
+  - alias: Turn off lights (no motion)
     initial_state: true
     trigger:
       - platform: state
@@ -141,8 +138,16 @@ automation:
           minutes: 1
     condition:
       - condition: time
-        after: '00:00:00'
-        before: '17:00:00'
+        after: '23:30:00'
+        before: '19:00:00'
+    action:
+      - service: script.lights_off
+
+  - alias: Turn off lights (midnight timer)
+    trigger:
+      platform: time_pattern
+      hours: '23'
+      minutes: '30'
     action:
       - service: script.lights_off