Hello! Earlier I asked help from forum about decoding the binary array with buffer parser. Lately got it working with help of you guys and thinked to share result as an example, how I managed to receive data out from my home battery. Maybe it will help someone in future
[
{
"id": "2e8ca724a2ec6615",
"type": "tcp in",
"z": "b3b5ee615be88a64",
"name": "",
"server": "client",
"host": "192.168.0.138",
"port": "9865",
"datamode": "stream",
"datatype": "buffer",
"newline": "",
"topic": "",
"trim": false,
"base64": false,
"tls": "",
"x": 130,
"y": 180,
"wires": [
[
"3de6baa54a48cb27"
]
]
},
{
"id": "1eaae525a714f81e",
"type": "buffer-parser",
"z": "b3b5ee615be88a64",
"name": "Parse values from buffer",
"data": "payload",
"dataType": "msg",
"specification": "spec",
"specificationType": "ui",
"items": [
{
"type": "byte",
"name": "status",
"offset": 27,
"length": 1,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "int32le",
"name": "chargeLevelWh",
"offset": 54,
"length": 1,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "int32le",
"name": "powerLevelWh",
"offset": 36,
"length": 1,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "byte",
"name": "powerDirection",
"offset": 42,
"length": 1,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "int32le",
"name": "cellsTemp",
"offset": 45,
"length": 1,
"offsetbit": 0,
"scale": "/100",
"mask": ""
}
],
"swap1": "",
"swap2": "",
"swap3": "",
"swap1Type": "swap",
"swap2Type": "swap",
"swap3Type": "swap",
"msgProperty": "payload",
"msgPropertyType": "str",
"resultType": "value",
"resultTypeType": "return",
"multipleResult": true,
"fanOutMultipleResult": true,
"setTopic": true,
"outputs": 5,
"x": 750,
"y": 180,
"wires": [
[
"caa89ac5ff78ec74"
],
[
"491e5677a637ada1"
],
[
"679ed6bfd56f36a7"
],
[
"679ed6bfd56f36a7"
],
[]
]
},
{
"id": "c470eff60f50fb49",
"type": "switch",
"z": "b3b5ee615be88a64",
"name": "",
"property": "bufferLenght",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "61",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 570,
"y": 180,
"wires": [
[
"1eaae525a714f81e"
]
]
},
{
"id": "e6795241b9ee3e8b",
"type": "ui_text",
"z": "b3b5ee615be88a64",
"group": "8842a890ac60c5e8",
"order": 3,
"width": 0,
"height": 0,
"name": "",
"label": "Charge level",
"format": " {{msg.chargeLevelPercentage}} %",
"layout": "row-spread",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 1310,
"y": 180,
"wires": []
},
{
"id": "bf8eb27e06702901",
"type": "ui_text",
"z": "b3b5ee615be88a64",
"group": "8842a890ac60c5e8",
"order": 2,
"width": 0,
"height": 0,
"name": "",
"label": "{{msg.label}}",
"format": "{{msg.power}} W",
"layout": "row-spread",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 1530,
"y": 240,
"wires": []
},
{
"id": "2baa2e769606025e",
"type": "ui_switch",
"z": "b3b5ee615be88a64",
"name": "",
"label": "Battery status",
"tooltip": "",
"group": "8842a890ac60c5e8",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "topic",
"topicType": "msg",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"animate": false,
"className": "",
"x": 1320,
"y": 80,
"wires": [
[]
]
},
{
"id": "caa89ac5ff78ec74",
"type": "change",
"z": "b3b5ee615be88a64",
"name": "convert status 0/1 to on/off",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "0",
"fromt": "num",
"to": "false",
"tot": "bool"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "1",
"fromt": "num",
"to": "true",
"tot": "bool"
},
{
"t": "set",
"p": "enabled",
"pt": "msg",
"to": "false",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1080,
"y": 80,
"wires": [
[
"2baa2e769606025e"
]
]
},
{
"id": "491e5677a637ada1",
"type": "function",
"z": "b3b5ee615be88a64",
"name": "battery level Wh and %",
"func": "let chargeLevelWh = msg.payload;\nlet chargeLevelPercentage = Math.round((chargeLevelWh/7000)*100);\nmsg.chargeLevelPercentage = chargeLevelPercentage;\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1070,
"y": 140,
"wires": [
[
"46fb8d0694786dbf",
"e6795241b9ee3e8b"
]
]
},
{
"id": "a35942da16b6eb11",
"type": "function",
"z": "b3b5ee615be88a64",
"name": "power and label",
"func": "let currentPower = msg.payload[0];\nlet direction = msg.payload[1];\nlet label;\n\nswitch(direction){\n case 52:\n label = \"Discharging power\";\n break;\n\n case 53:\n label = \"Charging power\";\n\n if(currentPower==0) {\n label = \"Idle\";\n }\n\n break;\n\n default:\n label = \"\";\n\n}\n\nmsg.power = currentPower;\nmsg.label = label;\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1380,
"y": 240,
"wires": [
[
"bf8eb27e06702901"
]
]
},
{
"id": "679ed6bfd56f36a7",
"type": "join",
"z": "b3b5ee615be88a64",
"name": "combine power level and direction msg",
"mode": "custom",
"build": "array",
"property": "payload",
"propertyType": "msg",
"key": "combined",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "num",
"reduceFixup": "",
"x": 1120,
"y": 240,
"wires": [
[
"a35942da16b6eb11"
]
]
},
{
"id": "46fb8d0694786dbf",
"type": "ui_gauge",
"z": "b3b5ee615be88a64",
"name": "",
"group": "8842a890ac60c5e8",
"order": 4,
"width": 0,
"height": 0,
"gtype": "wave",
"title": "Charge level Wh",
"label": "Wh",
"format": "{{value}}",
"min": 0,
"max": "7000",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 1330,
"y": 140,
"wires": []
},
{
"id": "3de6baa54a48cb27",
"type": "function",
"z": "b3b5ee615be88a64",
"name": "filter len 61 buffers only",
"func": "var buf = Buffer.from(msg.payload);\nmsg.bufferLenght = buf.length;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 390,
"y": 180,
"wires": [
[
"c470eff60f50fb49"
]
]
},
{
"id": "8842a890ac60c5e8",
"type": "ui_group",
"name": "Status",
"tab": "8f36175210262f11",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "8f36175210262f11",
"type": "ui_tab",
"name": "Grid Battery",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]