This flow extracts values from a SolarEdge inverter by accessing modbus-tcp on the inverter. In this example we also push those values into an influxdb-server.
-
-
Save jonaslq/f812ebbe49ee484628952b38cde7aad8 to your computer and use it in GitHub Desktop.
SolarEdge-modbus-influxdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"id": "ccdb2874.ab7a18", | |
"type": "debug", | |
"z": "b1d21476.ba5f88", | |
"name": "", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"x": 797, | |
"y": 1108, | |
"wires": [] | |
}, { | |
"id": "a4e7878c.859e1", | |
"type": "function", | |
"z": "b1d21476.ba5f88", | |
"name": "Solaredge TCP modbus -> JSON", | |
"func": "// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer);\n\n// Create influxdb JSON\nmsg.payload = [\n [{\n 'AC Total Current': round(uint16(40072) * scalefactor(40076), 2),\n 'AC Current phase A': round(uint16(40073) * scalefactor(40076), 2),\n 'AC Current phase B': round(uint16(40074) * scalefactor(40076), 2),\n 'AC Current phase C': round(uint16(40075) * scalefactor(40076), 2),\n 'AC Voltage phase A': round(uint16(40080) * scalefactor(40083), 2),\n 'AC Voltage phase B': round(uint16(40081) * scalefactor(40083), 2),\n 'AC Voltage phase C': round(uint16(40082) * scalefactor(40083), 2),\n 'AC Power output': round(int16(40084) * scalefactor(40085), 2),\n 'AC Lifetimeproduction': round(uint32(40094) * scalefactor(40096), 2),\n 'DC Current': round(uint16(40097) * scalefactor(40098), 2),\n 'DC Voltage': round(uint16(40099) * scalefactor(40100), 2),\n 'DC Power input': round(int16(40101) * scalefactor(40102), 2),\n 'Heat sink temp': round(int16(40104) * scalefactor(40107), 2),\n 'Status': round(uint16(40108), 2),\n time: new Date()\n },\n {\n inverter: '1'\n }]\n];\n\n\nreturn msg;\n\nfunction word(address) {\n // Find the correct offset in bytes\n // 40070 is the starting address we fetch from SolarEdge inverter\n return (address-40070) * 2;\n}\n\nfunction scalefactor(address) {\n return Math.pow(10, buf.readInt16BE(word(address)));\n}\n\nfunction int16(address) {\n return buf.readInt16BE(word(address))\n}\n\nfunction uint16(address) {\n return buf.readUInt16BE(word(address));\n}\n\nfunction int32(address) {\n return buf.readInt32BE(word(address))\n}\n\nfunction uint32(address) {\n return buf.readUInt32BE(word(address))\n}\n\nfunction round(value, decimals) {\n return Number(Math.round(value+'e'+decimals)+'e-'+decimals);\n} ", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 390, | |
"y": 1111, | |
"wires": [ | |
["971fd960.34551", "3f6de239.94e796", "ccdb2874.ab7a18"] | |
] | |
}, { | |
"id": "3626c1bf.cfc89e", | |
"type": "modbus-read", | |
"z": "b1d21476.ba5f88", | |
"name": "SolarEdge 3", | |
"topic": "", | |
"showStatusActivities": false, | |
"logIOActivities": false, | |
"showErrors": false, | |
"unitid": "1", | |
"dataType": "HoldingRegister", | |
"adr": "40069", | |
"quantity": "40", | |
"rate": "5000", | |
"rateUnit": "ms", | |
"delayOnStart": false, | |
"startDelayTime": "", | |
"server": "4d15fe9c.d15258", | |
"useIOFile": false, | |
"ioFile": "", | |
"useIOForPayload": false, | |
"x": 144, | |
"y": 1104, | |
"wires": [ | |
[], | |
["a4e7878c.859e1"] | |
] | |
}, { | |
"id": "971fd960.34551", | |
"type": "influxdb out", | |
"z": "b1d21476.ba5f88", | |
"influxdb": "7e4fea80.135824", | |
"name": "", | |
"measurement": "SolarEdge", | |
"precision": "ms", | |
"retentionPolicy": "", | |
"x": 701.5, | |
"y": 1143, | |
"wires": [] | |
}, { | |
"id": "b24cd458.b49cc", | |
"type": "comment", | |
"z": "b1d21476.ba5f88", | |
"name": "Fetch Solaredge TCP modbus data", | |
"info": "zsdfzsdfg", | |
"x": 189.5, | |
"y": 1043, | |
"wires": [] | |
}, { | |
"id": "4d15fe9c.d15258", | |
"type": "modbus-client", | |
"z": "", | |
"name": "SolarEdge", | |
"clienttype": "tcp", | |
"bufferCommands": true, | |
"stateLogEnabled": false, | |
"tcpHost": "192.168.6.10", | |
"tcpPort": "1502", | |
"tcpType": "DEFAULT", | |
"serialPort": "/dev/ttyUSB", | |
"serialType": "RTU-BUFFERD", | |
"serialBaudrate": "9600", | |
"serialDatabits": "8", | |
"serialStopbits": "1", | |
"serialParity": "none", | |
"serialConnectionDelay": "100", | |
"unit_id": 1, | |
"commandDelay": 1, | |
"clientTimeout": 1000, | |
"reconnectTimeout": 20000 | |
}, { | |
"id": "7e4fea80.135824", | |
"type": "influxdb", | |
"z": "", | |
"hostname": "192.168.6.11", | |
"port": "8086", | |
"protocol": "http", | |
"database": "solaredge", | |
"name": "InfluxDB/solaredge", | |
"usetls": false, | |
"tls": "b56a2f8c.4744d" | |
}, { | |
"id": "b56a2f8c.4744d", | |
"type": "tls-config", | |
"z": "", | |
"name": "local-tls", | |
"cert": "", | |
"key": "", | |
"ca": "", | |
"certname": "", | |
"keyname": "", | |
"caname": "", | |
"verifyservercert": false | |
}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment