-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbasement-controller.yaml
417 lines (359 loc) · 9 KB
/
basement-controller.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
substitutions:
devicename: cool-d1
upper_devicename: cool-d1
esphome:
name: "${devicename}"
platform: esp32
board: wemos_d1_mini32
# platformio_options:
# lib_deps:
# - ssilver2007/LCD_1602_RUS
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret api_pass
# Enabling air loading
ota:
password: !secret ota_pass
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pass
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${devicename} Fallback"
password: !secret back_pass
captive_portal:
i2c:
sda: 21 #D2
scl: 22 #D1
scan: true
# Font
# Imidge
image:
- file: "picture/valve-closed.png"
id: iclosed
resize: 16x16
- file: "picture/valve-open.png"
id: iopen
resize: 16x16
- file: "picture/fridge.png"
id: ifridge
resize: 16x16
- file: "picture/fan.png"
id: ifan
resize: 16x16
- file: "picture/water-alert.png"
id: iwater
resize: 16x16
- file: "picture/water-pump.png"
id: ipump
resize: 16x16
# Creating a buzzer
output:
- platform: ledc
pin: 17 #D8
id: buzzer
# Creating a binary sensor
binary_sensor:
- platform: template
lambda: |-
if ((id(t_indor).state - id(t_outdor).state) > 5) {
return true;
} else {
return false;
}
name: "raznica"
id: raznica
device_class: cold
on_state:
then:
- climate.control:
id: Holodilnik
mode: "OFF"
- climate.control:
id: Holodilnik
mode: "COOL"
- platform: gpio
pin:
number: 16 #D4
mode: INPUT_PULLUP
inverted: True
name: "Water!"
device_class: moisture
id: water
on_press:
then:
- output.turn_on: buzzer
- switch.turn_on: led1
on_release:
then:
- switch.turn_off: led1
- output.turn_off: buzzer
- platform: template
lambda: |-
if (id(pump_current).state > 1) {
return true;
} else {
return false;
}
name: "Pump"
id: pump
# Creating a switch
switch:
- platform: gpio
name: on-peltye
id: cool
pin: 18 #D5
icon: "mdi:fridge"
on_turn_on:
- switch.turn_off: vent
- switch.turn_on: cool
on_turn_off:
- switch.turn_off: cool
- platform: gpio
name: on_vent
id: vent
icon: "mdi:fan"
pin: 19 #D6
on_turn_on:
- switch.turn_off: cool
- switch.turn_on: open_vent
- switch.turn_on: vent
on_turn_off:
- switch.turn_off: vent
- switch.turn_on: close_vent
- platform: gpio
name: open_vent
id: open_vent
icon: "mdi:valve-open"
pin: 26 #D0
on_turn_on:
- switch.turn_off: close_vent
- switch.turn_on: open_vent
- delay: 10s
- switch.turn_off: open_vent
- platform: gpio
name: close_vent
id: close_vent
icon: "mdi:valve-closed"
pin: 23 #D7
on_turn_on:
- switch.turn_off: open_vent
- switch.turn_on: close_vent
- delay: 10s
- switch.turn_off: close_vent
- platform: gpio
pin:
number: 2 # internal
inverted: false
id: led1
# Creating a text sensor
text_sensor:
- platform: wifi_info
ip_address:
name: ${upper_devicename} IP Address
ssid:
name: ${upper_devicename} SSID
mac_address:
name: ${upper_devicename} Mac
# Creating a sensor
sensor:
- platform: wifi_signal
name: ${upper_devicename} Wifi
update_interval: 60s
- platform: esp32_hall
name: "Hall Sensor"
update_interval: 60s
- platform: bmp280
temperature:
name: "Holod_T_R"
id: bmp280_temperature
oversampling: 16x
pressure:
name: "Holod_Pressure"
id: bmp280_pressure
address: 0x77
update_interval: 60s
- platform: aht10
temperature:
name: "Holod_T"
id: t_indor
humidity:
name: "Holod_%"
id: H_humidity
update_interval: 60s
address: 0x38
- platform: aht10
temperature:
name: "Outdor_T"
id: t_outdor
humidity:
name: "Outdor_%"
id: h_outdor
update_interval: 60s
address: 0x39
- platform: adc
pin: SVP # A0 #36
name: pump current
id: pump_current
filters:
- lambda: return x - 0.5;
- max:
window_size: 4
send_every: 500
update_interval: 10 ms
unit_of_measurement: 'A'
device_class: current
- platform: template
name: "Altitude"
lambda: |-
const float STANDARD_SEA_LEVEL_PRESSURE = 1013.25; //in hPa, see note
return ((id(t_outdor).state + 273.15) / 0.0065) *
(powf((STANDARD_SEA_LEVEL_PRESSURE / id(bmp280_pressure).state), 0.190234) - 1); // in meter
update_interval: 15s
icon: 'mdi:signal'
unit_of_measurement: 'm'
- platform: template
name: "Absolute Humidity"
lambda: |-
const float mw = 18.01534; // molar mass of water g/mol
const float r = 8.31447215; // Universal gas constant J/mol/K
return (6.112 * powf(2.718281828, (17.67 * id(t_outdor).state) /
(id(t_outdor).state + 243.5)) * id(h_outdor).state * mw) /
((273.15 + id(t_outdor).state) * r); // in grams/m^3
accuracy_decimals: 2
update_interval: 15s
icon: 'mdi:water'
unit_of_measurement: 'g/m³'
- platform: template
name: "Dew Point"
lambda: |-
return (243.5*(log(id(h_outdor).state/100)+((17.67*id(t_outdor).state)/
(243.5+id(t_outdor).state)))/(17.67-log(id(h_outdor).state/100)-
((17.67*id(t_outdor).state)/(243.5+id(t_outdor).state))));
unit_of_measurement: °C
icon: 'mdi:thermometer-alert'
- platform: template
name: "Equivalent sea level pressure"
lambda: |-
const float STANDARD_ALTITUDE = 0.6; // in meters, see note
return id(bmp280_pressure_m).state / powf(1 - ((0.0065 * STANDARD_ALTITUDE) /
(id(t_outdor).state + (0.0065 * STANDARD_ALTITUDE) + 273.15)), 5.257); // in mmHg
update_interval: 15s
unit_of_measurement: 'mmHg'
- platform: template
name: "mm gh"
id: bmp280_pressure_m
lambda: |-
return id(bmp280_pressure).state * 0.750063;
update_interval: 15s
unit_of_measurement: 'mmHg'
icon: 'mdi:gauge'
# Creating a thermostat
climate:
- platform: thermostat
id: Holodilnik
min_cooling_off_time: 5s
min_cooling_run_time: 5s
min_idle_time: 5s
visual:
min_temperature: 5 °C
max_temperature: 9 °C
temperature_step: 0.5 °C
name: "Холодильник"
sensor: t_indor
default_target_temperature_high: 7 C
cool_action:
- if:
condition:
lambda: return (id(t_indor).state - id(t_outdor).state) > 5;
then:
- switch.turn_on: vent
else:
- switch.turn_on: cool
idle_action:
- switch.turn_off: vent
- switch.turn_off: cool
off_mode:
- switch.turn_off: vent
- switch.turn_off: cool
#Prin to display
display:
- platform: ssd1306_i2c
model: "SH1106 128x32"
reset_pin: 14
address: 0x3C
lambda: |-
// Print time in HH:MM format
it.strftime(2, 0, id(font3),"%H:%M",id(homeassistant_time).now());
if (id(cool).state) {
it.image(110, 0, id(ifridge));
}
if (id(vent).state) {
it.image(110, 16, id(ifan));
}
if (id(open_vent).state) {
it.image(96, 16, id(iopen));
}
if (id(close_vent).state) {
it.image(96, 0, id(iclosed));
}
if (id(water).state) {
it.image(0, 16, id(iwater));
}
if (id(pump).state) {
it.image(16, 16, id(ipump));
}
if (id(t_indor).state) {
it.printf(40, 0, id(font3) , "TH %.1f", id(t_indor).state);
}
if (id(t_outdor).state) {
it.printf(40, 13, id(font3) , "TU %.1f", id(t_outdor).state);
}
- platform: lcd_pcf8574
dimensions: 16x2
address: 0x27
lambda: |-
static int i = 0;
i++;
if ((i % 2) == 0)
it.strftime("%H:%M", id(homeassistant_time).now());
else
it.strftime("%H %M", id(homeassistant_time).now());
if (id(cool).state) {
it.print(0, 1, "Cool");
}
if (id(vent).state) {
it.print(0, 1, "Vent");
}
if (id(open_vent).state) {
it.print(5, 1, "VOpen");
}
if (id(close_vent).state) {
it.print(5, 1, "VClos");
}
if (id(water).state) {
it.print(11, 1, "W!");
}
if (id(pump).state) {
it.print(14, 1, "P!");
}
if (id(t_indor).state) {
it.printf(6, 0, "%.1f", id(t_indor).state);
}
if (id(t_outdor).state) {
it.printf(11, 0, " %.1f", id(t_outdor).state);
}
# Enable Web server.
web_server:
port: 80
auth:
username: !secret web_user
password: !secret web_pass
# Sync time with Home Assistant.
time:
- platform: sntp
id: homeassistant_time
timezone: "MSK-3MSD,M3.5.0/2,M10.5.0/3"
servers: 192.168.XX.XX