Sustainable Weather API

Hey everyone, so Dark Sky just got bought by Apple so my weather API will discontinue soon. This is happening not long after Wunderground got bought which is why I switched to Dark Sky in the first place.

WTF.

Is there a weather service with existing node packages in the pallette from a company that ISNT about to get purchased like google or amazon?

1 Like

OpenWeatherMap offers a free service (with a limit of 60 samples per minute).
I've been using it with my IoT students for nearly 3-years.

Here's a link to the NR node.

Thanks! The documentation doesnt suggest it has "chance of rain." Can you confirm that? Thats the most critical weather info in my opinion, Id be upset to lose that.

Hi Sean, which region are you in? I’ve always seen pretty good results for precipitation within Europe with the api.met.no. I’m currently working on porting my Python code to a subflow, as now that they’re officially supporting JSON it’s a lot easier than with xml parsing that it was before.

I don't believe OWM offers that (chance of rain) - sorry.

I am in the US

Most other API's dont either it seems, I must be ignorant to how these weather stations get their data because that seems like such a basic level variable to me. Quite upset about the Dark Sky sellout lol.

Thank you for your suggestion!

This one has always been open
https://api.met.no

Not sure how detailed it is for US but quite nice for Europe

1 Like

ROFL - exactly same feeling here too!

This is the platform 'home assistant' installed by default recently when we all updated to 0.105.
Screenshot_30

I was after rain info too and got OWM up and running only to find there is no rain info :roll_eyes:.

I had a thought that maybe there is some kinda open source api site where people share their personal weather station info too that maybe we could tap into someone close bys previous rainfall (obviously won't help with prediction info).

Have a look at this flow it gives you the examples and stuff to play around with to drill down as far as you want (BOM data for Australia - Sydney specifically here)

[{"id":"abf50d7c.40176","type":"inject","z":"24b0536b.d98bdc","name":"Additional Info","topic":"","payload":"ftp://ftp.bom.gov.au/anon/gen/fwo/IDV10753.xml","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":170,"y":140,"wires":[["a99e064e.0ca198"]]},{"id":"a99e064e.0ca198","type":"exec","z":"24b0536b.d98bdc","command":"curl","addpay":true,"append":"","useSpawn":"false","timer":"","name":"","x":360,"y":140,"wires":[["b1ce1967.985878","b50722ca.50bd3"],[],[]]},{"id":"b1ce1967.985878","type":"xml","z":"24b0536b.d98bdc","name":"","property":"payload","attr":"","chr":"","x":490,"y":120,"wires":[["cfca11f5.92405","7d2cf06d.2a796"]]},{"id":"cfca11f5.92405","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.product.forecast[0].area[2]","x":750,"y":180,"wires":[]},{"id":"7d2cf06d.2a796","type":"change","z":"24b0536b.d98bdc","name":"Get Forecast","rules":[{"t":"move","p":"payload.product.forecast[0].area[2]","pt":"msg","to":"weather","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"(\t \t    $weather := payload.product.forecast[0].area[2].\"forecast-period\";\t    $date := $weather.{\t       \"date\": $.\"$\".\"start-time-local\"\t    };\t    $elem := $weather.[element].{\t       $.\"$\".type: $.\"_\" & ($.\"$\".units ? \"°\" & $.\"$\".units.$substring(0,1) : \"\")\t    };\t    $text := $weather.[text].{\t       $.\"$\".type: $.\"_\"\t    };\t    $zip($date, $elem, $text).$merge($)\t\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":260,"wires":[["790c0d98.5c5eb4","9b1af07b.05ee4","2c1539ed.f55c66","681a0fbe.c3213","6cc31bb5.6ac9d4","7df42c64.4afe64","20d3688e.ab5a18","967bee1c.c7a1c","f04ea368.931fa"]]},{"id":"790c0d98.5c5eb4","type":"debug","z":"24b0536b.d98bdc","name":"Whole Object","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","x":1020,"y":260,"wires":[]},{"id":"a909a55a.a9aba8","type":"inject","z":"24b0536b.d98bdc","name":"Sydney","topic":"","payload":"ftp://ftp2.bom.gov.au/anon/gen/fwo/IDN10064.xml","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":150,"y":220,"wires":[["a99e064e.0ca198"]]},{"id":"b50722ca.50bd3","type":"function","z":"24b0536b.d98bdc","name":"TryXML2Json","func":"/* \nVersion: 1.0\nDate: 17 Mar 2017\nAuthor: BP Orpin\nTo use this node install xml2json.\nsudo npm install xml2json\nDo not install it globally\nEdit settings.js to 'require' the module\n*/\n \n// get an instance of the module\nvar parser = context.global.get('xml2json');\n// set the options\nvar options = {\n    object: true, //returns a JSON object\n    reversible: false,\n    coerce: false,\n    sanitize: true,\n    trim: true,\n    arrayNotation: false,\n    alternateTextNode: false\n};\n \n// xml to json \nvar json = parser.toJson(msg.payload, options);\n \nmsg.payload = json;\n \nreturn msg;","outputs":1,"noerr":0,"x":440,"y":520,"wires":[["e7d53bf7.cf8f58","419f1c27.58b974","8d0530df.6c7bc"]]},{"id":"e7d53bf7.cf8f58","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":420,"wires":[]},{"id":"419f1c27.58b974","type":"debug","z":"24b0536b.d98bdc","name":"Sydney","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.product.forecast.area[2]","x":680,"y":540,"wires":[]},{"id":"9b1af07b.05ee4","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload[1].date","x":1030,"y":320,"wires":[]},{"id":"2c1539ed.f55c66","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"weather[\"forecast-period\"][7]","x":1100,"y":380,"wires":[]},{"id":"681a0fbe.c3213","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"weather[\"forecast-period\"][7].text[1]._","x":1110,"y":440,"wires":[]},{"id":"f04ea368.931fa","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"weather[\"forecast-period\"][0].text[1]._","x":1100,"y":640,"wires":[]},{"id":"967bee1c.c7a1c","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"weather[\"forecast-period\"][1].text[1]._","x":1100,"y":600,"wires":[]},{"id":"20d3688e.ab5a18","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"weather[\"forecast-period\"][4.text[1]._","x":1100,"y":560,"wires":[]},{"id":"6cc31bb5.6ac9d4","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"weather[\"forecast-period\"][6].text[1]._","x":1100,"y":480,"wires":[]},{"id":"7df42c64.4afe64","type":"debug","z":"24b0536b.d98bdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"weather[\"forecast-period\"][5].text[1]._","x":1100,"y":520,"wires":[]},{"id":"8d0530df.6c7bc","type":"debug","z":"24b0536b.d98bdc","name":"Rain %","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.product.forecast.area[2][\"forecast-period\"][0].text[1].$t","targetType":"msg","x":640,"y":680,"wires":[]}]

Craig

Just found out about the Dark Sky buyout. My first reaction was that this was not great news for those of us who like things a bit more open!

However...

Looks like this will be a great opportunity to check out the current crop of weather APIs. Openweathermap looks good for me as they are UK based. Good to see they use personal weather stations in their mix.
The web seems full of guides on how to migrate across to competitors so looks like their will be some benefits for both weather companies and weather watchers alike.

Good luck to Apple with their new purchase. Guess it will sit alongside some of their other great products like.... Apple maps :slight_smile:

1 Like

Do I sense sarcasm :laughing:

2 Likes

Ah yes. Thank you for noticing my feeble attempt at humour.

1 Like

If you need data for a specific country, consider cutting out the middleman and going to the government weather site. A few years back, I remember looking for an API I could call hourly to get a temperature update for an orb that changed LED color based on temperature. I remember I used openweathermap because, on the surface, it seemed the easiest. I remember reading on their site (at that time - this was several years ago) something like a 99% uptime. As I recall, I had trouble getting it to select a specific airport I was interested in - it was set up I think to use city name. Once I got around this, I started seeing outages from time to time. Perhaps it was only 1% of the time (or whatever the specs said), but it was annoying and seemed to happen for no reason (no specific adverse weather or anything). Then there was a note that said if I needed 100% uptime I could upgrade to a paid plan. This ticked me off, because it seemed like the outages were being added deliberately to get people to pay. I re-wrote my app to access the feed from the National Weather Service directly. Sure, I have to parse the XML data myself, but it is not that big of a deal.

If you are in the US, you can go to the following URL to browse observations by state. Once you have the station you are interested in, you can query it directly from your app, and parse the XML easily.

https://w1.weather.gov/xml/current_obs/

I'm not trying to badmouth openweathermap - maybe things are different today - but the question is, why have a middleman when you can go directly to the source? Of course, if you need reports from multiple countries, then a middleman probably makes sense to provide a consistent querying interface.

The National Weather Service has an API...

https://www.weather.gov/documentation/services-web-api

A few things to keep in mind:

  1. You have to do a little bit of work to get the information you want. (ie. you have to find your station or grid point using your lat/lon coordinates, which isn't hard if you follow their "guide" on the link above.)
  2. You have to set the header user agent with an email address and website.
  3. I've been using it for a bit and I've noticed that the API doesn't consistently present the information... or the info is in different parts of the array depending on the time of day.
    For example
  • 10am - 12pm
    msg.payload.properties.periods[0].name will be "today" and msg.payload.properties.periods[1].name will be 'tonight",
  • but after (usually) 7pm
    msg.payload.properties.periods[0].name will be "tonight" and
    msg.payload.properties.periods[1].name will be "tuesday" (or the next day's name)

Which can be frustrating...

Otherwise the NWS Api works great! (though if you want to use the icons i would suggest using the "large" icons instead of medium, the just look better.)

edit: added #2 because it was something that kept me at my wits end until I figured it out.

UK Metoffice has some free API's

They are quite technical though I think. Not tried them for a while.

Some people have also said that the Norwegian service is good.

Ah, that reminds me, I wrote some basic test code to use the Met Office API a couple of years ago. It was fairly simple to use, as far as I recall, and it might be interesting to revisit it as a side project.

Is that just for forecast data (not current conditions?)

I signed-up for their 'Basic' account (FREE) this morning.
Here's a link to the APIs.

https://metoffice.apiconnect.ibmcloud.com/metoffice/production/api

Hourly spot data looks like the most recent results you can get for FREE.

1 Like

360 calls a day. You have to specify an OAuth endpoint but it doesn't really matter what you put in it, it doesn't get used for Node-RED.

Bit of a pain to get the app registered in order to be able to use the API, had to go round the loop a couple of times in order to get all of the parameters together.

  • Register
  • Respond to the email
  • Select the API
  • "Subscribe"
  • Register the app using the "basic" (free) subscription
  • go back to the API docs, fill in the secret and other parameters to test it
  • take the client ID & client secret to put into your flow along with the other params.
  • build an http-request flow inserting msg.header as well as the query params. Set the request node's output to JSON
  • Enjoy your weather data!

Just a note about locations though. For me, my detailed lat/lon details are translated to a point 2 mi away. While that doesn't sound like much, in a city like Sheffield, the weather can be significantly different over a very short distance. You might need to play with the location settings to get something that best reflects your location.