Weather reports to SMS and MQTT topic

I've setup a couple of flows to read weather forecast info from the BBC weather site using RSS. The feeds are specific to my location so should be changed for your own. The output is directed to 2 nodes, one for Twilio to send a SMS, the other to publish to a MQTT topic that in my case has a printer listening to it.

To get the correct RSS feeds, visit the BBC weather site, http://www.bbc.co.uk/weather/, select your location and click on the RSS logo, there are 2 links, one for Next day, the other for 3 day observations. Observations is used for the current conditions node and 3 days URL is used for the next day forecast node.

The Parse weather and Parse forecast nodes create the appropriate output topic and payloads for the 2 different output nodes. The Twilio node needs the phone number in the topic in order to send the message.

[{"id":"3fd7311e.c028ce","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"a968646d.569798","type":"inject","name":"Get Weather","topic":"","payload":"1","repeat":"0","crontab":"15 6 * * *","once":false,"x":124,"y":365,"z":"22fdfba5.dd0204","wires":[["6fac9031.90537"]]},{"id":"6fac9031.90537","type":"http request","name":"BBC Weather current conditions","method":"GET","url":"http://open.live.bbc.co.uk/weather/feeds/en/2636049/observations.rss","x":326,"y":365,"z":"22fdfba5.dd0204","wires":[["f99774f4.066888"]]},{"id":"f99774f4.066888","type":"xml2js","useEyes":false,"name":"","x":554,"y":364,"z":"22fdfba5.dd0204","wires":[["fc39496b.03c6b8"]]},{"id":"fc39496b.03c6b8","type":"function","name":"Parse Weather","func":"// Parse forecast and send to Twilio SMS and mqtt topic\n\nvar weatherChannel = msg.payload.rss.channel[0];\nvar pubDate = weatherChannel.item[0].pubDate[0];\nvar description = weatherChannel.item[0].description[0];\nvar mqttMsg = { topic: \"nodered/printer\", payload: pubDate + \"\\n\" + description };\nvar smsMsg = { topic: \"+44YOUR_MOBILE\", payload: pubDate + \"\\n\" + description };\n\nreturn [mqttMsg, smsMsg];","outputs":"2","x":738,"y":364,"z":"22fdfba5.dd0204","wires":[["42902f9a.bd6fd"],["f2bea1ba.0d416"]]},{"id":"a6f692fc.59097","type":"http request","name":"BBC Weather Next Day forecast","method":"GET","url":"http://open.live.bbc.co.uk/weather/feeds/en/2636049/3dayforecast.rss","x":368,"y":421,"z":"22fdfba5.dd0204","wires":[["6987a4d2.96785c"]]},{"id":"e0ebc595.1f1438","type":"inject","name":"Next Day Forcecast","topic":"","payload":"","repeat":"0","crontab":"00 21 * * *","once":false,"x":131,"y":420,"z":"22fdfba5.dd0204","wires":[["a6f692fc.59097"]]},{"id":"6987a4d2.96785c","type":"xml2js","useEyes":false,"name":"","x":577,"y":420,"z":"22fdfba5.dd0204","wires":[["247c6996.db8396"]]},{"id":"247c6996.db8396","type":"function","name":"Parse Forecast","func":"// Parse forecast and send to Twilio SMS and mqtt topic\n\nvar weatherChannel = msg.payload.rss.channel[0];\nvar day1 = weatherChannel.item[1];\nvar title = day1.title[0];\nvar description = day1.description[0];\nvar mqttMsg = { topic: \"nodered/printer\", payload: title };\nvar smsMsg = { topic: \"+44YOUR_MOBILE\", payload: title };\nreturn [mqttMsg, smsMsg];\n","outputs":"2","x":742,"y":420,"z":"22fdfba5.dd0204","wires":[["42902f9a.bd6fd"],["f2bea1ba.0d416"]]},{"id":"42902f9a.bd6fd","type":"mqtt out","name":"Send to Printer","topic":"nodered/printer","broker":"3fd7311e.c028ce","x":986,"y":428,"z":"22fdfba5.dd0204","wires":[]},{"id":"f2bea1ba.0d416","type":"twilio out","title":"Send SMS","name":"TwilioSMS","x":977,"y":358,"z":"22fdfba5.dd0204","wires":[]}]

Flow Info

Created 11 years ago
Updated 9 years, 3 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • function (x2)
  • http request (x2)
  • inject (x2)
  • mqtt out (x1)
  • mqtt-broker (x1)
Other
  • twilio out (x1)
  • xml2js (x2)

Tags

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