-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathnode-red-subflow.json
339 lines (339 loc) · 25.4 KB
/
node-red-subflow.json
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
[
{
"id": "16c33b1e099682e0",
"type": "subflow",
"name": "sofar inverter",
"info": "TCP server for LSW3 wifi logger \r\nused with Sofar inverters\r\n\r\n## Supported inverters\r\n\r\nSofar KTL-X \r\nSofar KTLX-G3 \r\nSofar ME3000SP \r\nSofar HYD6000-ES \r\n\r\n### Outputs\r\n1. JSON data\r\n: payload (object) : parsed data object.\r\n: topic (string) : frame data type.\r\n\r\n2. debug\r\n: payload (buffer) : raw data from inverter.\r\n: topic (string) : message origin.\r\n: frameType (string) : frame data type.\r\n\r\n### Details\r\n\r\nDefault local server port: \r\n`10000`\r\n\r\nDefault host IP: \r\n`47.88.8.200` (`data1.solarmanpv.com`) \r\nor \r\n`115.29.186.234` (`data2.solarmanpv.com`) \r\n\r\nDefault port nr: \r\n`10000`\r\n\r\n### References\r\n\r\n - [GitHub](https://github.com/serek4/node-red-sofar-inverter) - the node github repository\r\n",
"category": "",
"in": [],
"out": [
{
"x": 630,
"y": 260,
"wires": [
{
"id": "5d0553bafc1e3bf7",
"port": 0
}
]
},
{
"x": 1150,
"y": 260,
"wires": [
{
"id": "a92085a4d10f12e6",
"port": 0
}
]
}
],
"env": [
{
"name": "localPort",
"type": "num",
"value": "10000",
"ui": {
"icon": "font-awesome/fa-plug",
"label": {
"en-US": "local port"
},
"type": "input",
"opts": {
"types": [
"num",
"env"
]
}
}
},
{
"name": "resend",
"type": "bool",
"value": "true",
"ui": {
"label": {
"en-US": "forward data to remote server"
},
"type": "checkbox"
}
},
{
"name": "remoteHostIp",
"type": "str",
"value": "115.29.186.234",
"ui": {
"icon": "font-awesome/fa-cloud-upload",
"label": {
"en-US": "remote ip"
},
"type": "input",
"opts": {
"types": [
"str",
"env"
]
}
}
},
{
"name": "remoteHostPort",
"type": "num",
"value": "10000",
"ui": {
"icon": "font-awesome/fa-plug",
"label": {
"en-US": "remote port"
},
"type": "input",
"opts": {
"types": [
"num",
"env"
]
}
}
}
],
"meta": {
"version": "1.3.0",
"author": "serek4",
"desc": "sofar inverter with LSW3 wifi logger",
"license": "MIT"
},
"color": "#20c800",
"outputLabels": [
"JSON data",
"debug"
],
"icon": "node-red/bridge-dash.svg",
"status": {
"x": 300,
"y": 40,
"wires": [
{
"id": "7113cbe45845bb03",
"port": 0
}
]
}
},
{
"id": "f0ad23cb42522771",
"type": "tcp in",
"z": "16c33b1e099682e0",
"name": "Inverter stick out",
"server": "server",
"host": "",
"port": "${localPort}",
"datamode": "stream",
"datatype": "buffer",
"newline": "",
"topic": "inverter",
"base64": false,
"tls": "",
"x": 140,
"y": 120,
"wires": [
[
"5d0553bafc1e3bf7",
"88b9df11c34f72ea",
"a92085a4d10f12e6"
]
]
},
{
"id": "164f421ec73701f9",
"type": "tcp request",
"z": "16c33b1e099682e0",
"name": "Solarmanpv.com",
"server": "",
"port": "",
"out": "time",
"ret": "buffer",
"splitc": "1000",
"newline": "",
"tls": "",
"x": 810,
"y": 160,
"wires": [
[
"a92085a4d10f12e6"
]
]
},
{
"id": "c511e8c8f7ced576",
"type": "function",
"z": "16c33b1e099682e0",
"name": "generate response",
"func": "const request = msg.payload;\n\nconst timestamp = Math.floor(Date.now() / 1000);\nconst timestampStr = timestamp.toString(16);\nconst timestampBuff = Buffer.from(timestamp.toString(16), 'hex');\n\nconst response = Buffer.alloc(23);\nresponse.writeUInt8(0xA5, 0x00); // msg begin\n\nresponse.writeUInt8(0x0A, 0x01); // msg length\nresponse.writeUInt8(0x00, 0x02);\n\nresponse.writeUInt8(0x10, 0x03);\nresponse.writeUInt8(responseType(request.readUInt8(0x04)), 0x04); // match req type\n\nresponse.writeUInt8(request.readUInt8(0x05) >= 0xFF ? 0x00 : request.readUInt8(0x05) + 0x01, 0x05); // get from req + 1\nresponse.writeUInt8(request.readUInt8(0x06), 0x06); // get from req\n\nresponse.writeUInt32LE(request.readUInt32LE(0x07), 0x07); // wifi SN - get from req\n\nresponse.writeUInt8(request.readUInt8(0x0B), 0x0B); // get from req\nresponse.writeUInt8(0x01, 0x0C);\n\nresponse.writeUInt32LE(timestampBuff.readUInt32BE(0x00), 0x0D); // timestamp\n\nresponse.writeUInt8(0x78, 0x11);\nresponse.writeUInt8(0x00, 0x12);\nresponse.writeUInt8(0x00, 0x13);\nresponse.writeUInt8(0x00, 0x14);\n\nresponse.writeUInt8(calculateChecksum(response), 0x15); //checksum\nresponse.writeUInt8(0x15, 0x16); // msg end\n\nmsg.payload = response;\nmsg.topic = 'local_server';\nreturn msg;\n\nfunction responseType(requestTypeByte) {\n // node.warn(`req code: 0x${requestTypeByte.toString(16)}`);\n let responseTypeByte = requestTypeByte - (0x30);\n responseTypeByte = Math.min(Math.max(responseTypeByte, 0x00), 0xFF); //min 0x00 max 255\n // switch(requestTypeByte) {\n // case 0x41:\n // responseTypeByte = 0x11;\n // break;\n // case 0x42:\n // responseTypeByte = 0x12;\n // break;\n // case 0x43:\n // responseTypeByte = 0x13;\n // break;\n // case 0x47:\n // responseTypeByte = 0x17;\n // break;\n // case 0x48:\n // responseTypeByte = 0x18;\n // break;\n // default:\n // responseTypeByte = 0xFF;\n // }\n // node.warn(`res code: 0x${responseTypeByte.toString(16)}`);\n return responseTypeByte;\n}\nfunction calculateChecksum(message) {\n message = message.slice(1, -2);\n let sum = 0x0;\n for (const key of message.keys()) {\n sum += message[key];\n }\n sum = sum % 256;\n // node.warn( sum.toString(16));\n return sum;\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 810,
"y": 120,
"wires": [
[
"95b6eef2f2bbf823",
"a92085a4d10f12e6"
]
],
"inputLabels": [
"data from wifi stick"
],
"outputLabels": [
"response out"
]
},
{
"id": "95b6eef2f2bbf823",
"type": "tcp out",
"z": "16c33b1e099682e0",
"name": "Inverter stick response in",
"host": "",
"port": "10000",
"beserver": "reply",
"base64": false,
"end": true,
"tls": "",
"x": 1090,
"y": 120,
"wires": []
},
{
"id": "5d0553bafc1e3bf7",
"type": "function",
"z": "16c33b1e099682e0",
"name": "decode msg",
"func": "let buffer = msg.payload;\nlet data = {};\nswitch (buffer.length) {\n case 208: // data - HYD6000ES\n data.loggerSN = buffer.readUInt32LE(0x07);\n data.inverterSN = (buffer.toString('utf8', 0x20, 0x30)).trimEnd();\n data.DCPV1VoltageV = buffer.readUInt16LE(0x30) / 10;\n data.DCPV1CurrentA = buffer.readUInt16LE(0x32) / 100;\n data.DCPV1PowerW = buffer.readUInt16LE(0x34) * 10;\n data.DCPV2VoltageV = buffer.readUInt16LE(0x36) / 10;\n data.DCPV2CurrentA = buffer.readUInt16LE(0x38) / 100;\n data.DCPV2PowerW = buffer.readUInt16LE(0x3A) * 10;\n data.ACPVoltageV = buffer.readUInt16LE(0x3C) / 10;\n data.ACCurrentA = buffer.readUInt16LE(0x3E) / 100;\n data.ACFrequencyHz = buffer.readUInt16LE(0x40) / 100;\n data.battPowerW = buffer.readInt16LE(0x42) * 10;\n data.battVoltageV = buffer.readUInt16LE(0x44) / 10;\n data.battCurrentA = buffer.readInt16LE(0x46) / 100;\n data.battSoCPct = buffer.readUInt16LE(0x48);\n data.battTempC = buffer.readUInt16LE(0x4A);\n data.consumptionTotalW = buffer.readUInt16LE(0x4E) * 10;\n data.ACOutputTotalPowerW = buffer.readUInt16LE(0x52);\n data.emergencyOutputVoltageV = buffer.readUInt16LE(0x54) / 10;\n data.emergencyOutputPowerW = buffer.readUInt16LE(0x56) * 10;\n data.dailyGenerationkWh = buffer.readUInt16LE(0x58) / 100;\n data.dailyOnGridEnergykWh = buffer.readUInt16LE(0x5A) / 100;\n data.dailyEnergyPurchasedkWh = buffer.readUInt16LE(0x5C) / 100;\n data.dailyEnergyUsedkWh = buffer.readUInt16LE(0x5E) / 100;\n data.generationTotalkWh = buffer.readUInt32LE(0x60);\n data.totalOnGridGenerationkWh = buffer.readUInt32LE(0x64);\n data.totalEnergyPurchasedkWh = buffer.readUInt32LE(0x68);\n data.totalEnergyConsumptionkWh = buffer.readUInt32LE(0x6C);\n data.battDailyEnergyDischargedkWh = buffer.readUInt16LE(0x70) / 100;\n data.battDailyEnergyChargedkWh = buffer.readUInt16LE(0x72) / 100;\n data.battTotalEnergyChargedkWh = buffer.readUInt32LE(0x74);\n data.battTotalEnergyDischargedkWh = buffer.readUInt32LE(0x78);\n data.battTotalChargingDischargingTimesNum = buffer.readUInt16LE(0x80);\n data.busVoltageV = buffer.readUInt16LE(0x82) / 10;\n data.LLCbusVoltageV = buffer.readUInt16LE(0x84) / 10;\n data.buckCurrentA = buffer.readUInt16LE(0x86) / 100;\n data.powerGridVoltageV = buffer.readUInt16LE(0x88) / 10;\n data.powerGridCurrentA = buffer.readUInt16LE(0x8A) / 100;\n data.inverterTempC = buffer.readUInt16LE(0x8E);\n data.radiatorTempC = buffer.readUInt16LE(0x90);\n data.currentDCComponentA = buffer.readInt16LE(0x94);\n data.voltageDCComponentV = buffer.readInt16LE(0x96);\n data.dailyGeneratingHours = buffer.readUInt8(0xA4);\n data.totalGeneratingHours = buffer.readUInt32LE(0xA6);\n data.insulationImpedanceToTheGround = buffer.readUInt16LE(0xAA);\n data.insulationImpedancePVToGround = buffer.readUInt16LE(0xAC);\n data.insulationImpedanceCathodeToGround = buffer.readUInt16LE(0xAE);\n data.year = buffer.readUInt8(0xC8);\n data.month = buffer.readUInt8(0xC9);\n data.day = buffer.readUInt8(0xCA);\n data.hour = buffer.readUInt8(0xCB);\n data.minute = buffer.readUInt8(0xCC);\n data.second = buffer.readUInt8(0xCD);\n return {\n payload: data,\n topic: 'data'\n };\n break;\n case 232: // data - ME3000SP\n data.loggerSN = buffer.readUInt32LE(0x07);\n data.tempLogger = buffer.readInt16LE(0x70) / 100;\n data.tempBattery = buffer.readInt16LE(0x30) / 10;\n data.tempInverter = buffer.readInt16LE(0xA6);\n data.tempHeatSink = buffer.readInt16LE(0xA8);\n data.sensorTypeList = readSensorTypeList(buffer.slice(0x0C, 0x0E));\n data.tOperationTime = buffer.readUInt32LE(0x0E);\n data.inverterSN = (buffer.toString('utf8', 0x20, 0x30)).trimEnd();\n data.VAC1 = buffer.readUInt16LE(0x40) / 10;\n data.VAC2 = buffer.readUInt16LE(0x42) / 10;\n data.VAC3 = buffer.readUInt16LE(0x44) / 10;\n data.frequencyPowerGrid = buffer.readUInt16LE(0x46) / 100;\n data.currentPower = buffer.readUInt32LE(0x48);\n data.inverterStatus = decodeInverterStatus(buffer.readUInt8(0x58));\n data.Vbus = buffer.readUInt16LE(0x72) / 10;\n data.VCPU1 = buffer.readUInt16LE(0x74) / 10;\n data.cathode_groundInsulationImpedance = buffer.readUInt16LE(0x80);\n data.countryCode = buffer.readUInt16LE(0x82);\n data.A_phaseDCdistribution = buffer.readUInt16LE(0x8A);\n data.B_phaseDCdistribution = buffer.readUInt16LE(0x8C);\n data.C_phaseDCdistribution = buffer.readUInt16LE(0x8E);\n data.consumptionDailyEnergyPurchase = buffer.readUInt16LE(0x76);\n data.consumptionDailyEnergyUsed = buffer.readUInt16LE(0x78);\n data.consumptionTotal = buffer.readUInt16LE(0x86);\n data.generationTotal = buffer.readUInt16LE(0x7A);\n data.generationTotalOnGrid = buffer.readUInt16LE(0x7E);\n data.battChargeLevel = buffer.readUInt16LE(0x6A);\n data.battChargeDischargePower = buffer.readInt16LE(0x64) * 10;\n data.battCurrent = buffer.readInt16LE(0x68) / 100;\n data.battDailyGenerationPV = buffer.readUInt32LE(0x4C) / 100;\n data.battDailyEnergyCharged = buffer.readUInt16LE(0xc4) / 100;\n data.battDailyEnergyDischarged = buffer.readUInt16LE(0xC6) / 100;\n data.battGenerationCurrent = buffer.readInt16LE(0xA2) / 100;\n data.battTotalEnergyCharged = buffer.readUInt32LE(0xC8);\n data.battTotalEnergyDischarged = buffer.readUInt32LE(0xCC);\n data.battPower = buffer.readInt16LE(0xc2) * 10;\n data.battVoltage = buffer.readUInt16LE(0x66) / 100;\n\n data.busVoltage = buffer.readUInt16LE(0x90) / 10;\n data.busVoltageLlc = buffer.readUInt16LE(0x92) / 10;\n data.buckCurrent = buffer.readInt16LE(0x94) / 100;\n data.voltageDCComponent = buffer.readInt16LE(0xAE) / 10;\n data.epsOutVoltage = buffer.readInt16LE(0x96) / 10;\n data.productionCurrentR = buffer.readUInt16LE(0x98) / 100;\n data.productionCurrentS = buffer.readUInt16LE(0x9E) / 100;\n data.productionCurrentT = buffer.readUInt16LE(0xA0) / 100;\n\n data.year = buffer.readUInt8(0xE0);\n data.month = buffer.readUInt8(0xE1);\n data.day = buffer.readUInt8(0xE2);\n data.hour = buffer.readUInt8(0xE3);\n data.minute = buffer.readUInt8(0xE4);\n data.second = buffer.readUInt8(0xE5);\n let dateFormat = '20' + String(data.year).padStart(2, '0') + '-' + String(data.month).padStart(2, '0') + '-' + String(data.day).padStart(2, '0') + 'T' + String(data.hour).padStart(2, '0') + ':' + String(data.minute).padStart(2, '0') + ':' + String(data.second).padStart(2, '0')\n data.timestamp = new Date(dateFormat)\n //node.warn(data);\n return {\n payload: data,\n topic: 'data'\n };\n break;\n\n case 164: // data - KTL-X\n data.loggerSN = buffer.readUInt32LE(0x07);\n data.sensorTypeList = readSensorTypeList(buffer.slice(0x0C, 0x0E));\n data.tOperationTime = buffer.readUInt32LE(0x0E);\n data.inverterSN = (buffer.toString('utf8', 0x20, 0x30)).trimEnd();\n data.inverterTemp = buffer.readInt16LE(0x30) / 10;\n data.VDC1 = buffer.readUInt16LE(0x32) / 10;\n data.VDC2 = buffer.readUInt16LE(0x34) / 10;\n data.IDC1 = buffer.readUInt16LE(0x36) / 10;\n data.IDC2 = buffer.readUInt16LE(0x38) / 10;\n data.IAC1 = buffer.readUInt16LE(0x3A) / 10;\n data.IAC2 = buffer.readUInt16LE(0x3C) / 10;\n data.IAC3 = buffer.readUInt16LE(0x3E) / 10;\n data.VAC1 = buffer.readUInt16LE(0x40) / 10;\n data.VAC2 = buffer.readUInt16LE(0x42) / 10;\n data.VAC3 = buffer.readUInt16LE(0x44) / 10;\n data.fAC = buffer.readUInt16LE(0x46) / 100;\n\n data.currentPower = buffer.readUInt32LE(0x48);\n\n data.eToday = buffer.readUInt32LE(0x4C) / 100;\n data.eTotal = buffer.readUInt32LE(0x50) / 10;\n\n data.hTotal = buffer.readUInt32LE(0x54);\n\n data.inverterStatus = decodeInverterStatus(buffer.readUInt8(0x58));\n\n data.loggerTemp = buffer.readInt16LE(0x70);\n data.Vbus = buffer.readUInt16LE(0x72) / 10;\n data.VCPU1 = buffer.readUInt16LE(0x74) / 10;\n data.countdownTime = buffer.readUInt16LE(0x78);\n data.PV1insulationResistance = buffer.readUInt16LE(0x7C);\n data.PV2insulationResistance = buffer.readUInt16LE(0x7E);\n data.cathode_groundInsulationImpedance = buffer.readUInt16LE(0x80);\n data.countryCode = buffer.readUInt16LE(0x82);\n data.A_phaseDCdistribution = buffer.readUInt16LE(0x8A);\n data.B_phaseDCdistribution = buffer.readUInt16LE(0x8C);\n data.C_phaseDCdistribution = buffer.readUInt16LE(0x8E);\n\n data.firmware = buffer.toString('utf8', 0x90, 0x94);\n\n data.year = buffer.readUInt8(0x98);\n data.month = buffer.readUInt8(0x99);\n data.day = buffer.readUInt8(0x9A);\n data.hour = buffer.readUInt8(0x9B);\n data.minute = buffer.readUInt8(0x9C);\n data.second = buffer.readUInt8(0x9D);\n\n // node.warn(data);\n return {\n payload: data,\n topic: 'data'\n };\n break;\n case 1445: // data - KTLX-G3\n data.loggerSN = buffer.readUInt32LE(0x07);\n data.tOperationTime = buffer.readUInt32LE(0x0E);\n data.inverterSN = (buffer.toString('utf8', 0x8E, 0x9C));\n data.inverterPlateTemp = buffer.readInt16BE(0x50);\n data.inverterRadiatorTemp = buffer.readInt16BE(0x54);\n data.VDC1 = buffer.readUInt16BE(0x166) / 10;\n data.VDC2 = buffer.readUInt16BE(0x16C) / 10;\n data.IDC1 = buffer.readUInt16BE(0x168) / 100;\n data.IDC2 = buffer.readUInt16BE(0x16E) / 100;\n data.PDC1 = buffer.readUInt16BE(0x16A) / 100;\n data.PDC2 = buffer.readUInt16BE(0x170) / 100;\n data.IAC1 = buffer.readUInt16BE(0xDA) / 100;\n data.IAC2 = buffer.readUInt16BE(0xF0) / 100;\n data.IAC3 = buffer.readUInt16BE(0x106) / 100;\n data.VAC1 = buffer.readUInt16BE(0xD8) / 10;\n data.VAC2 = buffer.readUInt16BE(0xEE) / 10;\n data.VAC3 = buffer.readUInt16BE(0x104) / 10;\n data.fAC = buffer.readUInt16BE(0xC6) / 100;\n data.currentPower = buffer.readUInt16BE(0xC8) / 100;\n data.eToday = buffer.readUInt32BE(0x286) / 100;\n data.eTotal = buffer.readUInt32BE(0x28A) / 10;\n data.CombinerVoltageGroup1 = buffer.readUInt16BE(0x2E0) / 10;\n data.CombinerVoltageGroup2 = buffer.readUInt16BE(0x2E6) / 10;\n data.StringCurrentGroup1 = buffer.readUInt16BE(0x2E2) / 100;\n data.StringCurrentGroup2 = buffer.readUInt16BE(0x2E8) / 100;\n data.Vbus = buffer.readUInt16BE(0x2D2) / 10;\n data.year = buffer.readUInt16BE(0x78);\n data.month = buffer.readUInt16BE(0x7A);\n data.day = buffer.readUInt16BE(0x7C);\n data.hour = buffer.readUInt16BE(0x7E);\n data.minute = buffer.readUInt16BE(0x80);\n data.second = buffer.readUInt16BE(0x82);\n\n // node.warn(data);\n return {\n payload: data,\n topic: 'data'\n };\n break;\n case 99: // hello message\n data.loggerSN = buffer.readUInt32LE(0x07);\n data.tOperationTime = buffer.readUInt32LE(0x0C);\n data.uploadingFrequency = buffer.readUInt8(0x18);\n data.dataLoggingFrequency = buffer.readUInt8(0x19);\n data.heartbeatFrequency = buffer.readUInt8(0x1A);\n data.commandType = buffer.readUInt8(0x1B);\n data.signalQuality = buffer.readUInt8(0x1C);\n data.sensorTypeNr = buffer.readUInt8(0x1D);\n data.moduleVersion = buffer.toString('utf8', 0x1E, 0x46);\n data.macAddress = readMacAddress(buffer.slice(0x46, 0x4C));\n data.localIP = buffer.toString('utf8', 0x4C, 0x5B);\n data.sensorTypeList = readSensorTypeList(buffer.slice(0x5F, 0x61));\n\n // node.warn(data);\n return {\n payload: data,\n topic: 'hello'\n };\n break;\n case 41: // hello_cd message\n data.loggerSN = buffer.readUInt32LE(0x07);\n data.totalOperationTime = buffer.readUInt32LE(0x0C);\n\n // node.warn(data);\n return {\n payload: data,\n topic: 'hello_cd'\n };\n break;\n case 73: // hello_end message\n data.loggerSN = buffer.readUInt32LE(0x07);\n data.totalOperationTime = buffer.readUInt32LE(0x0C);\n\n // node.warn(data);\n return {\n payload: data,\n topic: 'hello_end'\n };\n break;\n\n default:\n // node.warn(buffer.length);\n return null\n break;\n}\n\nfunction readMacAddress(buffer) {\n let macAddressStr = '';\n for (let buff of buffer) {\n // node.warn(buff.toString(16));\n macAddressStr += `${`0${(buff.toString(16))}`.slice(-2)}:`;\n }\n return macAddressStr.substring(0, 17);\n}\nfunction readSensorTypeList(buffer) {\n let SensorTypeListStr = `${`0${(buffer[1].toString(16))}`.slice(-2)}`;\n SensorTypeListStr += `${`0${(buffer[0].toString(16))}`.slice(-2)}`;\n return SensorTypeListStr;\n}\n\nfunction decodeInverterStatus(status) {\n switch (status) {\n case 0x00:\n return `standby`;\n case 0x02:\n return `normal`;\n case 0x03:\n return `fault`;\n case 0x04:\n return `permanent`;\n default:\n return `0x${`0${(status.toString(16))}`.slice(-2)}`;\n }\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 450,
"y": 260,
"wires": [
[]
],
"inputLabels": [
"wifi stick buffer in"
],
"outputLabels": [
"decoded message object"
]
},
{
"id": "28fb73099b82097a",
"type": "change",
"z": "16c33b1e099682e0",
"name": "set host and port",
"rules": [
{
"t": "set",
"p": "host",
"pt": "msg",
"to": "remoteHostIp",
"tot": "env"
},
{
"t": "set",
"p": "port",
"pt": "msg",
"to": "remoteHostPort",
"tot": "env"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "remote_server",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 610,
"y": 160,
"wires": [
[
"164f421ec73701f9"
]
]
},
{
"id": "88b9df11c34f72ea",
"type": "switch",
"z": "16c33b1e099682e0",
"name": "",
"property": "resend",
"propertyType": "env",
"rules": [
{
"t": "istype",
"v": "boolean",
"vt": "boolean"
},
{
"t": "true"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 430,
"y": 120,
"wires": [
[
"c511e8c8f7ced576"
],
[
"28fb73099b82097a"
]
],
"inputLabels": [
"inverter data"
],
"outputLabels": [
"local server only",
"remote server"
]
},
{
"id": "7113cbe45845bb03",
"type": "status",
"z": "16c33b1e099682e0",
"name": "",
"scope": [
"f0ad23cb42522771"
],
"x": 160,
"y": 40,
"wires": [
[]
]
},
{
"id": "a92085a4d10f12e6",
"type": "function",
"z": "16c33b1e099682e0",
"name": "add msg.frameType",
"func": "let frameType = '';\nswitch (msg.payload.length) {\n case 99:\n frameType = 'hello(99)';\n break;\n case 23:\n frameType = 'srv_res(23)';\n break;\n case 164: // KTL-X\n case 208: // HYD6000ES\n case 232: // ME3000SP\n case 1445: // KTLX-G3\n frameType = `data(${msg.payload.length})`;\n break;\n case 14:\n frameType = 'heartbeat(14)';\n break;\n case 41:\n frameType = 'hello_cd(41)';\n break;\n case 73:\n frameType = 'hello_end(73)';\n break;\n default:\n frameType = `unknown(${msg.payload.length})`;\n break;\n}\nmsg.frameType = frameType;\n// delete TCP nodes properties\ndelete msg.ip;\ndelete msg.host;\ndelete msg.port;\ndelete msg._session;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 960,
"y": 260,
"wires": [
[]
]
}
]