-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathesp32-srne-asf-example.yaml
851 lines (785 loc) · 20.3 KB
/
esp32-srne-asf-example.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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
# See https://github.com/syssi/esphome-smg-ii/issues/28
# See https://github.com/HotNoob/PythonProtocolGateway/blob/main/protocols/srne/srne_v1.7.holding_registry_map.csv
substitutions:
name: srne-asf
friendly_name: ${name}
device_description: "Monitor and control a SRNE ASF inverter via RS232"
tx_pin: GPIO16
rx_pin: GPIO17
esphome:
name: ${name}
friendly_name: ${friendly_name}
comment: ${device_description}
min_version: 2024.6.0
project:
name: "syssi.esphome-smg-ii"
version: 1.1.0
esp32:
board: wemos_d1_mini32
framework:
type: esp-idf
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ota:
platform: esphome
logger:
level: INFO
# If you use Home Assistant please remove this `mqtt` section and uncomment the `api` component!
# The native API has many advantages over MQTT: https://esphome.io/components/api.html#advantages-over-mqtt
mqtt:
broker: !secret mqtt_host
username: !secret mqtt_username
password: !secret mqtt_password
id: mqtt_client
# api:
uart:
- id: uart_0
baud_rate: 9600
tx_pin: ${tx_pin}
rx_pin: ${rx_pin}
modbus:
- id: modbus0
uart_id: uart_0
send_wait_time: 200ms
modbus_controller:
- id: inverter0
address: 0x01
modbus_id: modbus0
command_throttle: 200ms
update_interval: 10s
time:
- platform: sntp
sensor:
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Software Version"
id: software_version
register_type: holding
address: 0x014
register_count: 2
value_type: U_DWORD
skip_updates: 1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Hardware Version"
id: hardware_version
register_type: holding
address: 0x016
register_count: 2
value_type: U_DWORD
skip_updates: 1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Battery SOC"
id: battery_soc
register_type: holding
address: 0x100
unit_of_measurement: "%"
value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Battery Voltage"
id: battery_voltage
address: 0x101
unit_of_measurement: "V"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Battery Current"
id: battery_current
address: 0x102
unit_of_measurement: "A"
register_type: holding
value_type: S_WORD
accuracy_decimals: 1
filters:
- multiply: -0.1
- platform: template
name: "Battery Power"
id: battery_power
unit_of_measurement: "W"
lambda: |-
return (id(battery_voltage).state * id(battery_current).state);
accuracy_decimals: 1
device_class: power
update_interval: 1s
- platform: modbus_controller
modbus_controller_id: inverter0
name: "MPPT 1 Voltage"
id: mppt1_voltage
address: 0x107
unit_of_measurement: "V"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "MPPT 1 Current"
id: mppt1_current
address: 0x108
unit_of_measurement: "A"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "MPPT 1 Power"
id: mppt1_power
address: 0x109
unit_of_measurement: "W"
register_type: holding
value_type: U_WORD
device_class: Power
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Charge Power"
id: charge_power
address: 0x10E
unit_of_measurement: "W"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "MPPT 2 Voltage"
id: mppt2_voltage
address: 0x10F
unit_of_measurement: "V"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "MPPT 2 Current"
id: mppt2_current
address: 0x110
unit_of_measurement: "A"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "MPPT 2 Power"
id: mppt2_power
address: 0x111
unit_of_measurement: "W"
register_type: holding
value_type: U_WORD
device_class: Power
accuracy_decimals: 1
- platform: template
name: "Solar Power"
id: solar_power
unit_of_measurement: "W"
accuracy_decimals: 0
device_class: Power
update_interval: 1s
lambda: |-
return (id(mppt1_power).state + id(mppt2_power).state);
- platform: modbus_controller
modbus_controller_id: inverter0
id: battery_rated_voltage
name: "Rated Voltage"
address: 0x204
unit_of_measurement: "V"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.01
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: time_year
# name: "Time Year"
# address: 0x020C
# register_type: holding
# bitmask: 0xFF00
# value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: inverter0
id: grid_voltage
name: "Grid Voltage"
address: 0x213
unit_of_measurement: "V"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: grid_current_a
name: "Grid Current A"
address: 0x214
unit_of_measurement: "A"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: grid_frequency
name: "Grid Frequency"
address: 0x215
unit_of_measurement: "Hz"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.01
- platform: modbus_controller
modbus_controller_id: inverter0
id: inverter_voltage
name: "Inverter Voltage"
address: 0x216
unit_of_measurement: "V"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: inverter_frequency
name: "Inverter Frequency"
address: 0x218
unit_of_measurement: "Hz"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.01
- platform: modbus_controller
modbus_controller_id: inverter0
id: inverter_current
name: "Inverter Current"
address: 0x219
unit_of_measurement: "A"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: inverter_load_a
name: "Inverter Load A"
address: 0x021B
unit_of_measurement: "W"
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1
- platform: modbus_controller
modbus_controller_id: inverter0
id: grid_voltage_b
name: "Grid Voltage B"
address: 0x022A
unit_of_measurement: "V"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: grid_current_b
name: "Grid Current B"
address: 0x022E
unit_of_measurement: "A"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: template
name: "Grid Power"
id: grid_power
unit_of_measurement: "W"
accuracy_decimals: 0
update_interval: 1s
lambda: |-
return (id(grid_voltage).state * id(grid_current_a).state);
- platform: modbus_controller
modbus_controller_id: inverter0
id: inverter_load_b
name: "Inverter Load B"
address: 0x232
unit_of_measurement: "W"
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1
- platform: template
name: "Inverter Load"
id: inverter_load
unit_of_measurement: "W"
accuracy_decimals: 0
update_interval: 1s
lambda: |-
return (id(inverter_load_a).state + id(inverter_load_b).state);
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: over_voltage_threshold
# name: ${name}_over_voltage_threshold
# address: 0xE005
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
#
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: charging_voltage_limit
# name: ${name}_charging_voltage_limit
# address: 0xE006
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
#
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: equalizing_charge_voltage
# name: ${name}_equalizing_charge_voltage
# address: 0xE007
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
#
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: boost_voltage
# name: ${name}_boost_voltage
# address: 0xE008
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
#
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: float_voltage
# name: ${name}_float_voltage
# address: 0xE009
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
#
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: boost_charging_recovery_voltage
# name: ${name}_boost_charging_recovery_voltage
# address: 0xE00A
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
#
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: over_discharge_recovery_voltage
# name: ${name}_over_discharge_recovery_voltage
# address: 0xE00B
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
#
# ######## 8 ########
#
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: under_voltage_warning
# name: ${name}_under_voltage_warning
# address: 0xE00C
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
#
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: over_discharge_voltage
# name: ${name}_over_discharge_voltage
# address: 0xE00D
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
#
# - platform: modbus_controller
# modbus_controller_id: inverter0
# id: discharge_limit_voltage
# name: ${name}_discharge_limit_voltage
# address: 0xE00E
# register_type: holding
# value_type: U_WORD
# accuracy_decimals: 1
# unit_of_measurement: "V"
# skip_updates: 1
# # filters:
# # - multiply: 0.1
# lambda: "return x * 0.4;"
- platform: modbus_controller
modbus_controller_id: inverter0
id: inverter_to_grid
name: "Inverter to Grid"
address: 0xE01B
register_type: holding
value_type: U_WORD
icon: mdi:sine-wave
accuracy_decimals: 1
unit_of_measurement: "V"
skip_updates: 1
# filters:
# - multiply: 0.1
lambda: "return x * 0.4;"
- platform: modbus_controller
modbus_controller_id: inverter0
id: grid_to_inverter
name: "Grid to Inverter"
address: 0xE022
register_type: holding
value_type: U_WORD
icon: mdi:sine-wave
accuracy_decimals: 1
unit_of_measurement: "V"
skip_updates: 1
# filters:
# - multiply: 0.1
lambda: "return x * 0.4;"
- platform: modbus_controller
modbus_controller_id: inverter0
id: solar_today
name: "Solar Power Today"
address: 0x0F02F
unit_of_measurement: "kWh"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
device_class: "Energy"
state_class: "total"
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: load_today
name: "Load Power Today"
address: 0x0F030
unit_of_measurement: "kWh"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
device_class: "Energy"
state_class: "total"
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: grid_today
name: "Grid Power Today"
address: 0x0F03D
unit_of_measurement: "kWh"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
device_class: "energy"
state_class: "total"
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: solar_accumulated
name: "Accumulated Solar Power"
address: 0x0F038
unit_of_measurement: "kWh"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
device_class: "Energy"
state_class: "total"
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: load_accumulated
name: "Accumulated Load Power"
address: 0x0F03A
unit_of_measurement: "kWh"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
device_class: "Energy"
state_class: "total"
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: grid_accumulated
name: "Accumulated Grid Power"
address: 0x0F048
unit_of_measurement: "kWh"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
device_class: "Energy"
state_class: "total"
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: inverter0
id: bypass_time
name: "Bypass Time"
address: 0x0F03F
unit_of_measurement: "min"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
number:
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Inverter to Grid Voltage"
id: inverter_togrid_bvoltage
address: 0xE01B
value_type: U_WORD
register_type: holding
unit_of_measurement: "V"
min_value: 40
max_value: 60
step: 0.1
lambda: "return x * 0.4;"
write_lambda: "return x * 2.5;"
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Grid to Inverter Voltage"
id: grid_toinverter_bvoltage
address: 0xE022
value_type: U_WORD
register_type: holding
unit_of_measurement: "V"
min_value: 40
max_value: 60
step: 0.1
lambda: "return x * 0.4;"
write_lambda: "return x * 2.5;"
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Boost Charge Voltage"
id: boost_voltage
address: 0xE008
value_type: U_WORD
register_type: holding
unit_of_measurement: "V"
min_value: 48
max_value: 58.4
step: 0.4
lambda: "return x * 0.4;"
write_lambda: "return x * 2.5;"
use_write_multiple: true
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Float Charge Voltage"
id: float_voltage
address: 0xE009
value_type: U_WORD
register_type: holding
unit_of_measurement: "V"
min_value: 48
max_value: 58.4
step: 0.4
lambda: "return x * 0.4;"
write_lambda: "return x * 2.5;"
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Grid Charge Current"
address: 0xE205
value_type: U_WORD
register_type: holding
unit_of_measurement: "A"
min_value: 0
max_value: 120
step: 1
lambda: "return x * 0.1;"
write_lambda: "return x * 10;"
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Total Charge Current"
address: 0xE20A
value_type: U_WORD
register_type: holding
unit_of_measurement: "A"
min_value: 10
max_value: 200
step: 10
lambda: "return x * 0.1;"
write_lambda: "return x * 10;"
select:
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Output Priority"
id: output_priority
address: 0xE204
value_type: U_WORD
optionsmap:
"Solar": 0
"Utility": 1
"Solar-Battery": 2
- platform: modbus_controller
modbus_controller_id: inverter0
name: "AC Input Voltage Range"
address: 0xE20B
value_type: U_WORD
optionsmap:
"Appliance": 0
"UPS": 1
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Charge Priority"
address: 0xE20F
value_type: U_WORD
optionsmap:
"Solar and Utility": 0
"Utility-Solar": 1
"Solar-Utility": 2
"Solar Only": 3
switch:
- platform: modbus_controller
use_write_multiple: true
modbus_controller_id: inverter0
name: "Overload Restart"
register_type: holding
address: 0xE20D
bitmask: 1
entity_category: config
icon: "mdi:toggle-switch"
- platform: modbus_controller
use_write_multiple: true
modbus_controller_id: inverter0
name: "Alarms"
register_type: holding
address: 0xE210
bitmask: 1
entity_category: config
icon: "mdi:toggle-switch"
- platform: modbus_controller
use_write_multiple: true
modbus_controller_id: inverter0
name: "ECO Mode"
register_type: holding
address: 0xE20C
bitmask: 1
entity_category: config
icon: "mdi:toggle-switch"
- platform: modbus_controller
use_write_multiple: true
modbus_controller_id: inverter0
name: "Overload Restart"
register_type: holding
address: 0xE20D
bitmask: 1
entity_category: config
icon: "mdi:toggle-switch"
- platform: modbus_controller
use_write_multiple: true
modbus_controller_id: inverter0
name: "Overload Bypass"
register_type: holding
address: 0xE212
bitmask: 1
entity_category: config
icon: "mdi:toggle-switch"
text_sensor:
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Inverter State"
id: inverter_state
address: 0x0210
register_type: holding
raw_encode: HEXBYTES
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("Power On");
case 1: return std::string("Standby");
case 2: return std::string("Mains");
case 3: return std::string("Off-Grid");
case 4: return std::string("Bypass");
case 5: return std::string("Charging");
case 6: return std::string("Fault");
}
return std::string("Unknown");
- platform: modbus_controller
modbus_controller_id: inverter0
name: "Charge State"
id: charge_state
address: 0x010B
register_type: holding
raw_encode: HEXBYTES
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("Charge Off");
case 1: return std::string("Quick Charge");
case 2: return std::string("Cons Volt Charge");
case 4: return std::string("Float Charge");
case 5: return std::string("Reserved");
case 6: return std::string("Li Batt Activate");
case 7: return std::string("Reserved");
}
return std::string("Unknown");