-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbasement-new.yaml
417 lines (373 loc) · 10.1 KB
/
basement-new.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
###################################################################
## WEMOS D1 ESP32 ##
## |GN| |RS| |#| | 1| tuart |GN| ##
## |NC| |36| ADC |#| | 3| ruart |27| ##
## |39| |26| SWpeltye |#| |22| scl |25| ##
## |35| |18| SWvent |#| |21| sda |32| ##
## |33| |19| SWopen |#| |17| Buzzer ! |12| ##
## |34| |23| SWclose |#| |16| BiWater | 4| ##
## |14| | 5| Buzzer |#| |GN| | 0| ##
## |NC| |3V| |#| |5V| | 2| ##
## | 9| |13| |#| |15| led | 8| ##
## |11| |10| |#| | 7| | 6| ##
###################################################################
substitutions:
name: basement
esphome:
name: "${name}"
on_boot:
then:
- switch.turn_on: close_vent
esp32:
board: wemos_d1_mini32
framework:
type: esp-idf
external_components:
- source: github://syssi/esphome-apc-ups@main
refresh: 0s
logger:
baud_rate: 0
# 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_password
power_save_mode: none
uart:
- id: uart_0
baud_rate: 2400
tx_pin: 1
rx_pin: 3
apc_ups:
- id: ups0
uart_id: uart_0
i2c:
sda: 21 #D2
scl: 22 #D1
scan: true
id: bus_a
# Creating a buzzer
output:
- platform: ledc
pin: 17 #D8
id: buzzer
# Creating a binary sensor
binary_sensor:
- platform: apc_ups
apc_ups_id: ups0
runtime_calibration:
name: "${name} runtime calibration"
smart_trim:
name: "${name} smart trim"
smart_boost:
name: "${name} smart boost"
on_line:
name: "${name} on line"
on_battery:
name: "${name} on battery"
output_overloaded:
name: "${name} output overloaded"
battery_low:
name: "${name} battery low"
replace_battery:
name: "${name} replace battery"
- platform: gpio
pin:
number: 16 #D4
mode: INPUT_PULLUP
inverted: True
name: "${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: analog_threshold
name: "${name} pump"
sensor_id: pump_current
device_class: power
threshold: 0.3
id: pump
on_press:
then:
- sensor.template.publish:
id: pump_on
state: !lambda 'return id(homeassistant_time).now().timestamp;'
on_release:
then:
- number.set:
id: counter
value: !lambda |-
return ((id(counter).state)+1);
- sensor.template.publish:
id: pump_off
state: !lambda 'return id(homeassistant_time).now().timestamp;'
number:
- platform: template
name: ${name} Counter
id: counter
update_interval: 30s
min_value: 0
max_value: 50
step: 0
optimistic: true
initial_value: 0
internal: true
button:
- platform: restart
name: "${name} Restart"
switch:
- platform: gpio
name: "${name} on-peltye"
id: cool
pin: 26 #D0
icon: "mdi:fridge"
on_turn_on:
- switch.turn_off: vent
- switch.turn_on: cool
- switch.turn_on: close_vent
on_turn_off:
- switch.turn_off: cool
- platform: gpio
name: "${name} on_vent"
id: vent
icon: "mdi:fan"
pin: 18 #D5
on_turn_on:
- switch.turn_off: cool
- switch.turn_on: open_vent
- switch.turn_on: vent
on_turn_off:
- switch.turn_on: close_vent
- switch.turn_off: vent
- platform: gpio
name: "${name} open_vent"
id: open_vent
icon: "mdi:valve-open"
pin: 19 #D6
on_turn_on:
- switch.turn_off: close_vent
- switch.turn_on: open_vent
- delay: 10s
- switch.turn_off: open_vent
on_turn_off:
- switch.turn_off: open_vent
- platform: gpio
name: "${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
on_turn_off:
- switch.turn_off: close_vent
- platform: gpio
pin:
number: 2 # internal
inverted: false
id: led1
# Creating a text sensor
text_sensor:
- platform: apc_ups
apc_ups_id: ups0
cause_of_last_transfer:
name: "${name} cause of last transfer"
protocol_info:
name: "${name} protocol info"
firmware_revision:
name: "${name} firmware revision"
- platform: wifi_info
ip_address:
name: ${name} IP Address
icon: mdi:ip
ssid:
name: ${name} SSID
icon: mdi:access-point-network
mac_address:
name: ${name} Mac
icon: mdi:lan
# Creating a sensor
sensor:
- platform: apc_ups
apc_ups_id: ups0
battery_voltage:
name: "${name} battery voltage"
grid_frequency:
name: "${name} grid frequency"
grid_voltage:
name: "${name} grid voltage"
ac_output_voltage:
name: "${name} ac output voltage"
ac_output_load:
name: "${name} ac output load"
status_bitmask:
name: "${name} status bitmask"
state_of_charge:
name: "${name} state of charge"
estimated_runtime:
name: "${name} estimated runtime"
- platform: internal_temperature
name: "${name} ESP32 T"
- platform: wifi_signal
name: "${name} Wifi"
update_interval: 60s
id: wifi_signal_db
entity_category: "diagnostic"
- platform: copy # Reports the WiFi signal strength in %
source_id: wifi_signal_db
name: "${name} WiFi Percent"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: "diagnostic"
- platform: esp32_hall
name: "${name} hall Sensor"
update_interval: 60s
- platform: aht10
temperature:
name: "${name} outdor_T"
id: t_outdor
humidity:
name: "${name} outdor_%"
id: h_outdor
update_interval: 60s
address: 0x38
i2c_id: bus_a
- platform: absolute_humidity
name: "${name} Absolute Humidity outdor"
temperature: t_outdor
humidity: h_outdor
- platform: aht10
temperature:
name: "${name} holod_T"
id: t_indor
humidity:
name: "${name} holod_%"
id: h_indor
update_interval: 60s
address: 0x39
i2c_id: bus_a
- platform: absolute_humidity
name: "${name} Absolute Humidity"
temperature: t_indor
humidity: h_indor
- platform: adc
pin: 36
id: adc_sensor
- platform: ct_clamp
sensor: adc_sensor
name: "pump current"
id: pump_current
update_interval: 5s
- platform: template
name: "time pump off"
device_class: timestamp
id: pump_off
update_interval: never
- platform: template
name: "time pump on"
device_class: timestamp
id: pump_on
update_interval: never
- platform: template
name: "time working pump"
device_class: duration
lambda: |-
return (( id(pump_off).state - id(pump_on).state ));
- platform: template
name: "pump working"
lambda: |-
return id(counter).state;
accuracy_decimals: 0
icon: mdi:counter
# 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: "${name} Холодильник"
sensor: t_indor
cool_action:
- if:
condition:
lambda: return (id(t_indor).state - id(t_outdor).state) > 3;
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
display:
- platform: lcd_pcf8574
dimensions: 16x2
address: 0x27
i2c_id: bus_a
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);
}
time:
- platform: sntp
id: homeassistant_time
timezone: Europe/Moscow #"MSK-2MSD,M3.5.0/2,M10.5.0/3"
servers: !secret sntp
on_time:
- hours: 00
then:
- number.set:
id: counter
value: 0
web_server:
port: 80
auth:
username: !secret web_user
password: !secret web_pass