Hi there. Im trying to figure out how I can start and stop charg 5000w from grid to send a Little-endian in json and run it in Nod-Red to my BYD battery. Any suggestions?
Here is a jason code that works in BE but not in LE please help!
[
{
"id": "e6ebc9556a4f754e",
"type": "function",
"z": "2aa9d19d.92731e",
"name": "Lad Kostan 5kw",
"func": "var fc = 16;\nvar sa = 1034;\nvar addresses = 2;\nvar value = -5000;\nbuf = Buffer.alloc(4);\nbuf.writeFloatBE(value);\n//buf.writeFloatBE(-5000);\nvar values = [(buf[0] * 256 + buf[1]), (buf[2] * 256) + buf[3]]\nmsg.slave_ip = "192.168.0.117";\nmsg.payload = { "value": values, 'fc': fc, 'unitid': 71, 'address': sa, 'quantity': addresses };\nreturn msg;",
"outputs": 1,
"noerr": 6,
"initialize": "",
"finalize": "",
"libs": ,
"x": 840,
"y": 1780,
"wires": [
[
"44d268e917f21846"
]
]
},
{
"id": "44d268e917f21846",
"type": "modbus-flex-write",
"z": "2aa9d19d.92731e",
"name": "Write It",
"showStatusActivities": false,
"showErrors": false,
"server": "3da3c5245580e30a",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 1020,
"y": 1780,
"wires": [
,
]
},
{
"id": "add8a27e9551ee3e",
"type": "function",
"z": "2aa9d19d.92731e",
"name": "Stop batteri",
"func": "var fc = 16;\nvar sa = 1034;\nvar addresses = 2;\nvar value = 0;\nbuf = Buffer.alloc(4);\nbuf.writeFloatBE(value);\n//buf.writeFloatBE(0);\nvar values = [(buf[0] * 256 + buf[1]), (buf[2] * 256) + buf[3]]\nmsg.slave_ip = "192.168.0.117";\nmsg.payload = { "value": values, 'fc': fc, 'unitid': 71, 'address': sa, 'quantity': addresses };\nreturn msg;",
"outputs": 1,
"noerr": 6,
"initialize": "",
"finalize": "",
"libs": ,
"x": 870,
"y": 1700,
"wires": [
[
"44d268e917f21846"
]
]
},
{
"id": "3da3c5245580e30a",
"type": "modbus-client",
"name": "Kostal",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": true,
"queueLogEnabled": false,
"failureLogEnabled": true,
"tcpHost": "192.168.0.117",
"tcpPort": "1502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": 71,
"commandDelay": 1,
"clientTimeout": 1000,
"reconnectOnTimeout": true,
"reconnectTimeout": 2000,
"parallelUnitIdsAllowed": true
}
]