Calculate rain precipitation from URL with columns

Via the URL https://gpsgadget.buienradar.nl/data/raintext/?lat=52.37&lon=4.89 I can get the expected rainfall for the next two hours for a GPS location. This is shown in two columns, the amount of precipitation on the left and the time per 5 minutes on the right.

Although I get a JSON Parse Error I can request the two columns in NR with a http request (see attachment).

I would like to calculate the rainfall for the next hour so I have to add the first twelve values from the left column. Can someone explain to me how I can properly request the data and then calculate the rainfall for the next hour?

Its not JSON so switch that option off.
Next try feeding the payload to a split node.

Thanks Steve, the JSON error is not showing anymore. I've added the split node and now the rows are shown separately (see attachment).

I have too little experience with NR to work this out further, so I hope someone can explain to me exactly how to do this.

Could you export your flow and

```
paste it between backticks like this
```

Myself or another kind member will help you out

Thanks again! Would be great if someone can help me out :wink:

[{"id":"c0785c86.682e","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"a322a220.a74e9","type":"http request","z":"c0785c86.682e","name":"GET Data","method":"GET","ret":"txt","paytoqs":false,"url":"https://gpsgadget.buienradar.nl/data/raintext/?lat=52.37&lon=4.89","tls":"","persist":false,"proxy":"","authType":"","x":400,"y":100,"wires":[["b7bc2e91.ccb9a"]]},{"id":"7d17f83d.1d5638","type":"inject","z":"c0785c86.682e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":100,"wires":[["a322a220.a74e9"]]},{"id":"6df9daa3.ba89a4","type":"debug","z":"c0785c86.682e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":100,"wires":[]},{"id":"b7bc2e91.ccb9a","type":"split","z":"c0785c86.682e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"topic","x":570,"y":100,"wires":[["6df9daa3.ba89a4"]]}]

To get you started...
image

[{"id":"c18a41c1.78301","type":"http request","z":"c90da02f.d57d2","name":"GET Data","method":"GET","ret":"txt","paytoqs":false,"url":"https://gpsgadget.buienradar.nl/data/raintext/?lat=52.37&lon=4.89","tls":"","persist":false,"proxy":"","authType":"","x":740,"y":100,"wires":[["745545df.f5010c"]]},{"id":"5bfe12a7.97f05c","type":"inject","z":"c90da02f.d57d2","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":580,"y":100,"wires":[["c18a41c1.78301"]]},{"id":"745545df.f5010c","type":"function","z":"c90da02f.d57d2","name":"split and map","func":"//first split each line into an array\nvar lines = msg.payload.trim().split(\"\\n\");\n\n//next map each element of the lines\n//array into an object with .time and .value\nvar errors = [];\nvar count = lines ? lines.length : 0;\nvar data = [];\nif(count){\n    data = lines.map((e) =>{\n        try{\n            let parts = e.split(\"|\");\n            return {\n                time: parts[1].trim(),\n                value: parseInt(parts[0])\n            }        \n        } catch(error) {\n            errors.push(\"Error splitting '\" + e + \"': \" + error)\n        }\n    })   \n}\n\n//return the data\nmsg.payload = {\n    count,\n    errors,\n    data\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":180,"wires":[["9b0d5e51.65864"]]},{"id":"9b0d5e51.65864","type":"debug","z":"c90da02f.d57d2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":740,"y":180,"wires":[]}]

Hi Steve,

Very helpfull and appreciated, thanks!

Best regards, Hans.

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