-
Notifications
You must be signed in to change notification settings - Fork 1
/
growatt-esp32.yaml
527 lines (480 loc) · 13.1 KB
/
growatt-esp32.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
substitutions:
name: growatt
device_name: growatt #name for all sensors in Home assistant
device_description: "Esphome for growatt"
modbus_controller_id: controller1
modbus_update_interval: 15s #normal update
skip_updates_slow: "6" #how many times to skip normal update for slow updating sensors
update_fast: 15s
update_slow: 60s
esphome:
name: ${name}
esp32:
board: esp32dev
logger:
api: #Enable Home Assistant Api
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: ${name}
captive_portal:
web_server:
port: 80
uart:
id: mod_bus
tx_pin: 17
rx_pin: 16
baud_rate: 9600
stop_bits: 1
modbus:
id: modbus1
# flow_control_pin: 4 #for use when you use a rs485 board without auto flow control. Like the rs485 max board.
modbus_controller:
- id: ${modbus_controller_id}
address: 0x1
modbus_id: modbus1
setup_priority: -10
update_interval: ${modbus_update_interval}
sensor:
- platform: modbus_controller
name: ${device_name} status_code
skip_updates: $skip_updates_slow
address: 0
register_type: "read"
internal: true
accuracy_decimals: 0
id: status
- platform: modbus_controller
name: "${device_name} Input Power"
address: 1
register_type: "read"
unit_of_measurement: W
device_class: power
state_class: measurement
icon: mdi:solar-power-variant
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} PV1 voltage"
address: 3
register_type: "read"
unit_of_measurement: V
device_class: voltage
icon: mdi:flash
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} PV1 current"
address: 4
register_type: "read"
unit_of_measurement: A
device_class: current
icon: mdi:flash
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} PV1 power"
id: pv1_power
address: 5
register_type: "read"
unit_of_measurement: W
device_class: power
icon: mdi:flash
value_type: U_DWORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} PV2 voltage"
address: 7
register_type: "read"
unit_of_measurement: V
device_class: voltage
icon: mdi:flash
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} PV2 current"
address: 8
register_type: "read"
unit_of_measurement: A
device_class: current
icon: mdi:flash
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} PV2 power"
id: pv2_power
address: 9
register_type: "read"
unit_of_measurement: W
device_class: power
icon: mdi:flash
value_type: U_DWORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: template
id: pv_power
name: "${device_name} PV Power"
unit_of_measurement: W
device_class: power
state_class: measurement
icon: mdi:solar-power-variant
accuracy_decimals: 0
lambda: |-
return float((id(pv1_power).state + id(pv2_power).state));
update_interval: ${update_fast}
- platform: modbus_controller
name: "${device_name} Output power"
address: 35
register_type: "read"
unit_of_measurement: W
device_class: power
icon: mdi:solar-power
value_type: U_DWORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} Energy total"
skip_updates: $skip_updates_slow
address: 55
register_type: "read"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
icon: mdi:solar-power
value_type: U_DWORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} PV1 energy total"
skip_updates: $skip_updates_slow
id: pv1_energy_total
address: 61
register_type: "read"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
icon: mdi:solar-power
value_type: U_DWORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} PV2 energy total"
skip_updates: $skip_updates_slow
id: pv2_energy_total
address: 65
register_type: "read"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
icon: mdi:solar-power
value_type: U_DWORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: template
id: pv_energy_total
name: "${device_name} PV Energy Total"
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
icon: mdi:solar-power-variant
accuracy_decimals: 1
lambda: |-
return float((id(pv1_energy_total).state + id(pv2_energy_total).state));
update_interval: ${update_slow}
- platform: modbus_controller
name: "${device_name} Temperature"
address: 93
register_type: "read"
unit_of_measurement: °C
device_class: temperature
entity_category: diagnostic
icon: mdi:thermometer
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
skip_updates: $skip_updates_slow
- platform: modbus_controller
name: "${device_name} Battery Discharging Power"
address: 1009
register_type: "read"
unit_of_measurement: W
device_class: power
icon: mdi:battery-arrow-down
value_type: U_DWORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} Battery Charging Power"
address: 1011
register_type: "read"
unit_of_measurement: W
device_class: power
icon: mdi:battery-arrow-up-outline
value_type: U_DWORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} Battery SoC"
skip_updates: $skip_updates_slow
address: 1014
register_type: "read"
unit_of_measurement: "%"
icon: mdi:home-battery
value_type: U_WORD
accuracy_decimals: 0
- platform: modbus_controller
name: "${device_name} AC Power to User Total"
address: 1021
register_type: "read"
unit_of_measurement: W
device_class: power
state_class: measurement
icon: mdi:transmission-tower-export
value_type: U_DWORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} AC Power to Grid Total"
address: 1029
register_type: "read"
unit_of_measurement: W
device_class: power
state_class: measurement
icon: mdi:transmission-tower-import
value_type: U_DWORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} INV Power to Local Load Total"
address: 1037
register_type: "read"
unit_of_measurement: W
device_class: power
state_class: measurement
icon: mdi:home-import-outline
value_type: U_DWORD
accuracy_decimals: 0
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} Battery Temperature"
address: 1040
register_type: "read"
unit_of_measurement: °C
device_class: temperature
state_class: measurement
icon: mdi:thermometer
skip_updates: $skip_updates_slow
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} Battery State"
skip_updates: $skip_updates_slow
address: 1041
register_type: "read"
icon: mdi:home-battery
value_type: U_WORD
- platform: modbus_controller
name: "${device_name} Energy to User Total"
skip_updates: $skip_updates_slow
address: 1046
register_type: "read"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
icon: mdi:transmission-tower-export
value_type: U_DWORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} Energy to Grid Total"
skip_updates: $skip_updates_slow
address: 1050
register_type: "read"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
icon: mdi:transmission-tower-import
value_type: U_DWORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} Battery Discharge Total"
skip_updates: $skip_updates_slow
address: 1054
register_type: "read"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
icon: mdi:battery-arrow-down
value_type: U_DWORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} Battery Charge Total"
skip_updates: $skip_updates_slow
address: 1058
register_type: "read"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
icon: mdi:battery-arrow-up-outline
value_type: U_DWORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: "${device_name} Local Load Total"
skip_updates: $skip_updates_slow
address: 1062
register_type: "read"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
icon: mdi:home-import-outline
value_type: U_DWORD
accuracy_decimals: 1
filters:
- multiply: 0.1
number:
- platform: modbus_controller
name: "${device_name} Discharge SoC"
address: 1071
value_type: U_WORD
min_value: 10
max_value: 100
step: 1
skip_updates: $skip_updates_slow
- platform: modbus_controller
name: "${device_name} Discharge Power Rate"
address: 1070
value_type: U_WORD
min_value: 10
max_value: 100
step: 1
skip_updates: $skip_updates_slow
- platform: modbus_controller
name: "${device_name} Charge SoC"
address: 1091
value_type: U_WORD
min_value: 10
max_value: 100
step: 1
skip_updates: $skip_updates_slow
- platform: modbus_controller
name: "${device_name} Charge Power Rate"
address: 1090
value_type: U_WORD
min_value: 10
max_value: 100
step: 1
skip_updates: $skip_updates_slow
select:
- platform: modbus_controller
name: "${device_name} AC Charging"
icon: mdi:battery-charging-100
address: 1092
value_type: U_WORD
optionsmap:
"Disabled": 0
"Enabled": 1
skip_updates: $skip_updates_slow
- platform: modbus_controller
name: "${device_name} Inverter Priority"
icon: mdi:arrow-decision-outline
address: 1044
value_type: U_WORD
optionsmap:
"Load First": 0
"Battery First": 1
"Grid First": 2
skip_updates: $skip_updates_slow
text_sensor:
- platform: template
name: "${device_name} Status state"
icon: mdi:eye
entity_category: diagnostic
lambda: |-
if ((id(status).state) == 1) {
return {"Normal"};
} else if ((id(status).state) == 0) {
return {"Standby"};
} else if ((id(status).state) == 2) {
return {"Discharge"};
} else if ((id(status).state) == 3) {
return {"Fault"};
} else if ((id(status).state) == 4) {
return {"Flash"};
} else if ((id(status).state) == 5) {
return {"PV Charging"};
} else if ((id(status).state) == 6) {
return {"AC Charging"};
} else if ((id(status).state) == 7) {
return {"Combined Charging"};
} else if ((id(status).state) == 8) {
return {"Combined Charging & Bypass"};
} else if ((id(status).state) == 9) {
return {"PV Charging & Bypass"};
} else if ((id(status).state) == 10) {
return {"AC Charging & Bypass"};
} else if ((id(status).state) == 11) {
return {"Bypass"};
} else if (id(status).state == 12) {
return {"PV Charge and Discharge"};
} else {
return {"Unknown"};
}
- platform: modbus_controller
name: "${device_name} Fault code"
skip_updates: $skip_updates_slow
address: 105
register_type: "read"
icon: mdi:eye
entity_category: diagnostic
raw_encode: HEXBYTES
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("No error");
case 24: return std::string("Auto test failed");
case 25: return std::string("No AC connection");
case 26: return std::string("PV isolation low");
case 27: return std::string("Residual I high");
case 28: return std::string("Output high DCI");
case 29: return std::string("PV voltage high");
case 30: return std::string("AC voltage out of range");
case 31: return std::string("AC frequency out of range");
case 32: return std::string("Module too hot");
// case 1~23 " Error: 99+x
default: return std::string("Fault code: " + to_string(value));
}
return x;