I have a USB stick in a RasPi.
I want to keep a eye on how full it is. I do that with the drive
node.
But.... (And isn't there always a but?)
The output is an array.
I noticed that I wasn't getting a result for the USB stick memory usage recently.
The position in the array for the USB stick has changed from 9
to 8
.
Basic code:
[{"id":"7ff716d6.e21418","type":"inject","z":"aa48e352.9ad2f8","name":"Start / test","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":680,"y":2690,"wires":[["6577d12.52626b"]]},{"id":"6577d12.52626b","type":"Drives","z":"aa48e352.9ad2f8","name":"","x":630,"y":2770,"wires":[["782006fd.3e7dd","993a88f2.a45528"]]},{"id":"782006fd.3e7dd","type":"function","z":"aa48e352.9ad2f8","name":"","func":"var used = msg.payload[8].capacity;\nmsg.payload = used * 100;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":2770,"wires":[["ef0a36fd.aa9b7","5b576c7e.3b7f74","757c403.9cec9c","454f45f.552593c"]]},{"id":"5b576c7e.3b7f74","type":"debug","z":"aa48e352.9ad2f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1040,"y":2690,"wires":[]}]
Without making it too complicated how can I get it to track the USB and not having to change the code in the function
node?
Because what I have to do is look at the message
out of the node and open each one to see which is the USB drive and change the function
node to that number.