GoogleAPI request travle time & save to influxDB

I was inspired by a flow/video from User: @nygma2004 for an new project idea with my Node-Red. Basicaly he uses Node-Red for requesting the Google API and getting the travle time form home to work. My idea was then to request the data from the Google API and save them in InfluxDB for further analytics.

Actual i visualize it in Grafana so i know when normaly traffic starts in the morning.

Node-Red Flow:GoogleAPI request and store in influxDB

Grafana Visualisation:Visualize influxDB in Grafana

[{"id":"80d5d518.4ca0b","type":"http request","z":"a6d40943.974d4","name":"Travel to work","method":"GET","ret":"txt","paytoqs":false,"url":"https://maps.googleapis.com/maps/api/distancematrix/json?origins=Haarer+Weg+2+85630+Grasbrun+VC&destinations=Ludwigsfelder+Str+85+80997+M%C3%BCnchen&key={your google api key}&mode=driving&units=metric&departure_time=now","tls":"","proxy":"","authType":"","x":680,"y":400,"wires":[["c162e379.b586f8"]]},{"id":"c162e379.b586f8","type":"json","z":"a6d40943.974d4","name":"","x":850,"y":400,"wires":[["4985da12.9d1f5c","ca2e507d.c672e8","cca70e93.2c74d"]]},{"id":"4985da12.9d1f5c","type":"change","z":"a6d40943.974d4","name":"","rules":[{"t":"move","p":"payload.rows[0].elements[0].duration_in_traffic.value","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"duration_in_traffic","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":360,"wires":[["8d9c7218.8ae548"]]},{"id":"1c6d963d.9f3e8a","type":"influxdb out","z":"a6d40943.974d4","influxdb":"4a8ed10d.a5189","name":"Statistics","measurement":"travle_allach","precision":"","retentionPolicy":"","x":1460,"y":400,"wires":[]},{"id":"d314e890.b3b85","type":"bigtimer","z":"a6d40943.974d4","outtopic":"","outpayload1":"","outpayload2":"","name":"Big Timer","comment":"","lat":"47.9922","lon":"12.0053","starttime":"270","endtime":"630","starttime2":"0","endtime2":"0","startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":false,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":220,"y":400,"wires":[[],["4b874c8a.992e6c"],[]]},{"id":"dc449fb.c000b6","type":"join","z":"a6d40943.974d4","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"10","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":490,"y":400,"wires":[["80d5d518.4ca0b"]]},{"id":"4b874c8a.992e6c","type":"switch","z":"a6d40943.974d4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":400,"wires":[["dc449fb.c000b6"],[]]},{"id":"c7dda87d.f9ea3","type":"inject","z":"a6d40943.974d4","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":340,"wires":[["80d5d518.4ca0b"]]},{"id":"ca2e507d.c672e8","type":"change","z":"a6d40943.974d4","name":"","rules":[{"t":"move","p":"payload.rows[0].elements[0].duration.value","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"duration","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":400,"wires":[["8d9c7218.8ae548"]]},{"id":"cca70e93.2c74d","type":"change","z":"a6d40943.974d4","name":"","rules":[{"t":"move","p":"payload.rows[0].elements[0].distance.value","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"distance","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":440,"wires":[["8d9c7218.8ae548"]]},{"id":"8d9c7218.8ae548","type":"join","z":"a6d40943.974d4","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1270,"y":400,"wires":[["1c6d963d.9f3e8a"]]},{"id":"4a8ed10d.a5189","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"statistics","name":"","usetls":false,"tls":""}]

Flow Info

Created 5 years, 8 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x3)
  • http request (x1)
  • inject (x1)
  • join (x2)
  • json (x1)
  • switch (x1)
Other
  • bigtimer (x1)
  • influxdb (x1)
  • influxdb out (x1)

Tags

Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option