Change node change payload from array to number

How to change message from

1/31/2021, 11:01:26 AMnode: 1afb97a5.247c08polling : msg.payload : array[8]

[ false, false, false, false, false, false, false, false ]
To 0

and

1/31/2021, 11:01:26 AMnode: 1afb97a5.247c08polling : msg.payload : array[8]

[ true, false, false, false, false, false, false, false ]
To 1

I tried several but no success image

image

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

https://nodered.org/docs/user-guide/messages


EDIT

I think i miss-read.

You want to set msg.paylod to "number zero" if it contains [ false, false, false, false, false, false, false, false ] ?

Perhaps this?...

demo flow...

[{"id":"93704910.d87f58","type":"inject","z":"766a1068.58afb","name":"[ true, false, false, false, false, false, false, false ]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[ true, false, false, false, false, false, false, false ]","payloadType":"json","x":320,"y":740,"wires":[["716e29a.fb62cd8"]]},{"id":"592b3e8.38b91c","type":"inject","z":"766a1068.58afb","name":"[ false, false, false, false, false, false, false, false ]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[ false, false, false, false, false, false, false, false ]","payloadType":"json","x":320,"y":700,"wires":[["716e29a.fb62cd8"]]},{"id":"716e29a.fb62cd8","type":"json","z":"766a1068.58afb","name":"","property":"payload","action":"","pretty":false,"x":600,"y":720,"wires":[["953c2964.cbced8"]]},{"id":"953c2964.cbced8","type":"switch","z":"766a1068.58afb","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"[false,false,false,false,false,false,false,false]","vt":"str"},{"t":"cont","v":"[true,false,false,false,false,false,false,false]","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":750,"y":720,"wires":[["2907ddef.853382"],["b6d7e003.016e8"]]},{"id":"2907ddef.853382","type":"change","z":"766a1068.58afb","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":700,"wires":[["2253905c.f66ee"]]},{"id":"b6d7e003.016e8","type":"change","z":"766a1068.58afb","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":740,"wires":[["5b51a92d.1044e8"]]},{"id":"2253905c.f66ee","type":"debug","z":"766a1068.58afb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1110,"y":700,"wires":[]},{"id":"5b51a92d.1044e8","type":"debug","z":"766a1068.58afb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1110,"y":740,"wires":[]},{"id":"2290b159.5d67de","type":"comment","z":"766a1068.58afb","name":"V1 (explicit)","info":"","x":220,"y":660,"wires":[]},{"id":"588fb527.0286ec","type":"inject","z":"766a1068.58afb","name":"[ false, false, false, false, false, false, false, false ]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[ false, false, false, false, false, false, false, false ]","payloadType":"json","x":320,"y":840,"wires":[["d9c7b496.f23338"]]},{"id":"b4b13926.859578","type":"inject","z":"766a1068.58afb","name":"[ true, false, false, false, false, false, false, false ]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[ true, false, false, false, false, false, false, false ]","payloadType":"json","x":320,"y":880,"wires":[["d9c7b496.f23338"]]},{"id":"d9c7b496.f23338","type":"change","z":"766a1068.58afb","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0] = true ? 1 : 0\t\t  ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":860,"wires":[["55e89d81.20b2f4"]]},{"id":"55e89d81.20b2f4","type":"debug","z":"766a1068.58afb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":860,"wires":[]},{"id":"41d1f450.daad9c","type":"comment","z":"766a1068.58afb","name":"V1 (only check first element)","info":"","x":260,"y":800,"wires":[]}]

Yes that worked, I used the 2nd version to check just the first element my case.
Thanks :ok_hand: