WISE 4060 (advantech) to node red

Hello,

i'am using Node red to receive the massage from my wise 4060 using modbus tcp . it works wen i instal de modbus tcp with the wise 4060 as modbus server and link to a debug note. i get the following message

Wise : msg.payload : array[8]
[ false, false, false, false, false, false, false, false ]

Wen i klik on this link i get

Wise : msg.payload : array[8]
array[8]
0: false
1: false
2: false
3: false
4: false
5: false
6: false
7: false

is there away to split this array string so i can give a action to 1 if this status chance to true

thanks Ron

Hi Ron,

you can use the power of javascript and convert and split the array of Booleans and send each modbus status to seperate output. Im not exactly sure if this what you need but here it goes :

image

let arr = msg.payload;
let binary = arr.map(el => el ? {payload: 1} : {payload: 0})

return binary;

Test flow :

[{"id":"7b2ea4f4.08c55c","type":"inject","z":"4d675784.11e12","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[ false, true, false, true, true, false, false, false ]","payloadType":"jsonata","x":380,"y":800,"wires":[["e7a930e0.6897d8","c01d20cc.bd17c"]]},{"id":"e7a930e0.6897d8","type":"function","z":"4d675784.11e12","name":"","func":"\nlet arr = msg.payload;\n\nlet binary = arr.map(el => el ? {payload: 1} : {payload: 0})\n\n//return [binary[0], binary[1], binary[2], binary[3], binary[4], binary[5], binary[6], binary[7]];\nreturn binary;","outputs":8,"noerr":0,"initialize":"","finalize":"","x":560,"y":800,"wires":[["dd1bcd50.4ee92"],["c2b571a8.0c2198"],["71bef607.0c3af8"],["d37938ef.23d718"],["56483803.b5933"],["1bcd9bfe.040c44"],["461219b3.7b703"],["51ac1099.d8d65"]]},{"id":"dd1bcd50.4ee92","type":"debug","z":"4d675784.11e12","name":"output 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":680,"wires":[]},{"id":"c2b571a8.0c2198","type":"debug","z":"4d675784.11e12","name":"output 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":720,"wires":[]},{"id":"71bef607.0c3af8","type":"debug","z":"4d675784.11e12","name":"output 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":760,"wires":[]},{"id":"d37938ef.23d718","type":"debug","z":"4d675784.11e12","name":"output 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":800,"wires":[]},{"id":"56483803.b5933","type":"debug","z":"4d675784.11e12","name":"output 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":840,"wires":[]},{"id":"1bcd9bfe.040c44","type":"debug","z":"4d675784.11e12","name":"output 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":880,"wires":[]},{"id":"461219b3.7b703","type":"debug","z":"4d675784.11e12","name":"output 7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":920,"wires":[]},{"id":"51ac1099.d8d65","type":"debug","z":"4d675784.11e12","name":"output 8","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":960,"wires":[]},{"id":"c01d20cc.bd17c","type":"debug","z":"4d675784.11e12","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":455,"y":700,"wires":[],"l":false}]

More info on array map

2 Likes

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