@pautorras
No offence intended, but that function code tells me you are a bit inexperienced with JavaScript.
So I will try one last attempt to sway you to buffer-parser.
NOTE: without knowing what bits & bytes make up those properties, I have just assigned each byte to a property (and had to add 2 bytes to the buffer).
but just to demonstrate you can avoid all this looping and manual conversion, here is a quick demo...
demo flow...
[{"id":"327126db.93d1ca","type":"buffer-parser","z":"4fed65e5.e87b3c","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int8","name":"BNBA3=>OnOff","offset":0,"length":1,"offsetbit":16,"scale":"1","mask":""},{"type":"int8","name":"BNBA3=>OpTime","offset":1,"length":1,"offsetbit":16,"scale":"1","mask":""},{"type":"int8","name":"BNBA3=>Volt","offset":2,"length":1,"offsetbit":16,"scale":"1","mask":""},{"type":"int8","name":"BNBA3=>Amp","offset":3,"length":1,"offsetbit":16,"scale":"1","mask":""},{"type":"int8","name":"LSA3=>H","offset":4,"length":1,"offsetbit":16,"scale":"1","mask":""},{"type":"int8","name":"LSA3=>M","offset":5,"length":1,"offsetbit":16,"scale":"1","mask":""},{"type":"int8","name":"LSA3=>L","offset":6,"length":1,"offsetbit":16,"scale":"1","mask":""},{"type":"int8","name":"LSA3=>LAlarm","offset":7,"length":1,"offsetbit":16,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":710,"y":160,"wires":[["48b72cde.b5bbb4","91d955b3.6ef278"]]},{"id":"302044c6.a2fe3c","type":"inject","z":"4fed65e5.e87b3c","name":"PLC data (faked) [ 12, 33, 26, 77, 91, 21, 0, 0 ]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[ 12, 33, 26, 77, 91, 21, 0, 0 ]","payloadType":"bin","x":790,"y":100,"wires":[["327126db.93d1ca"]]},{"id":"48b72cde.b5bbb4","type":"change","z":"4fed65e5.e87b3c","name":"store BNBA3 in global BNBA3","rules":[{"t":"set","p":"BNBA3","pt":"global","to":"payload.BNBA3","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":220,"wires":[[]]},{"id":"91d955b3.6ef278","type":"debug","z":"4fed65e5.e87b3c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":160,"wires":[]}]