Get Twitter Lat. and Lon. of a tweet, interprets with Weather Insights and tweet the actual temperature

Get tweets with a specific "#" - words are not necessary - Twitter give us the location of the tweet. With it we use http://www.findlatitudeandlongitude.com to get the coordinates for the specific city of the user. It returns latitude and longitude in an array, we convert to float and get the payloads [0] and [1] representing latitude and longitude we sent. After it we send the data to Weather Insights, it returns a JSON, this case we want just the temperature: msg.observation.metric.temp Note: I also change the node function to re-tweet to the person who asked the information.

[{"id":"f8c57383.3f8338","type":"html","z":"1556b725.384cc1","name":"","tag":"#lat_dec span.value, #lon_dec span.value","ret":"text","as":"single","x":575,"y":158,"wires":[["de80fbaf.5a2a1"]]},{"id":"de80fbaf.5a2a1","type":"function","z":"1556b725.384cc1","name":"","func":"msg.newpayload = parseFloat(msg.payload[0]) + \",\" + parseFloat(msg.payload[1]);\n\nreturn msg","outputs":1,"noerr":0,"x":860,"y":158,"wires":[["2113e957.99ae9e"]]},{"id":"2113e957.99ae9e","type":"change","z":"1556b725.384cc1","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"newpayload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":211,"y":310,"wires":[["13fb04bf.be77b3"]]},{"id":"13fb04bf.be77b3","type":"weather_insights","z":"1556b725.384cc1","name":"","service":"/api/weather/v2/observations/current","geocode":"","units":"m","language":"en-US","x":442,"y":308,"wires":[["f6134782.1b3178"]]},{"id":"f6134782.1b3178","type":"function","z":"1556b725.384cc1","name":"","func":"msg.payload= \"@\" + msg.topic.slice(7,30) + \" Temperature of your location: \" + msg.observation.metric.temp;\nreturn msg;","outputs":1,"noerr":0,"x":647,"y":314,"wires":[["19ede94d.b91b17"]]},{"id":"62794ee0.7da218","type":"twitter in","z":"1556b725.384cc1","twitter":"","tags":"pp_temp","user":"false","name":"pp_temp","topic":"tweets","x":117,"y":159,"wires":[["5592dd40.3d33ac"]]},{"id":"5592dd40.3d33ac","type":"http request","z":"1556b725.384cc1","name":"long and lat","method":"GET","ret":"txt","url":"http://www.findlatitudeandlongitude.com/?loc={{location.place}}","x":293,"y":159,"wires":[["f8c57383.3f8338"]]},{"id":"19ede94d.b91b17","type":"twitter out","z":"1556b725.384cc1","twitter":"","name":"Tweet","x":824,"y":323,"wires":[]}]
priscillaparodi

Flow Info

created 1 year ago

Node Types

Core
  • change (x1)
  • function (x2)
  • html (x1)
  • http request (x1)
  • twitter in (x1)
  • twitter out (x1)
Other

Tags

  • weather_insights
  • tweet
  • twitter
  • temperature
  • latitude
  • longitude
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option