Kostal Plenticore MODBUS LE Code to start charge from grid code

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
}
]

first use Ctrl+E for Code.
second use correct code, not squares symbols !

what do you want with 1076+1078 ?
you can't do anything with it.

you´ll need 1024 to set power manually.

1024 Battery charge power (AC) setpoint Note1,6
Negative values will charge the battery, positive values will discharge the battery.

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

var fc = 16;
var sa = 1034;
var addresses = 2;
var value = 0;
buf = Buffer.alloc(4);
buf.writeFloatBE(value);
//buf.writeFloatBE(0);
var values = [(buf[0] * 256 + buf[1]), (buf[2] * 256) + buf[3]]
msg.slave_ip = "192.168.10.12";
msg.payload = { "value": values, 'fc': fc, 'unitid': 71, 'address': sa, 'quantity': addresses };
return msg;



var fc = 16;
var sa = 1034;
var addresses = 2;
var value = -5000;
buf = Buffer.alloc(4);
buf.writeFloatBE(value);
//buf.writeFloatBE(-5000);
var values = [(buf[0] * 256 + buf[1]), (buf[2] * 256) + buf[3]]
msg.slave_ip = "192.168.10.12";
msg.payload = { "value": values, 'fc': fc, 'unitid': 71, 'address': sa, 'quantity': addresses };
return msg;

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.