]> git.giorgioravera.it Git - homeassistant.git/commitdiff
Added climate script
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 11 Feb 2019 14:24:43 +0000 (15:24 +0100)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 11 Feb 2019 14:24:43 +0000 (15:24 +0100)
automation/climate.yaml
automation/day.yaml
script/climate.yaml [new file with mode: 0644]

index 0fc6a63f923bd8870660434f376eba08c7121765..289cd65d5a0b2277cbc5a11d489a6486624688f1 100644 (file)
@@ -1,9 +1,9 @@
 ######################################################################
 # Climate: Weekly Schedule
-# - climate.set_temperature
+# - script.climate_daily_schedule
 ######################################################################
 
-- alias: "Termosifoni: Schedule Settimanale"
+- alias: "Termosifoni: Schedule Feriale"
   trigger:
     - platform: time
       at: '06:30:00'
         state: 'off'
 
       - condition: time
-        weekday:
-        - mon
-        - tue
-        - wed
-        - thu
-        - fri
+        weekday: [mon, tue, wed, thu, fri]
 
   action:
-    - service: climate.set_temperature
+    - service: script.climate_daily_schedule
       data_template:
         entity_id: climate.bagno_termostato_cucina
-        temperature: >-
-        {% if trigger.now.hour == 6 %}
-          20
-        {% elif trigger.now.hour == 7 %}
-          18
-        {% elif trigger.now.hour == 9 %}
-          20
-        {% elif trigger.now.hour == 18 %}
-          20.5
-        {% elif trigger.now.hour == 22 %}
-          16
-        {% else % }
-          16
-        {% endif %}
+        temp1: 20
+        temp2: 18
+        temp3: 20
+        temp4: 20.5
+        temp5: 16
 
-    - service: climate.set_temperature
+    - service: script.climate_daily_schedule
       data_template:
         entity_id: climate.bagno_termostato_sala
-        temperature: >-
-        {% if trigger.now.hour == 6 %}
-          18
-        {% elif trigger.now.hour == 7 %}
-          18
-        {% elif trigger.now.hour == 9 %}
-          19.5
-        {% elif trigger.now.hour == 18 %}
-          20
-        {% elif trigger.now.hour == 22 %}
-          16
-        {% else % }
-          16
-        {% endif %}
+        temp1: 18
+        temp2: 18
+        temp3: 19.5
+        temp4: 20
+        temp5: 16
 
-    - service: climate.set_temperature
+    - service: script.climate_daily_schedule
       data_template:
         entity_id: climate.bagno_termostato_bagno
-        temperature: >-
-        {% if trigger.now.hour == 6 %}
-          19
-        {% elif trigger.now.hour == 7 %}
-          18
-        {% elif trigger.now.hour == 9 %}
-          19
-        {% elif trigger.now.hour == 18 %}
-          19.5
-        {% elif trigger.now.hour == 22 %}
-          16
-        {% else % }
-          16
-        {% endif %}
+        temp1: 19
+        temp2: 18
+        temp3: 19
+        temp4: 29.5
+        temp5: 16
 
-    - service: climate.set_temperature
+    - service: script.climate_daily_schedule
       data_template:
         entity_id: climate.bagno_termostato_studio
-        temperature: >-
-        {% if trigger.now.hour == 6 %}
-          18
-        {% elif trigger.now.hour == 7 %}
-          18
-        {% elif trigger.now.hour == 9 %}
-          19.5
-        {% elif trigger.now.hour == 18 %}
-          20
-        {% elif trigger.now.hour == 22 %}
-          16
-        {% else % }
-          16
-        {% endif %}
+        temp1: 18
+        temp2: 18
+        temp3: 19.5
+        temp4: 20
+        temp5: 16
 
-    - service: climate.set_temperature
+    - service: script.climate_daily_schedule
       data_template:
         entity_id: climate.bagno_termostato_camera
-        temperature: >-
-        {% if trigger.now.hour == 6 %}
-          19
-        {% elif trigger.now.hour == 7 %}
-          18
-        {% elif trigger.now.hour == 9 %}
-          19
-        {% elif trigger.now.hour == 18 %}
-          19.5
-        {% elif trigger.now.hour == 22 %}
-          16
-        {% else % }
-          16
-        {% endif %}
+        temp1: 19
+        temp2: 18
+        temp3: 19
+        temp4: 19.5
+        temp5: 16
index d6b71ba60f01c447013fcfb320a7b64258935c3e..f81829ea21eadb595be36103e2a474a232a3f3dc 100644 (file)
         state: 'off'
 
       - condition: time
-        weekday:
-        - mon
-        - tue
-        - wed
-        - thu
-        - fri
+        weekday: [mon, tue, wed, thu, fri]
 
   action:
     - service: cover.set_cover_position
diff --git a/script/climate.yaml b/script/climate.yaml
new file mode 100644 (file)
index 0000000..5ac8382
--- /dev/null
@@ -0,0 +1,38 @@
+######################################################################
+# Climate: Daily Schedule
+# Inputs:
+# - entity_id
+# - temp1
+# - temp2
+# - temp3
+# - temp4
+# - temp5
+#
+# Operations:
+# - cover.{{modus}}_cover
+######################################################################
+
+climate_daily_schedule:
+  alias: "Termosifoni: Schedulazione giornaliera"
+  sequence:
+    - service: climate.set_temperature
+      data_template:
+        entity_id: {{ entity_id }}
+        temperature: >-
+          {% set current_date_string = now().strftime("%H%M") %}
+          {% set time1_string = ("0630") %}
+          {% set time2_string = ("0730") %}
+          {% set time3_string = ("0900") %}
+          {% set time4_string = ("1830") %}
+          {% set time5_string = ("2200") %}
+          {% if (current_date_string|int >= (time1_string)|int) and ((current_date_string|int < (time2_string)|int)) %}
+            {{ temp1 }}
+          {% eliif (current_date_string|int >= (time2_string)|int) and ((current_date_string|int < (time3_string)|int)) %}
+            {{ temp2 }}
+          {% elif (current_date_string|int >= (time3_string)|int) and ((current_date_string|int < (time4_string)|int)) %}
+            {{ temp3 }}
+          {% elif (current_date_string|int >= (time4_string)|int) and ((current_date_string|int < (time5_string)|int)) %}
+            {{ temp4 }}
+          {% else % }
+            {{ temp5 }}
+          {% endif %}