HSL public transport vehicle locations through Open API

Uses public mqtt API and puts trafic into worldmap.

[{"id":"eb89d20e.80ad7","type":"mqtt-broker","broker":"mqtt.hsl.fi","port":"1883","clientid":""},{"id":"51a0d6.314d5f2c","type":"websocket-listener","path":"/ws/worldmap","wholemsg":"false"},{"id":"7ceea90f.5baac8","type":"worldmap","name":"","x":465.8541946411133,"y":125.30556869506836,"z":"8f216ca4.df9c7","wires":[]},{"id":"2522acde.dfe564","type":"websocket out","name":"","server":"51a0d6.314d5f2c","client":"","x":492.8541946411133,"y":48.055559158325195,"z":"8f216ca4.df9c7","wires":[]},{"id":"92696722.a8e9b8","type":"inject","name":"Map center to Helsinki","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"x":170.50003051757812,"y":46.444443702697754,"z":"8f216ca4.df9c7","wires":[["2522acde.dfe564"]]},{"id":"954adec.b86ee2","type":"mqtt in","name":"HSL open API","topic":"/hfp/journey/#","broker":"eb89d20e.80ad7","x":116.59944152832031,"y":120.09091472625732,"z":"8f216ca4.df9c7","wires":[["5c403301.5bb7fc"]]},{"id":"5c403301.5bb7fc","type":"function","name":"Parse","func":"var data=JSON.parse(msg.payload);\nvar thing = {\n    name:data.VP.veh, \n    lat:data.VP.lat, \n    lon:data.VP.long,\n    icon:\"car\",\n    iconColor:\"red\",\n    extrainfo:data.VP.desi\n};\nmsg.payload=thing;\nreturn msg;","outputs":1,"noerr":0,"x":271.84946060180664,"y":119.34091377258301,"z":"8f216ca4.df9c7","wires":[["2522acde.dfe564"]]}]
mikakaraila

Flow Info

created 11 months, 1 week ago

Node Types

Core
  • function (x1)
  • inject (x1)
  • mqtt in (x1)
  • mqtt-broker (x1)
  • websocket out (x1)
  • websocket-listener (x1)
Other

Tags

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