-
Notifications
You must be signed in to change notification settings - Fork 1
/
heat.yaml
452 lines (418 loc) · 13.6 KB
/
heat.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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
esphome:
name: heater
platform: ESP32
board: nodemcu-32s
platformio_options:
upload_speed: 921600
#wifi:
# ssid: "test"
# password: "12345678"
# Enable fallback hotspot (captive portal) in case wifi connection fails
# ap:
# ssid: "heater Fallback Hotspot"
# password: "12345678"
# reboot_timeout: 0s
# power_save_mode: HIGH
#captive_portal:
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
#api:
#ota:
# Активация web сервера
#web_server:
# port: 80
globals:
- id: counter_sec
type: unsigned int
restore_value: no
initial_value: '0'
- id: device_mode
type: int
restore_value: no
initial_value: '-1'
- id: display_menu
type: int
restore_value: no
initial_value: '0'
- id: boiling_time
type: unsigned int
restore_value: yes
initial_value: '1800'
- id: boiling_temperature_low
type: float
restore_value: yes
initial_value: '125'
- id: boiling_temperature_high
type: float
restore_value: yes
initial_value: '135'
- id: waiting_temperature_low
type: float
restore_value: yes
initial_value: '75'
- id: waiting_temperature_high
type: float
restore_value: yes
initial_value: '85'
binary_sensor:
- platform: gpio
pin:
number: GPIO0
inverted: true
mode: INPUT_PULLUP
filters:
- delayed_on: 50ms
name: "Switch button"
on_click:
min_length: 50ms
max_length: 350ms
then:
- lambda: |-
id(display_menu) +=1;
if (id(display_menu) > 7) id(display_menu) = 0;
- logger.log: "Click"
- platform: gpio
pin:
number: GPIO32
inverted: true
mode: INPUT_PULLUP
name: "Encoder1 button"
on_click:
min_length: 50ms
max_length: 450ms
then:
- lambda: |-
switch(id(display_menu))
{
case 0:
id(display_menu) = 1;
id(rotary_encoder1).set_min_value(1);
id(rotary_encoder1).set_max_value(7);
id(rotary_encoder1).set_value(id(display_menu));
break;
case 1:
id(display_menu) = 0;
break;
case 2:
id(display_menu) = id(display_menu) * 10;
id(rotary_encoder1).set_min_value(50);
id(rotary_encoder1).set_max_value(150);
id(rotary_encoder1).set_value(id(boiling_temperature_low));
break;
case 3:
id(display_menu) = id(display_menu) * 10;
id(rotary_encoder1).set_min_value(50);
id(rotary_encoder1).set_max_value(150);
id(rotary_encoder1).set_value(id(boiling_temperature_high));
break;
case 4:
id(display_menu) = id(display_menu) * 10;
id(rotary_encoder1).set_min_value(0);
id(rotary_encoder1).set_max_value(999);
id(rotary_encoder1).set_value(id(boiling_time) / 60);
break;
case 5:
id(display_menu) = id(display_menu) * 10;
id(rotary_encoder1).set_min_value(50);
id(rotary_encoder1).set_max_value(150);
id(rotary_encoder1).set_value(id(waiting_temperature_low));
break;
case 6:
id(display_menu) = id(display_menu) * 10;
id(rotary_encoder1).set_min_value(50);
id(rotary_encoder1).set_max_value(150);
id(rotary_encoder1).set_value(id(waiting_temperature_high));
break;
case 7:
id(display_menu) = 0;
id(device_mode) = -1;
break;
default:
id(display_menu) = id(display_menu) / 10;
id(rotary_encoder1).set_min_value(1);
id(rotary_encoder1).set_max_value(7);
id(rotary_encoder1).set_value(id(display_menu));
break;
};
if (id(device_mode) < 2 )
{
auto call = id(my_climate).make_call();
call.set_target_temperature_low(id(boiling_temperature_low));
call.set_target_temperature_high(id(boiling_temperature_high));
call.perform();
}else
{
auto call = id(my_climate).make_call();
call.set_target_temperature_low(id(waiting_temperature_low));
call.set_target_temperature_high(id(waiting_temperature_high));
call.perform();
}
- component.update: my_display
script:
- id: check_mode
then:
- lambda: |-
if (id(device_mode) == -1 )
{
id(device_mode) = 0;
auto call = id(my_climate).make_call();
call.set_mode("AUTO");
call.set_target_temperature_low(id(boiling_temperature_low));
call.set_target_temperature_high(id(boiling_temperature_high));
call.perform();
id(relay_2).turn_on();
id(counter_sec) = 0;
}
if (id(device_mode) == 0)
{
if (id(temp_1).state > id(my_climate).target_temperature_low)
{
id(device_mode) = 1;
id(counter_sec) = 0;
};
}
if (id(device_mode) == 1 )
{
if (id(counter_sec) >= id(boiling_time))
{
id(device_mode) = 2;
id(relay_2).turn_off();
id(counter_sec) = 0;
auto call = id(my_climate).make_call();
call.set_target_temperature_low(id(waiting_temperature_low));
call.set_target_temperature_high(id(waiting_temperature_high));
call.perform();
}
}
font:
- file: "fonts/tahoma.ttf"
id: my_font
size: 26
- file: "fonts/tahoma.ttf"
id: my_font_s
size: 10
spi:
clk_pin: GPIO26
mosi_pin: GPIO25
display:
- platform: ST7920_spi
reset_pin: GPIO27
cs_pin: GPIO33
rotation: 180°
id: my_display
lambda: |-
if(id(display_menu) == 0)
{
it.printf(1, 0, id(my_font), "%02d:%02d", id(counter_sec) / 60 / 60, id(counter_sec) / 60 % 60);
if (id(device_mode) == 0 )
it.print(80, 3, id(my_font_s), "HEATING");
if (id(device_mode) == 1 )
it.print(80, 3, id(my_font_s), "BOILING");
if (id(device_mode) == 2 )
it.print(80, 3, id(my_font_s), "WAITING");
if (id(relay_1).state)
{
it.filled_rectangle(77, 16, 20, 9);
it.print(85, 14, id(my_font_s), COLOR_OFF, "1");
}
if (id(relay_2).state)
{
it.filled_rectangle(105, 16, 20, 9);
it.print(113, 14, id(my_font_s), COLOR_OFF, "2");
}
it.printf(1, 34, id(my_font), "%3.0f°C", id(temp_1).state);
it.print(90, 34, id(my_font_s), "Target:");
if (id(relay_1).state && id(device_mode) > 0)
it.printf(90, 52, id(my_font_s), "%3.0f°C", id(my_climate).target_temperature_high);
else
it.printf(90, 52, id(my_font_s), "%3.0f°C", id(my_climate).target_temperature_low);
}else /*----------------------- Выводим меню --------------------*/
{
if (id(display_menu) == 1)
{
it.rectangle(0, 1, 51, 11);
}
it.printf(50, 0, id(my_font_s), TextAlign::TOP_RIGHT, "EXIT-");
it.printf(50, 12, id(my_font_s), TextAlign::TOP_RIGHT, "BOILING:");
if (id(display_menu) == 2)
{
it.rectangle(50, 13, 31, 11);
it.printf(50, 12, id(my_font_s)," %3.0f°C", id(boiling_temperature_low));
} else if (id(display_menu) == 20)
{
it.filled_rectangle(50, 13, 31, 11);
it.printf(50, 12, id(my_font_s), COLOR_OFF, " %3.0f°C", id(boiling_temperature_low));
}else
{
it.printf(50, 12, id(my_font_s)," %3.0f°C", id(boiling_temperature_low));
}
if (id(display_menu) == 3)
{
it.rectangle(83, 13, 31, 11);
it.printf(83, 12, id(my_font_s), " %3.0f°C", id(boiling_temperature_high));
} else if (id(display_menu) == 30)
{
it.filled_rectangle(83, 13, 31, 11);
it.printf(83, 12, id(my_font_s), COLOR_OFF, " %3.0f°C", id(boiling_temperature_high));
} else
{
it.printf(83, 12, id(my_font_s)," %3.0f°C", id(boiling_temperature_high));
}
it.printf(50, 24, id(my_font_s), TextAlign::TOP_RIGHT, "TIME:");
if (id(display_menu) == 4)
{
it.rectangle(50, 25, 40, 11);
it.printf(50, 24, id(my_font_s), " %3d min", id(boiling_time) / 60);
} else if (id(display_menu) == 40)
{
it.filled_rectangle(50, 25, 40, 11);
it.printf(50, 24, id(my_font_s), COLOR_OFF," %3d min", id(boiling_time) / 60);
} else
{
it.printf(50, 24, id(my_font_s)," %3d min", id(boiling_time) / 60);
}
it.printf(50, 36, id(my_font_s), TextAlign::TOP_RIGHT, "WAITING:");
if (id(display_menu) == 5)
{
it.rectangle(50, 37, 31, 11);
it.printf(50, 36, id(my_font_s), " %3.0f°C", id(waiting_temperature_low));
} else if (id(display_menu) == 50)
{
it.filled_rectangle(50, 37, 31, 11);
it.printf(50, 36, id(my_font_s), COLOR_OFF, " %3.0f°C", id(waiting_temperature_low));
} else
{
it.printf(50, 36, id(my_font_s)," %3.0f°C", id(waiting_temperature_low));
}
if (id(display_menu) == 6)
{
it.rectangle(83, 37, 31, 11);
it.printf(83, 36, id(my_font_s), " %3.0f°C", id(waiting_temperature_high));
} else if (id(display_menu) == 60)
{
it.filled_rectangle(83, 37, 31, 11);
it.printf(83, 36, id(my_font_s), COLOR_OFF, " %3.0f°C", id(waiting_temperature_high));
} else
{
it.printf(83, 36, id(my_font_s)," %3.0f°C", id(waiting_temperature_high));
}
if (id(display_menu) == 7)
{
it.rectangle(0, 49, 51, 11);
it.printf(50, 48, id(my_font_s), TextAlign::TOP_RIGHT, "RESTART-");
}else
{
it.printf(50, 48, id(my_font_s), TextAlign::TOP_RIGHT, "RESTART-");
}
}
#dallas:
# - pin: GPIO32
# update_interval: 10s
# Individual sensors
sensor:
- platform: uptime
name: Uptime Sensor
update_interval: 5min
# - platform: dallas
# name: "Temperature #1"
# address: 0xB4041590482EFF28
# id: temp_2
- platform: adc
attenuation: 0db
pin: GPIO34
id: temp_1
update_interval: 5s
filters:
# - median:
# window_size: 6
# send_every: 3
# send_first_at: 2
- calibrate_linear:
# - 0.371 -> 0.40
# - 1.869 -> 1.6
- 0.150 -> 43.00
- 0.730 -> 136.0
on_value:
then:
- script.execute: check_mode
- component.update: my_display
- platform: rotary_encoder
name: "Rotary Encoder 1"
id: rotary_encoder1
pin_a: GPIO14
pin_b: GPIO13
min_value: 1
max_value: 7
on_value:
then:
- lambda: |-
switch(id(display_menu))
{
case 0:
break;
case 20:
id(boiling_temperature_low) = id(rotary_encoder1).state;
break;
case 30:
id(boiling_temperature_high) = id(rotary_encoder1).state;
break;
case 40:
id(boiling_time) = id(rotary_encoder1).state * 60;
break;
case 50:
id(waiting_temperature_low) = id(rotary_encoder1).state;
break;
case 60:
id(waiting_temperature_high) = id(rotary_encoder1).state;
break;
default:
id(display_menu) = id(rotary_encoder1).state;
break;
};
- component.update: my_display
switch:
- platform: gpio
pin:
number: GPIO16
inverted: true
id: relay_1
restore_mode: ALWAYS_OFF
- platform: gpio
pin:
number: GPIO17
inverted: true
id: relay_2
restore_mode: ALWAYS_OFF
- platform: gpio
pin:
number: GPIO18
inverted: true
id: relay_3
restore_mode: ALWAYS_OFF
- platform: gpio
pin:
number: GPIO15
inverted: false
id: ref_adc
restore_mode: ALWAYS_ON
interval:
- interval: 1s
then:
- lambda: 'id(counter_sec) += 1;'
climate:
- platform: bang_bang
name: "Bang Bang Climate Controller"
sensor: temp_1
default_target_temperature_low: 127 °C
default_target_temperature_high: 133 °C
id: my_climate
visual:
min_temperature: 20 °C
max_temperature: 140 °C
temperature_step: 1 °C
heat_action:
- switch.turn_on: relay_1
idle_action:
- switch.turn_off: relay_1