Calculations HTTP Request received data string

Because I have little experience with NodeRED, I run into a problem. With an HTTP Request I retrieve the data as in the graphic, a left column with 24 values and a right column with 24 times.

I want to add the first 3 values of the left column (green square) to be processed further. In the example, that value would be 154.

Can someone tell me how to do that?

[{"id":"a7ca5e83.ddd39","type":"tab","label":"Rain","disabled":false,"info":""},{"id":"566ef5f9.d235fc","type":"inject","z":"a7ca5e83.ddd39","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":100,"wires":[["9fc6992c.30f8a8"]]},{"id":"9fc6992c.30f8a8","type":"http request","z":"a7ca5e83.ddd39","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://gpsgadget.buienradar.nl/data/raintext?lat=51&lon=3","tls":"","persist":false,"proxy":"","authType":"basic","x":350,"y":100,"wires":[["85f8de99.1bb49"]]},{"id":"85f8de99.1bb49","type":"debug","z":"a7ca5e83.ddd39","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":100,"wires":[]}]

There are multiple ways to do this, you could run the string throug a cvs node to convert to an array of objects then use Javascript or JSONata to sum the first 3 array values.
e.g.

[{"id":"566ef5f9.d235fc","type":"inject","z":"a7ca5e83.ddd39","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":80,"wires":[["e9b1d32a.56ac38"]]},{"id":"e9b1d32a.56ac38","type":"template","z":"a7ca5e83.ddd39","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"000|14:05\n077|14:10\n077|14:15\n092|14:20\n092|14:25","output":"str","x":250,"y":80,"wires":[["776da0a1.f6fc"]]},{"id":"776da0a1.f6fc","type":"csv","z":"a7ca5e83.ddd39","name":"","sep":"|","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"value,time","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":390,"y":80,"wires":[["25f6f6be.47474a"]]},{"id":"25f6f6be.47474a","type":"change","z":"a7ca5e83.ddd39","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$sum(payload[[0..2]].[$number(value)].*)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":140,"wires":[["85f8de99.1bb49"]]},{"id":"85f8de99.1bb49","type":"debug","z":"a7ca5e83.ddd39","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":140,"wires":[]}]
1 Like

I could not have imagined that or it would have cost me a lot of time and frustration. That's why I'm very glad you helped me, thank you!

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