-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomatic climate system.txt
345 lines (345 loc) · 19.3 KB
/
automatic climate system.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
alias: Airco - Automatic Climate System
description: ""
trigger:
- platform: time_pattern
minutes: /10
- platform: state
entity_id:
- input_boolean.home_occupation
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.allow_airco_start_stop
state: "off"
- condition: state
entity_id: input_boolean.home_occupation
state: "off"
sequence:
- repeat:
count: "{{ ac_off_count }}"
sequence:
- if:
- condition: numeric_state
entity_id: sensor.hourly_consumption_average
below: -700
then:
- service: script.airco_action_an_ac_with_params
data: |
{% set airco = ac_off[repeat.index-1] %}
{"ac_name": "{{ airco }}", "ac_mode": "dry", "ac_temp": "20", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
- stop: airco starts drying
- repeat:
count: "{{ ac_on_count }}"
sequence:
- if:
- condition: numeric_state
entity_id: sensor.hourly_consumption_average
above: -100
then:
- service: script.airco_action_an_ac_with_params
data: |
{% set airco = ac_on_inv[repeat.index-1] %}
{"ac_name": "{{ airco }}", "ac_mode": "dry", "ac_temp": "20", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
- stop: airco decreased to drying
- repeat:
count: "{{ ac_dry_count }}"
sequence:
- if:
- condition: numeric_state
entity_id: sensor.hourly_consumption_average
above: -100
then:
- service: script.airco_action_an_ac_with_params
data:
ac_name: "{{ ac_dry_inv[repeat.index-1] }}"
ac_mode: "off"
- stop: airco stopped
- repeat:
count: "{{ ac_dry_count }}"
sequence:
- if:
- condition: template
value_template: >
{{ (states('sensor.hourly_consumption_average') |
float(0) < -700) and
( (states('sensor.median_indoor_tempererature') | float(0) <= 21) or
(states('sensor.median_indoor_tempererature') | float(0) >= 25)
) }}
then:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_dry[repeat.index-1] %} {% if
(states('sensor.median_indoor_tempererature') | float(0)
<= 21) %}
{"ac_name": "{{ airco }}", "ac_mode": "heat", "ac_temp": "{{ mapping_attributes[airco][1] | int(0) - 1 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
{% else %}
{"ac_name": "{{ airco }}", "ac_mode": "cool", "ac_temp": "{{ mapping_attributes[airco][2] | int(0) + 1 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
{% endif %}
- stop: airco switched from drying to heating or cooling
- conditions:
- condition: state
entity_id: input_boolean.allow_airco_start_stop
state: "off"
- condition: state
entity_id: input_boolean.home_occupation
state: "on"
sequence:
- repeat:
count: "{{ ac_off_count }}"
sequence:
- if:
- condition: template
value_template: |
{% set airco = ac_off[repeat.index-1] %} {{
(states('input_boolean.ac_auto_'+mapping_attributes[airco][0]) == 'on') and
not ( (states('sensor.average_outside_temperature') | float(0) > 19) and
(states('sensor.average_outside_temperature') | float(0) < 25) and
(states('sensor.hourly_consumption_average') | float(0) > -700) ) }}
then:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_off[repeat.index-1] %} {% if
(states('sensor.average_outside_temperature') | float(0)
<= 19) %}
{"ac_name": "{{ airco }}", "ac_mode": "heat", "ac_temp": "{{ mapping_attributes[airco][1] | int(0) - 1 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
{% elif (states('sensor.median_indoor_tempererature') |
float(0) >= 25) %}
{"ac_name": "{{ airco }}", "ac_mode": "cool", "ac_temp": "{{ mapping_attributes[airco][2] | int(0) + 1 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
{% else %}
{"ac_name": "{{ airco }}", "ac_mode": "dry", "ac_temp": "20", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
{% endif %}
- stop: new airco starts
- repeat:
count: "{{ ac_all_on_count }}"
sequence:
- if:
- condition: template
value_template: |
{% set airco = ac_all_on[repeat.index-1] %}
{{ (states('input_boolean.ac_auto_'+mapping_attributes[airco][0]) == 'on') }}
then:
- choose:
- conditions:
- condition: template
value_template: >-
{{ states('sensor.average_outside_temperature')
| float(0) <= 19 }}
sequence:
- if:
- condition: template
value_template: |
{% set airco = ac_all_on[repeat.index-1] %}
{{ (states('sensor.hourly_consumption_average') | float(0) > -100) and
( ( (mapping_attributes[airco][0] | truncate(2,false,'') == 'sa') and
((now().hour >= 23) or (now().hour < 9)) ) or
( (mapping_attributes[airco][0] | truncate(2,false,'') == 'ch') and
((now().hour >= 9) and (now().hour < 18)) ) ) }}
then:
- if:
- condition: template
value_template: >-
{% set airco = ac_all_on[repeat.index-1]
%}
{{ (states(airco) != 'heat') or
(state_attr(airco, 'temperature') | float(0) != mapping_attributes[airco][1] | int(0) - 1) }}
then:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%}
{"ac_name": "{{ airco }}", "ac_mode": "heat", "ac_temp": "{{ mapping_attributes[airco][1] | int(0) - 1 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
- stop: starting reduced heating
else:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%}
{"ac_name": "{{ airco }}", "ac_mode": "heat", "ac_temp": "{{ mapping_attributes[airco][1] | int(0) - 1 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
else:
- if:
- condition: template
value_template: >-
{% set airco = ac_all_on[repeat.index-1]
%}
{{ (states(airco) != 'heat') or
(state_attr(airco, 'temperature') | float(0) != mapping_attributes[airco][1]) }}
then:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%}
{"ac_name": "{{ airco }}", "ac_mode": "heat", "ac_temp": "{{ mapping_attributes[airco][1] }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
- stop: starting normal heating
else:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%}
{"ac_name": "{{ airco }}", "ac_mode": "heat", "ac_temp": "{{ mapping_attributes[airco][1] }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
- conditions:
- condition: template
value_template: |-
{{
(states('sensor.average_outside_temperature') | float(0) > 19) and
(states('sensor.average_outside_temperature') | float(0) < 25)
}}
sequence:
- if:
- condition: template
value_template: >-
{{
states('sensor.hourly_consumption_average')
| float(0) > -100 }}
then:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%}
{"ac_name": "{{ airco }}", "ac_mode": "off" }
- stop: airco stopped
else:
- if:
- condition: template
value_template: >-
{{ (states(ac_all_on[repeat.index-1]) !=
'dry') }}
then:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%}
{"ac_name": "{{ airco }}", "ac_mode": "dry", "ac_temp": "20", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
- stop: start drying
else:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%}
{"ac_name": "{{ airco }}", "ac_mode": "dry", "ac_temp": "20", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
- choose:
- conditions:
- condition: template
value_template: >-
{{ states('sensor.average_outside_temperature')
| float(0) >= 25 }}
sequence:
- if:
- condition: template
value_template: |
{% set airco = ac_all_on[repeat.index-1] %}
{{ (states('sensor.hourly_consumption_average') | float(0) > -100) and
( ( (mapping_attributes[airco][0] | truncate(2,false,'') == 'sa') and
((now().hour >= 23) or (now().hour < 9)) ) or
( (mapping_attributes[airco][0] | truncate(2,false,'') == 'ch') and
((now().hour >= 9) and (now().hour < 18)) ) ) }}
then:
- if:
- condition: template
value_template: >-
{{ (states(ac_all_on[repeat.index-1]) !=
'cool') }}
then:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%}
{"ac_name": "{{ airco }}", "ac_mode": "cool", "ac_temp": "{{ mapping_attributes[airco][2] | int(0) + 2 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
- stop: starting reduced heating
else:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%}
{"ac_name": "{{ airco }}", "ac_mode": "cool", "ac_temp": "{{ mapping_attributes[airco][2] | int(0) + 2 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
else:
- if:
- condition: template
value_template: >-
{{ (states(ac_all_on[repeat.index-1]) !=
'cool') }}
then:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%} {% if
(states('sensor.hourly_consumption_average')
| float(0) <= -100) %}
{"ac_name": "{{ airco }}", "ac_mode": "cool", "ac_temp": "{{ mapping_attributes[airco][2] | int(0) - 1 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
{% else %}
{"ac_name": "{{ airco }}", "ac_mode": "cool", "ac_temp": "{{ mapping_attributes[airco][2] }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
{% endif %}
- stop: starting normal or increased cooling
else:
- service: script.airco_action_an_ac_with_params
data: >
{% set airco = ac_all_on[repeat.index-1]
%} {% if
(states('sensor.hourly_consumption_average')
| float(0) <= -100) %}
{"ac_name": "{{ airco }}", "ac_mode": "cool", "ac_temp": "{{ mapping_attributes[airco][2] | int(0) - 1 }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
{% else %}
{"ac_name": "{{ airco }}", "ac_mode": "cool", "ac_temp": "{{ mapping_attributes[airco][2] }}", "ac_suffix": "{{ mapping_attributes[airco][0] }}" }
{% endif %}
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.allow_airco_start_stop
mode: single
variables:
ac_off: >
{{ expand(area_entities('Clims')) | selectattr('state','in', ['off']) |
sort(attribute='entity_id') | map(attribute='entity_id') | list }}
ac_off_count: >
{{ expand(area_entities('Clims')) | selectattr('state','in', ['off']) | list
| count }}
ac_all_on: >
{{ expand(area_entities('Clims')) | rejectattr('state','in', ['unknown',
'unavailable', 'off']) | sort(attribute='entity_id', reverse=true) |
map(attribute='entity_id') | list }}
ac_all_on_count: >
{{ expand(area_entities('Clims')) | rejectattr('state','in', ['unknown',
'unavailable', 'off']) | list | count }}
ac_on_inv: >
{{ expand(area_entities('Clims')) | rejectattr('state','in', ['unknown',
'unavailable', 'off', 'dry']) | sort(attribute='entity_id', reverse=true) |
map(attribute='entity_id') | list }}
ac_on_count: >
{{ expand(area_entities('Clims')) | rejectattr('state','in', ['unknown',
'unavailable', 'off', 'dry']) | list | count }}
ac_dry: >
{{ expand(area_entities('Clims')) | selectattr('state','in', ['dry']) |
sort(attribute='entity_id') | map(attribute='entity_id') | list }}
ac_dry_inv: >
{{ expand(area_entities('Clims')) | selectattr('state','in', ['dry']) |
sort(attribute='entity_id', reverse=true) | map(attribute='entity_id') |
list }}
ac_dry_count: >
{{ expand(area_entities('Clims')) | selectattr('state','in', ['dry']) | list
| count }}
mapping_attributes:
climate.ac_1_chambre_haut_fond:
- ch_haut_fond
- 17
- 24
climate.ac_2_chambre_bas_fond:
- ch_bas_fond
- 17
- 25
climate.ac_3_chambre_haut_avant:
- ch_haut_avant
- 17
- 25
climate.ac_4_chambre_bas_avant:
- ch_bas_avant
- 17
- 25
climate.ac_5_salon_bas:
- salon_bas
- 17
- 25
climate.ac_6_salon_haut:
- salon_haut
- 19
- 24