generated from esphome/esphome-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
power-manager-8c-esp8266-d1-mini.yaml
543 lines (480 loc) · 15.3 KB
/
power-manager-8c-esp8266-d1-mini.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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
# These substitutions allow the end user to override certain values
substitutions:
name: "power-manager"
# Modify variables if you use multiple boards
hostname: 'PM'
# Modify variables based on your circuit, like "breaker 01" or "dryer"
ct_clamp_00: 'A0'
ct_clamp_01: 'A1'
ct_clamp_02: 'A2'
ct_clamp_03: 'A3'
ct_clamp_04: 'A4'
ct_clamp_05: 'A5'
ct_clamp_06: 'A6'
ct_clamp_07: 'A7'
# Modify variable based on your language
adc_sensor: 'ADC Sensor'
measured_current: 'Measured Current'
measured_power: 'Measured Power'
measured_total_power_daily: 'Measured Total/Daily'
esphome:
name: "${name}"
# Automatically add the mac address to the name
# so you can use a single firmware for all devices
name_add_mac_suffix: true
# This will allow for (future) project identification,
# configuration and updates.
project:
name: esphome.power-manager
version: "6.4.1"
esp8266:
board: d1_mini
# To be able to get logs from the device via serial and api.
logger:
# API is a requirement of the dashboard import.
api:
# OTA is required for Over-the-Air updating
ota:
# This should point to the public location of this yaml file.
dashboard_import:
package_import_url: github://djiesr/JLNTR2K4-power-manager/power-manager-8c-esp32-d1-mini.yaml@main
wifi:
# Set up a wifi access point using the device name above
ap:
password: "12345678"
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device.
captive_portal:
# Sets up the improv via serial client for Wi-Fi provisioning.
# Handy if your device has a usb port for the user to add credentials when they first get it.
improv_serial:
##########################################################
web_server:
port: 80
text_sensor:
- platform: wifi_info
ip_address:
name: $hostname ESP IP Address
id: ip_now
ssid:
name: $hostname ESP Connected SSID
bssid:
name: $hostname ESP Connected BSSID
mac_address:
name: $hostname ESP Mac Wifi Address
scan_results:
name: $hostname ESP Latest Scan Results
i2c:
sda: D2
scl: D1
scan: false
interval:
- interval: 5s
then:
- display.page.show_next: ic2_screen
- component.update: ic2_screen
display:
- platform: ssd1306_i2c
id: ic2_screen
model: "SSD1306 128x64"
reset_pin: D0
address: 0x3C
pages:
- id: page1
lambda: |-
it.printf(10, 0, id(font_times), "Power Manager");
it.printf(10, 15, id(font_times), "JLNTR2k4 2022.4");
# it.printf(10, 30, id(font_times), "Main: %.1f kW", id(power_total).state);
# it.printf(10, 45, id(font_times), "IP: %s", id(ip_now).state.c_str());
- id: page2
lambda: |-
it.printf(10, 0, id(font_times), "Get A0: %.3f V", id(adc_sensor_a0).state);
it.printf(10, 15, id(font_times), "A0: %.2f Amp", id(measured_current_a0).state);
it.printf(10, 30, id(font_times), "Power %.3f kW", id(power_a0).state);
it.printf(10, 45, id(font_times), "Total %.3f kW", id(tde_a0).state);
- id: page3
lambda: |-
it.printf(10, 0, id(font_times), "Get A1: %.3f V", id(adc_sensor_a1).state);
it.printf(10, 15, id(font_times), "A1: %.2f Amp", id(measured_current_a1).state);
it.printf(10, 30, id(font_times), "Power %.3f kW", id(power_a1).state);
it.printf(10, 45, id(font_times), "Total %.3f kW", id(tde_a1).state);
- id: page4
lambda: |-
it.printf(10, 0, id(font_times), "Get A2: %.3f V", id(adc_sensor_a2).state);
it.printf(10, 15, id(font_times), "A2: %.2f Amp", id(measured_current_a2).state);
it.printf(10, 30, id(font_times), "Power %.3f kW", id(power_a2).state);
it.printf(10, 45, id(font_times), "Total %.3f kW", id(tde_a2).state);
- id: page5
lambda: |-
it.printf(10, 0, id(font_times), "Get A3: %.3f V", id(adc_sensor_a3).state);
it.printf(10, 15, id(font_times), "A3: %.2f Amp", id(measured_current_a3).state);
it.printf(10, 30, id(font_times), "Power %.3f kW", id(power_a3).state);
it.printf(10, 45, id(font_times), "Total %.3f kW", id(tde_a3).state);
- id: page6
lambda: |-
it.printf(10, 0, id(font_times), "Get A4: %.3f V", id(adc_sensor_a4).state);
it.printf(10, 15, id(font_times), "A4: %.2f Amp", id(measured_current_a4).state);
it.printf(10, 30, id(font_times), "Power %.3f kW", id(power_a4).state);
it.printf(10, 45, id(font_times), "Total %.3f kW", id(tde_a4).state);
- id: page7
lambda: |-
it.printf(10, 0, id(font_times), "Get A5: %.3f V", id(adc_sensor_a5).state);
it.printf(10, 15, id(font_times), "A5: %.2f Amp", id(measured_current_a5).state);
it.printf(10, 30, id(font_times), "Power %.3f kW", id(power_a5).state);
it.printf(10, 45, id(font_times), "Total %.3f kW", id(tde_a5).state);
- id: page8
lambda: |-
it.printf(10, 0, id(font_times), "Get A6: %.3f V", id(adc_sensor_a6).state);
it.printf(10, 15, id(font_times), "A6: %.2f Amp", id(measured_current_a6).state);
it.printf(10, 30, id(font_times), "Power %.3f kW", id(power_a6).state);
it.printf(10, 45, id(font_times), "Total %.3f kW", id(tde_a6).state);
- id: page9
lambda: |-
it.printf(10, 0, id(font_times), "Get A7: %.3f V", id(adc_sensor_a7).state);
it.printf(10, 15, id(font_times), "A7: %.2f Amp", id(measured_current_a7).state);
it.printf(10, 30, id(font_times), "Power %.3f kW", id(power_a7).state);
it.printf(10, 45, id(font_times), "Total %.3f kW", id(tde_a7).state);
font:
- file: "fonts/times.ttf"
id: font_times
size: 16
spi:
clk_pin: D5
mosi_pin: D7
miso_pin: D6
mcp3008:
cs_pin: D8
id: main_board
sensor:
- platform: mcp3008 # Attached to pin 0 of the MCP3008.
update_interval: 10s
mcp3008_id: main_board
id: adc_sensor_a0
number: 0
name: $hostname $adc_sensor $ct_clamp_00
accuracy_decimals: 3
internal: true
filters:
- lambda: return x;
- platform: mcp3008 # Attached to pin 0 of the MCP3008.
update_interval: 10s
mcp3008_id: main_board
id: adc_sensor_a1
number: 1
name: $hostname $adc_sensor $ct_clamp_01
accuracy_decimals: 3
internal: true
filters:
- lambda: return x;
- platform: mcp3008 # Attached to pin 0 of the MCP3008.
update_interval: 10s
mcp3008_id: main_board
id: adc_sensor_a2
number: 2
name: $hostname $adc_sensor $ct_clamp_02
accuracy_decimals: 3
internal: true
filters:
- lambda: return x;
- platform: mcp3008 # Attached to pin 0 of the MCP3008.
update_interval: 10s
mcp3008_id: main_board
id: adc_sensor_a3
number: 3
name: $hostname $adc_sensor $ct_clamp_03
accuracy_decimals: 3
internal: true
filters:
- lambda: return x;
- platform: mcp3008 # Attached to pin 0 of the MCP3008.
update_interval: 10s
mcp3008_id: main_board
id: adc_sensor_a4
number: 4
name: $hostname $adc_sensor $ct_clamp_04
accuracy_decimals: 3
internal: true
filters:
- lambda: return x;
- platform: mcp3008 # Attached to pin 0 of the MCP3008.
update_interval: 10s
mcp3008_id: main_board
id: adc_sensor_a5
number: 5
name: $hostname $adc_sensor $ct_clamp_05
accuracy_decimals: 3
internal: true
filters:
- lambda: return x;
- platform: mcp3008 # Attached to pin 0 of the MCP3008.
update_interval: 10s
mcp3008_id: main_board
id: adc_sensor_a6
number: 6
name: $hostname $adc_sensor $ct_clamp_06
accuracy_decimals: 3
internal: true
filters:
- lambda: return x;
- platform: mcp3008 # Attached to pin 0 of the MCP3008.
update_interval: 10s
mcp3008_id: main_board
id: adc_sensor_a7
number: 7
name: $hostname $adc_sensor $ct_clamp_07
accuracy_decimals: 3
internal: true
filters:
- lambda: return x;
########################################################## CT Clamp #########################################################
- platform: ct_clamp
sensor: adc_sensor_a0
name: $hostname $measured_current $ct_clamp_00
update_interval: 15s
id: measured_current_a0
accuracy_decimals: 3
filters:
- calibrate_linear:
- 0.003 -> 0
- 0.5 -> 100
- platform: ct_clamp
sensor: adc_sensor_a1
name: $hostname $measured_current $ct_clamp_01
update_interval: 15s
id: measured_current_a1
accuracy_decimals: 3
filters:
- calibrate_linear:
- 0.003 -> 0
- 1.000 -> 30
- platform: ct_clamp
sensor: adc_sensor_a2
name: $hostname $measured_current $ct_clamp_02
update_interval: 15s
id: measured_current_a2
accuracy_decimals: 3
filters:
- calibrate_linear:
- 0.003 -> 0
- 1.000 -> 30
- platform: ct_clamp
sensor: adc_sensor_a3
name: $hostname $measured_current $ct_clamp_03
update_interval: 15s
id: measured_current_a3
accuracy_decimals: 3
filters:
- calibrate_linear:
- 0.003 -> 0
- 1.000 -> 30
- platform: ct_clamp
sensor: adc_sensor_a4
name: $hostname $measured_current $ct_clamp_04
update_interval: 15s
id: measured_current_a4
accuracy_decimals: 3
filters:
- calibrate_linear:
- 0.003 -> 0
- 1.000 -> 30
- platform: ct_clamp
sensor: adc_sensor_a5
name: $hostname $measured_current $ct_clamp_05
update_interval: 15s
id: measured_current_a5
accuracy_decimals: 3
filters:
- calibrate_linear:
- 0.003 -> 0
- 1.000 -> 30
- platform: ct_clamp
sensor: adc_sensor_a6
name: $hostname $measured_current $ct_clamp_06
update_interval: 15s
id: measured_current_a6
accuracy_decimals: 3
filters:
- calibrate_linear:
- 0.003 -> 0
- 1.000 -> 30
- platform: ct_clamp
sensor: adc_sensor_a7
name: $hostname $measured_current $ct_clamp_07
update_interval: 15s
id: measured_current_a7
accuracy_decimals: 3
filters:
- calibrate_linear:
- 0.003 -> 0
- 0.5 -> 100
########################################################## Power total house ##########################################################
# - platform: template
# id: power_total
# name: "Énergie mesurée"
# lambda: return ((id(measured_current_a0).state + id(measured_current_a7).state) * 120 / 1000); #Power = V*I/1000. So change 230V to whatever your mains voltage is)
# unit_of_measurement: 'kW'
# device_class: power
# accuracy_decimals: 3
# update_interval: 10s
# - platform: total_daily_energy
# name: "Énergie totale de la maison"
# device_class: energy
# accuracy_decimals: 2
# power_id: power_total
# restore: true
##############################################################################################################################################
- platform: template
id: power_a0
name: $hostname $measured_power $ct_clamp_00
unit_of_measurement: 'kW'
device_class: power
update_interval: 15s
accuracy_decimals: 3
lambda: |-
if (id(measured_current_a0).state > 0.03){
return (id(measured_current_a0).state * 120 / 1000);
} else {
return 0.0;
}
- platform: total_daily_energy
name: $hostname $measured_total_power_daily $ct_clamp_00
device_class: energy
power_id: power_a0
restore: true
id: tde_a0
- platform: template
id: power_a1
name: $hostname $measured_power $ct_clamp_01
unit_of_measurement: 'kW'
device_class: power
update_interval: 15s
accuracy_decimals: 3
lambda: |-
if (id(measured_current_a1).state > 0.03){
return (id(measured_current_a1).state * 120 / 1000);
} else {
return 0.0;
}
- platform: total_daily_energy
name: $hostname $measured_total_power_daily $ct_clamp_01
device_class: energy
power_id: power_a1
restore: true
id: tde_a1
- platform: template
id: power_a2
name: $hostname $measured_power $ct_clamp_02
unit_of_measurement: 'kW'
device_class: power
update_interval: 15s
accuracy_decimals: 3
lambda: |-
if (id(measured_current_a2).state > 0.03){
return (id(measured_current_a2).state * 120 / 1000);
} else {
return 0.0;
}
- platform: total_daily_energy
name: $hostname $measured_total_power_daily $ct_clamp_02
device_class: energy
power_id: power_a2
restore: true
id: tde_a2
- platform: template
id: power_a3
name: $hostname $measured_power $ct_clamp_03
unit_of_measurement: 'kW'
device_class: power
update_interval: 15s
accuracy_decimals: 3
lambda: |-
if (id(measured_current_a3).state > 0.03){
return (id(measured_current_a3).state * 120 / 1000);
} else {
return 0.0;
}
- platform: total_daily_energy
name: $hostname $measured_total_power_daily $ct_clamp_03
device_class: energy
power_id: power_a3
restore: true
id: tde_a3
- platform: template
id: power_a4
name: $hostname $measured_power $ct_clamp_04
unit_of_measurement: 'kW'
device_class: power
update_interval: 15s
accuracy_decimals: 3
lambda: |-
if (id(measured_current_a4).state > 0.03){
return (id(measured_current_a4).state * 120 / 1000);
} else {
return 0.0;
}
- platform: total_daily_energy
name: $hostname $measured_total_power_daily $ct_clamp_04
device_class: energy
power_id: power_a4
restore: true
id: tde_a4
- platform: template
id: power_a5
name: $hostname $measured_power $ct_clamp_05
unit_of_measurement: 'kW'
device_class: power
update_interval: 15s
accuracy_decimals: 3
lambda: |-
if (id(measured_current_a5).state > 0.03){
return (id(measured_current_a5).state * 120 / 1000);
} else {
return 0.0;
}
- platform: total_daily_energy
name: $hostname $measured_total_power_daily $ct_clamp_05
device_class: energy
power_id: power_a5
restore: true
id: tde_a5
- platform: template
id: power_a6
name: $hostname $measured_power $ct_clamp_06
unit_of_measurement: 'kW'
device_class: power
update_interval: 15s
accuracy_decimals: 3
lambda: |-
if (id(measured_current_a6).state > 0.03){
return (id(measured_current_a6).state * 120 / 1000);
} else {
return 0.0;
}
- platform: total_daily_energy
name: $hostname $measured_total_power_daily $ct_clamp_06
device_class: energy
power_id: power_a6
restore: true
id: tde_a6
- platform: template
id: power_a7
name: $hostname $measured_power $ct_clamp_07
unit_of_measurement: 'kW'
device_class: power
update_interval: 15s
accuracy_decimals: 3
lambda: |-
if (id(measured_current_a7).state > 0.03){
return (id(measured_current_a7).state * 120 / 1000);
} else {
return 0.0;
}
- platform: total_daily_energy
name: $hostname $measured_total_power_daily $ct_clamp_07
device_class: power
power_id: power_a7
restore: true
id: tde_a7
time:
- platform: sntp
id: my_time