ik heb mijn code verder verfijnt. In het eerste variabelen blok kunnen parameters opgegeven worden, waarmee de rest van de automatisering werkt. De rest van de automatisering is voor iedere zone identiek. Dit is mijn huidige code:
Naast deze automatisering zijn per zone nog een aantal helpers nodig, die ik in configuration.yaml heb opgenomen:
De helpers met manual heb ik in de frontentopgenomen, zodat ik de automatisering tijdelijk kan overrulen.
:strip_exif()/f/image/Wq6upBMpAkFb76g0DTYPg1MQ.jpg?f=fotoalbum_large)
Als die temperatuur hoger ligt dan de huidige temperatuur, wordt de setpoint ook met kleine stapjes verhoogd.
Ik moet nog een ding regelen, en dat is dat de automatisering ook wordt aangeroepen na een herstart van homeassistant. Als een herstart plaatsvindt op het moment dat ook de automatisering zou moeten worden uitegevoerd op moment next_time, wordt next_time niet aangepast, stopt de automatisering en neemt het Evohome schema het weer over. In principe weet je wanneer je homeassistant herstart en kun je de automatisering even handmatig laten uitvoeren, dan werkt ie ook weer, maar het is charmanter als dat automatisch gebeurt :-).
code:
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
| alias: CE0.1 woonkamer EVOhome verhoging description: >- max_temp is the temperature to reach, the automation will raise the temperature by variable delta degrees (depending on the specific zone, delta could be higher than 0.1) every 20 minutes (this depends on the first trigger and can be set faster or slower by changing the value in the trigger) until max_temp is reached." max_temp is set according a schedule, there's a week (sp_week) and weekend (sp_wknd) schedule. you can use as many setpoint as you like, but they should increase in time and when you set to manay, the evohome service might be blocked. " The automation will not run if the zone is set to a Permanent temperature. The automation will run between firstrun and lastrun, where firstrun depends on a trigger with id 'First run'. There can be more than one 'First run' and if the mode is changed from 'Permanent' this will also trigger 'First run'. It's best to set lastrun after an Evohome setpoint where the temperature will not be raised again (lower setpoints have no effect)." triggers: - trigger: time at: "02:10:00" id: First run - trigger: time at: input_datetime.woonkamer_next_time enabled: true - trigger: state entity_id: - climate.woonkamer attribute: preset_mode from: permanent id: First run to: none - trigger: state entity_id: - climate.woonkamer attribute: preset_mode from: permanent to: temporary id: First run - trigger: state entity_id: - input_number.woonkamer_temp_manual - trigger: state entity_id: - input_boolean.iemand_in_regio to: "on" conditions: - condition: not conditions: - condition: state entity_id: input_boolean.iemand_in_regio state: "off" for: hours: 4 minutes: 0 seconds: 0 actions: - variables: evozone: woonkamer freq_run: 20 max_temp_start: 20.5 sp_week: - - "07:00" - 20 - - "11:00" - 20.8 - - "16:00" - 20.5 - - "20:00" - 20.8 sp_wknd: - - "09:00" - 20.5 - - "11:00" - 20.7 - - "17:00" - 20.5 - - "20:00" - 20.8 lastrun: "{{ '22:30' if now().weekday() in (6,0,1,2,4) else '23:30' }}" alias: Configuration variables - alias: General variables (better not change) variables: climatezone: climate.{{evozone}} start_time: input_datetime.{{evozone}}_start_time manual_time: input_datetime.{{evozone}}_manual_time manual_temp: input_number.{{evozone}}_temp_manual max_temp: >- {% if now().weekday() in (5,6)%} {% set sp = sp_wknd %} {% else %} {% set sp = sp_week %} {% endif%} {% set ns = namespace(value=max_temp_start) %} {% for row in sp %} {% if now() > today_at(row[0]) %} {% set ns.value = row[1] %} {% endif %} {% endfor %} {% if (now() | as_timestamp < states(manual_time) | as_timestamp ) and (states(manual_temp) | float(0) > 5) %} {{states(manual_temp)}} {% else %} {{ns.value }} {% endif%} firstrun: |- {% if trigger.id == 'First run' %} {%set stamp = now()%} {% else %} {% set stamp = states(start_time) %} {% endif%} {{ stamp | as_timestamp | timestamp_custom('%H:%M')}} lastrun: >- {{ lastrun if (today_at(lastrun) | as_timestamp) > (states(manual_time) | as_timestamp) else (states(manual_time) | as_timestamp | timestamp_custom('%H:%M')) }} current_temp: "{{ state_attr(climatezone, 'temperature') | float }}" actual_temp: "{{ state_attr(climatezone, 'current_temperature') | float }}" delta: "{{0.2 if (current_temp <= 20 ) else 0.1}}" - if: - condition: and conditions: - alias: Between firstrun and last run or trigger is First run condition: or conditions: - alias: Time between firstrun and last run+(freq_run+5) minutes condition: template value_template: >- {{ today_at(firstrun) <= now() <= (today_at(lastrun)+timedelta(minutes=(freq_run+5)))}} - condition: trigger id: - First run - alias: "Not equal to permanent " condition: not conditions: - condition: template value_template: "{{is_state_attr(climatezone,'preset_mode','permanent')}}" then: - alias: >- Sets the firstrun time if the automation is started by a trigger with id = ‘First run’ if: - condition: trigger id: - First run then: - action: input_datetime.set_datetime metadata: {} data: timestamp: >- {{(now()) | as_timestamp | timestamp_custom('%H:%M') | today_at | as_timestamp}} target: entity_id: input_datetime.{{evozone}}_start_time - if: - condition: or conditions: - condition: template value_template: "{{now() > today_at(lastrun)}}" then: - if: - condition: template value_template: "{{is_state_attr(climatezone,'preset_mode','temporary')}}" then: - action: evohome.clear_zone_override data: entity_id: climate.{{evozone}} - action: input_datetime.set_datetime metadata: {} data: timestamp: >- {{ (today_at(lastrun) - timedelta(minutes=30)).timestamp()}} target: entity_id: input_datetime.{{evozone}}_start_time - action: input_number.set_value metadata: {} data: value: 5 target: entity_id: "{{manual_temp}}" else: - action: input_datetime.set_datetime metadata: {} data: timestamp: >- {{(now()+timedelta(minutes=freq_run)) | as_timestamp | timestamp_custom('%H:%M') | today_at | as_timestamp}} target: entity_id: input_datetime.{{evozone}}_next_time - data: setpoint: >- {{ min(max_temp | float, max((current_temp+delta) | float, (actual_temp+delta) | float) ) }} duration: "00:30:00" entity_id: climate.{{evozone}} action: evohome.set_zone_override alias: >- Actie uitvoeren 'Honeywell Total Connect Comfort (Europe): Set zone override' on evozone for 30 minutes. This repeats until lastrun. From then on the evohome schedule continues. enabled: true mode: single |
Naast deze automatisering zijn per zone nog een aantal helpers nodig, die ik in configuration.yaml heb opgenomen:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| input_number: woonkamer_temp_manual: name: Woonkamer temp manual unit_of_measurement: "Cº" step: 0.1 min: 5 max: 25 mode: box input_datetime: #Evohome raise woonkamer_start_time: name: Woonkamer start time has_date: true has_time: true woonkamer_next_time: name: Woonkamer next time has_date: true has_time: true woonkamer_manual_time: name: Woonkamer manual until time has_date: true has_time: true |
De helpers met manual heb ik in de frontentopgenomen, zodat ik de automatisering tijdelijk kan overrulen.
:strip_exif()/f/image/Wq6upBMpAkFb76g0DTYPg1MQ.jpg?f=fotoalbum_large)
Als die temperatuur hoger ligt dan de huidige temperatuur, wordt de setpoint ook met kleine stapjes verhoogd.
Ik moet nog een ding regelen, en dat is dat de automatisering ook wordt aangeroepen na een herstart van homeassistant. Als een herstart plaatsvindt op het moment dat ook de automatisering zou moeten worden uitegevoerd op moment next_time, wordt next_time niet aangepast, stopt de automatisering en neemt het Evohome schema het weer over. In principe weet je wanneer je homeassistant herstart en kun je de automatisering even handmatig laten uitvoeren, dan werkt ie ook weer, maar het is charmanter als dat automatisch gebeurt :-).