-
Notifications
You must be signed in to change notification settings - Fork 17
/
solis-modbus-inv.yaml
403 lines (398 loc) · 12.2 KB
/
solis-modbus-inv.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
#
# solis-modbus-inv.yaml -- Ginlong Solis INV Inverter modbus sensors include file
#
# ! This file is to be included as a package in an ESPhome definition !
# ! This file only works with Solis 'INV' type inverters !
#
# (C) 2023 Hajo Noerenberg
#
# http://www.noerenberg.de/
# https://github.com/hn/ginlong-solis
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3.0 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>.
#
number:
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Limit output power
disabled_by_default: true # intentionally disabled, remove if you know what you are doing
register_type: holding
address: 3051 # = 3052 - 1
value_type: S_WORD
unit_of_measurement: '%'
entity_category: config
icon: mdi:percent
skip_updates: 10
mode: box
min_value: 0
max_value: 110
multiply: 100
select:
- platform: modbus_controller
name: Working Mode
disabled_by_default: true # intentionally disabled, remove if you know what you are doing
address: 3040 # = 3041 - 1
value_type: U_WORD
entity_category: config
icon: mdi:cog-outline
skip_updates: 10
optionsmap:
"No response mode": 0
"Volt-Watt default": 1
"Volt-VAr": 2
"Fixed power factor": 3
"Fix reactive power": 4
"Power-PF": 5
"Rule21Volt-Watt": 6
binary_sensor:
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Working status Normal
register_type: read
address: 3071 # = 3072 - 1
bitmask: 0x0001
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Working status Initializing
register_type: read
address: 3071 # = 3072 - 1
bitmask: 0x0002
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Working status Grid off
device_class: problem
register_type: read
address: 3071 # = 3072 - 1
bitmask: 0x0004
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Working status Fault to stop
device_class: problem
register_type: read
address: 3071 # = 3072 - 1
bitmask: 0x0008
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Working status Standby
register_type: read
address: 3071 # = 3072 - 1
bitmask: 0x0010
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Working status Derating
register_type: read
address: 3071 # = 3072 - 1
bitmask: 0x0020
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Working status Limitating
register_type: read
address: 3071 # = 3072 - 1
bitmask: 0x0040
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Working status Grid surge
device_class: problem
register_type: read
address: 3071 # = 3072 - 1
bitmask: 0x0100
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Working status Fan fault
device_class: problem
register_type: read
address: 3071 # = 3072 - 1
bitmask: 0x0200
sensor:
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Active Power
device_class: power
state_class: measurement
unit_of_measurement: W
register_type: read
address: 3004 # = 3005 - 1
value_type: U_DWORD
on_value:
then:
- script.execute: modbus_activity
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Total DC output power
device_class: power
state_class: measurement
unit_of_measurement: W
register_type: read
address: 3006 # = 3007 - 1
value_type: U_DWORD
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Total energy
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
register_type: read
address: 3008 # = 3009 - 1
value_type: U_DWORD
force_new_range: true # workaround to seperate reg 3006: "skip_updates applies for all components in the same range"
skip_updates: 10
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Energy this month
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
register_type: read
address: 3010 # = 3011 - 1
value_type: U_DWORD
skip_updates: 10
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Energy last month
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
register_type: read
address: 3012 # = 3013 - 1
value_type: U_DWORD
skip_updates: 10
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Energy today
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
register_type: read
address: 3014 # = 3015 - 1
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
skip_updates: 10
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Energy last day
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
register_type: read
address: 3015 # = 3016 - 1
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
skip_updates: 10
- platform: modbus_controller
modbus_controller_id: modbus_master
name: DC voltage 1
device_class: voltage
state_class: measurement
unit_of_measurement: V
register_type: read
address: 3021 # = 3022 - 1
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: modbus_master
name: DC current 1
device_class: current
state_class: measurement
unit_of_measurement: A
register_type: read
address: 3022 # = 3023 - 1
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: modbus_master
name: DC voltage 2
device_class: voltage
state_class: measurement
unit_of_measurement: V
register_type: read
address: 3023 # = 3024 - 1
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: modbus_master
name: DC current 2
device_class: current
state_class: measurement
unit_of_measurement: A
register_type: read
address: 3024 # = 3025 - 1
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: modbus_master
name: AC voltage
device_class: voltage
state_class: measurement
unit_of_measurement: V
register_type: read
address: 3035 # = 3036 - 1
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Inverter temperature
device_class: temperature
state_class: measurement
unit_of_measurement: °C
register_type: read
address: 3041 # = 3042 - 1
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Grid frequency
device_class: frequency
state_class: measurement
unit_of_measurement: Hz
register_type: read
address: 3042 # = 3043 - 1
value_type: U_WORD
accuracy_decimals: 2
filters:
- multiply: 0.01
text_sensor:
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Product model
register_type: read
address: 2999 # = 3000 - 1
response_size: 2
raw_encode: HEXBYTES
entity_category: diagnostic
icon: mdi:factory
skip_updates: 10
- platform: modbus_controller
modbus_controller_id: modbus_master
name: DSP software version
register_type: read
address: 3000 # = 3001 - 1
response_size: 2
force_new_range: true # workaround for bug concatening model, dsp and lcd
raw_encode: HEXBYTES
entity_category: diagnostic
icon: mdi:chip
skip_updates: 10
- platform: modbus_controller
modbus_controller_id: modbus_master
name: LCD software version
register_type: read
address: 3001 # = 3002 - 1
response_size: 2
raw_encode: HEXBYTES
entity_category: diagnostic
icon: mdi:chip
skip_updates: 10
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Country standard code
register_type: read
address: 3053 # = 3054 - 1
response_size: 2
raw_encode: HEXBYTES
entity_category: diagnostic
icon: mdi:earth
skip_updates: 10
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
/* Solis Spec Appendix 3 */
case 0x003: return std::string("VDE0126");
case 0x009: return std::string("MEX-CFE");
case 0x00B: return std::string("VDE4105");
}
return x;
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Inverter SN
register_type: read
address: 3060 # = 3061 - 1
register_count: 4
raw_encode: HEXBYTES
entity_category: diagnostic
icon: mdi:numeric
skip_updates: 10
lambda: |-
char serialnumber[4 * 4 + 1];
for (int j = 0; j < 4; j++) {
unsigned int r = esphome::modbus_controller::word_from_hex_str(x, j * 2);;
sprintf(serialnumber + (j * 4), "%02x%02x",
(r & 0x0F) << 4 | (r & 0xF0) >> 4, (r & 0x0F00) >> 4 | (r & 0xF000) >> 12);
}
serialnumber[4 * 4] = 0;
return std::string(serialnumber);
- platform: modbus_controller
modbus_controller_id: modbus_master
id: inverter_rtc
register_type: holding
address: 2999 # = 3000 - 1
register_count: 6
raw_encode: HEXBYTES
entity_category: diagnostic
icon: mdi:clock-digital
skip_updates: 10
lambda: |-
time_t i_t;
struct tm i_tm = { 0 };
i_tm.tm_year = modbus_controller::word_from_hex_str(x, 0*2) + 2000 - 1900;
i_tm.tm_mon = modbus_controller::word_from_hex_str(x, 1*2) - 1;
i_tm.tm_mday = modbus_controller::word_from_hex_str(x, 2*2);
i_tm.tm_hour = modbus_controller::word_from_hex_str(x, 3*2);
i_tm.tm_min = modbus_controller::word_from_hex_str(x, 4*2);
i_tm.tm_sec = modbus_controller::word_from_hex_str(x, 5*2);
i_tm.tm_isdst = -1;
i_t = mktime(&i_tm);
ESP_LOGI("SyncInverterRTC", "Inverter RTC is %02d:%02d:%02d %04d-%02d-%02d",
i_tm.tm_hour, i_tm.tm_min, i_tm.tm_sec, i_tm.tm_year + 1900, i_tm.tm_mon + 1, i_tm.tm_mday);
auto s_espt = id(network_time).now();
if (s_espt.is_valid()) {
double deviation = difftime(i_t, s_espt.timestamp);
if (abs(deviation) > 42) {
std::vector<uint16_t> rtc_data =
{(uint16_t) (s_espt.year % 100), s_espt.month, s_espt.day_of_month, s_espt.hour, s_espt.minute, s_espt.second};
auto set_rtc_command =
modbus_controller::ModbusCommandItem::create_write_multiple_command(modbus_master, item->start_address, item->register_count, rtc_data);
modbus_master->queue_command(set_rtc_command);
ESP_LOGI("SyncInverterRTC", "Inverter RTC deviation=%.fs, updated RTC to %02d:%02d:%02d %04d-%02d-%02d",
deviation, s_espt.hour, s_espt.minute, s_espt.second, s_espt.year, s_espt.month, s_espt.day_of_month);
}
} else {
ESP_LOGI("SyncInverterRTC", "Inverter RTC not checked because NTP is not yet synchronised");
}
return {};
- platform: modbus_controller
modbus_controller_id: modbus_master
name: Inverter type definition
register_type: read
address: 35000
response_size: 2
raw_encode: HEXBYTES
entity_category: diagnostic
icon: mdi:chip
skip_updates: 10