-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsterownik.yaml
384 lines (364 loc) · 11.4 KB
/
sterownik.yaml
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#use esphome 2024.5 or lower. As for november 2024 dallas component is still broken in newer versions.
esphome:
name: sterownik_kotla_v2
on_boot:
- state_machine.set: IDLE
- switch.turn_off: stove_relay
- switch.turn_off: wh_relay
- logger.log:
format: "FW VERSION: 0.3"
level: WARN
esp32:
board: esp32dev
# Enable logging
logger:
#level: WARN
level: DEBUG
# Enable Home Assistant API
api:
encryption:
key: "skR9b3kg8faCvxnHIbOD6wVlXalUKTOzlHtLhpnUOA8="
ota:
password: "28cf72c4b1505ff8519fee3d866a9d54"
packages:
wifi: !include wifi.yaml
captive_portal:
spi:
clk_pin: GPIO17 # sck
mosi_pin: GPIO23 # mosi -> SDA(Serial DAta)
font:
- file: "arial.ttf"
id: arial
size: 10
- file: "Consolas.ttf"
id: consolas
size: 10
color:
- id: light_red
red: 100%
green: 20%
blue: 25%
white: 0%
- id: light_green
red: 0%
green: 100%
blue: 25%
white: 0%
display:
- platform: st7735
model: "INITR_18BLACKTAB"
cs_pin: GPIO21 # D21->CS
dc_pin: GPIO22 # D22->A0
#reset_pin: D6 # ->RESET
rotation: 180
device_width: 128
device_height: 160
col_start: 0
row_start: 0
eight_bit_color: true
update_interval: 1s
lambda: |-
it.printf(0, 0, id(consolas), "Stan: %s", id(current_state).state.c_str());
it.printf(0, 9, id(consolas), "Tryb: %s", id(mode).c_str());
it.printf(0, 18, id(consolas), id(light_green), "------- Bufor --------");
it.printf(0, 27, id(consolas), " %12s %.1f °C", "Gora:", id(buffer_temp_top).state);
it.printf(0, 36, id(consolas), " %12s %.1f °C", "Dol:", id(buffer_temp_bottom).state);
it.printf(0, 45, id(consolas), " %12s %.1f °C", "T zadana:", id(buffer_temp_target).state);
it.printf(0, 54, id(consolas), " %12s %.1f °C", "T minimalna:", id(buffer_temp_min).state);
it.printf(0, 63, id(consolas), id(light_green), "-------- CWU ---------");
it.printf(0, 72, id(consolas), " %12s %.1f °C", "Temperatura:", id(WH_temp).state);
it.printf(0, 81, id(consolas), " %12s %.1f °C", "T zadana:", id(WH_temp_target).state);
it.printf(0, 90, id(consolas), " %12s %.1f °C", "T minimalna:", id(WH_temp_min).state);
it.printf(0, 99, id(consolas), " ");
it.printf(0, 108, id(consolas), " %13s %s", "Kociol:", id(stove_relay).state==true?"ON":"OFF");
it.printf(0, 117, id(consolas), " %13s %s", "Grzanie CWU:", id(wh_relay).state==true?"ON":"OFF");
it.printf(0, 126, id(consolas), " %13s %s", "Pompa CWU:", true==true?"ON":"OFF");
it.printf(0, 135, id(consolas), " %13s %s", "Dogrzewanie :", id(top_up_active)==true?"ON":"OFF") ;
it.printf(0, 144, id(consolas), " %13s %s", "WiFi:", id(wifi_id).is_connected()==true?"Polaczono":"Blad!");
globals:
- id: mode
type: std::string
initial_value: '"LATO"'
restore_value: True
- id: top_up_active
type: bool
initial_value: 'true'
external_components:
- source:
type: git
url: https://github.com/muxa/esphome-state-machine
text_sensor:
- platform: state_machine
id: current_state
name: Current State
on_value:
- logger.log:
format: "Entering %s state"
args: [ 'id(current_state).state.c_str()']
level: WARN
state_machine:
- name: "Maszyna stanów kotłowni"
id: "sm1"
initial_state: IDLE
states:
- name: IDLE
on_enter:
- switch.turn_off: stove_relay
- switch.turn_off: wh_relay
- name: BUFFER_LOADING
on_enter:
- switch.turn_on: stove_relay
- switch.turn_off: wh_relay
- name: BUFFER_FULL
on_enter:
- if:
condition: # jeśli ustawiona jest flaga DOGRZEWANIE_CWU. nie sprawdzam temeraatury zasobnika, najwyżej od rezu się wyłaczy
lambda: 'return id(top_up_active);'
then:
- state_machine.transition: TOP_UP
else:
- state_machine.transition: GO_IDLE
- name: WH_LOADING
on_enter:
- switch.turn_on: stove_relay
- switch.turn_on: wh_relay
- name: WH_LOADING_INTERRUPTED #do tego stanu przechodzi, gdy trzeba podgrzać CWU w trakcie grzania bufora. Normalnie po nagrzniu CWU przeszedłbby w IDLE
#ale z tego stanu wraca do grzania bufora
on_enter:
- switch.turn_on: stove_relay
- switch.turn_on: wh_relay
- name: WH_FULL #ciągle nie jestem pewien, czy ten stan jest potrzebny. W teorii ma zapobiec chwilowemu wyłaczeniu przekaźnika, bo nie wiadomo jak się wtedy piec zachowa
#cholera wie, czy nie zacznie sie wygaszać, daję sobie 2,5 czasu na ewentualny trigger z dallas_temp przejście do grzania bufora
on_enter:
- if:
condition:
lambda: 'return id(mode) == "LATO";'
then:
- logger.log:
format: ""
level: WARN
- state_machine.transition: GO_IDLE
- if:
condition:
and:
- lambda: 'return id(mode) == "ZIMA";'
- lambda: 'return id(top_up_active);'
then:
- state_machine.transition: TOP_UP
- if:
condition:
and:
- lambda: 'return id(mode) == "ZIMA";'
- lambda: 'return ~id(top_up_active);'
then:
- state_machine.transition: GO_IDLE
- name: WH_TOP_UP #dogrzewanie cwu. po naładowaniu bufora dogrzewamy zasobnik, żeby uniknąć niepotrzebnego wygaszania kotła
on_enter:
- if:
condition:
- lambda: 'return id(WH_temp).state >= id(WH_temp_target).state;'
then:
- state_machine.transition: GO_IDLE
else:
- switch.turn_on: stove_relay
- switch.turn_on: wh_relay
- name: BUFFER_TOP_UP #dogrzewanie bufora, analogicznie co CWU
on_enter:
- if:
condition:
- lambda: 'return id(buffer_temp_bottom).state >= id(buffer_temp_target).state;'
then:
- state_machine.transition: GO_IDLE
else:
- switch.turn_on: stove_relay
- switch.turn_off: wh_relay
inputs:
- name: WH_TEMP_BELOW_MIN
transitions:
- IDLE -> WH_LOADING
- BUFFER_LOADING -> WH_LOADING_INTERRUPTED
- BUFFER_TOP_UP -> WH_LOADING_INTERRUPTED
- name: WH_TEMP_REACHED
transitions:
- WH_LOADING -> WH_FULL
- WH_TOP_UP -> WH_FULL
- WH_LOADING_INTERRUPTED -> BUFFER_LOADING
- name: BUFFER_TEMP_BELOW_MIN
transitions:
- IDLE -> BUFFER_LOADING
- WH_FULL -> BUFFER_LOADING #patrz: komentarz do stanu WH_FULL
- name: BUFFER_TEMP_REACHED
transitions:
- BUFFER_LOADING -> BUFFER_FULL
- BUFFER_TOP_UP -> BUFFER_FULL
- name: TOP_UP
transitions:
- BUFFER_FULL -> WH_TOP_UP
- WH_FULL -> BUFFER_TOP_UP
- name: GO_IDLE
transitions:
- BUFFER_FULL -> IDLE
- BUFFER_TOP_UP -> IDLE
- WH_LOADING -> IDLE
- WH_TOP_UP -> IDLE
- WH_FULL -> IDLE
number:
- platform: template
name: "T. zadana bufora"
id: buffer_temp_target
restore_value: True
initial_value: 75
optimistic: True
min_value: 50
max_value: 80
step: 1
- platform: template
name: "T. minimalna bufora"
id: "buffer_temp_min"
optimistic: True
restore_value: True
initial_value: 35
min_value: 30
max_value: 40
step: 1
- platform: template
name: "T. zadana CWU"
id: "WH_temp_target"
restore_value: True
initial_value: 45
optimistic: True
min_value: 40
max_value: 60
step: 1
- platform: template
name: "T. minimalna CWU"
id: "WH_temp_min"
optimistic: True
restore_value: True
initial_value: 35
min_value: 30
max_value: 45
step: 1
dallas:
#- platform: gpio
pin: GPIO14
update_interval: 2s
sensor:
- platform: dallas
accuracy_decimals: 1
address: 0x3c3c01d607bbfb28
# dół bufora ma adres address: 0x3d0922200f71d728
name: "Bufor gora"
id: "buffer_temp_top"
on_value:
if:
condition: # jeśli temperatura na górze BUFORA spadnie poniżej minimalnej
and:
- lambda: 'return id(buffer_temp_top).state < id(buffer_temp_min).state;'
- lambda: 'return id(mode) == "ZIMA";'
then:
- state_machine.transition: BUFFER_TEMP_BELOW_MIN
#####
- platform: dallas
accuracy_decimals: 1
address: 0x2c08222017ed7f28
name: "Bufor dol"
id: "buffer_temp_bottom"
on_value:
if:
condition: # jeśli tempetatura na dole BUFORA osiognie temperaturę zadaną
lambda: 'return id(buffer_temp_bottom).state >= id(buffer_temp_target).state;'
then:
- state_machine.transition: BUFFER_TEMP_REACHED
- platform: dallas
accuracy_decimals: 1
address: 0x381268581e64ff28
name: "Zasobnik CWU"
id: "WH_temp"
on_value:
- if:
condition: #jeśli temperatura zasobnika poniżej dolnego limitu
lambda: 'return id(WH_temp).state < id(WH_temp_min).state;'
then:
- state_machine.transition: WH_TEMP_BELOW_MIN
- if:
condition:
lambda: 'return id(WH_temp).state >= id(WH_temp_target).state;'
then:
- state_machine.transition: WH_TEMP_REACHED
- platform: dallas
accuracy_decimals: 1
address: 0x3d0922200f71d728
name: "Zasobnik CWU dół"
id: "WH_temp_bottom"
switch:
- platform: gpio
pin: GPIO25
name: "Włączanie kotła"
id: stove_relay
#inverted: false
- platform: gpio
pin: GPIO33
name: "Grzanie CWU"
id: wh_relay #WH = water heater
#inverted: true
- platform: gpio
pin: GPIO32
name: "Cyrkulacja CWU"
id: hot_water_pump_relay
#inverted: true
- platform: gpio
pin: GPIO26
name: "Pompa obiegowa"
id: circulation_pump_relay
#inverted: true
- platform: template
name: "Tryb (Lato/Zima)"
id: mode_switch
turn_on_action:
- globals.set:
id: mode
value: '"ZIMA"'
- switch.template.publish:
id: mode_switch
state: !lambda 'return true;'
- logger.log:
format: "Mode: %s"
args: [ 'id(mode).c_str()']
level: WARN
turn_off_action:
- globals.set:
id: mode
value: '"LATO"'
- switch.template.publish:
id: mode_switch
state: !lambda 'return false;'
- logger.log:
format: "Mode: %s"
args: [ 'id(mode).c_str()']
level: WARN
- platform: template
name: "Dogrzewanie CWU"
id: top_up_switch
turn_on_action:
- globals.set:
id: top_up_active
value: "true"
- switch.template.publish:
id: top_up_switch
state: !lambda 'return true;'
- logger.log:
format: "top_up_active: %d"
args: [ 'id(top_up_active)']
level: WARN
turn_off_action:
- globals.set:
id: top_up_active
value: "false"
- switch.template.publish:
id: top_up_switch
state: !lambda 'return false;'
- logger.log:
format: "top_up_active: %d"
args: [ 'id(top_up_active)']
level: WARN