Weather Data using Node-Red and APIs

With the forthcoming descent of Dark Skies into an Apple-Only universe (a sad loss for the rest of us) I’ve been looking into alternative APIs to use for grabbing weather forecasts and related data. While I struggle with the MET Office behemoth, here’s a little information on yr.no

I’d not heard of them until this week so if this is new to you, don’t worry. The yr.no API is free to use, getting results is easy using Node-Red and useful for obtaining weather information, now and in the future and as a bonus, sunrise and sunset times for any place. Unlike more comprehensive and involved systems, yr.no lets you access this information by place name only, not longitude and latitude – after all do you really need weather, sunrise, sunset, wind, air pressure etc down to your exact house or office? By PLACE I mean town. Of course you could always use the Node-Red Geonames nodes if you want to put in long/lat or something else.

Ok, so when you first look at this, depending on your experience with APIs and also Node-Red, this might look horrific or simple – I can’t narrow it down more than that. I was terrified for all of 30 minutes until I twigged.

No passwords or accounts are needed to access this information. Let’s take an example, my (summer) home town in the Spain. Punch this exact URL (Universal Resource Locator) into your web browser.

So what you will get out of that URL is a huge block of data in XML format not pretty).

I was interested in temperature NOW (you can have hourly forecasts into the future) along with wind speed, precipitation and for the sake of it, sunrise and sunset times. I also wanted to be able to easily separate the location from the URL, get the output in JSON format and for demo, put bits of it into a DEBUG node. Here’s my FLOW – for in this case my local town in the UK (note the embedded space in the location). When you see this flow in Node-Red, it’s a lot easier than it looks here.

For a test, click on the top left INJECT node… The one that says WARK… and view the result in the DEBUG node. I’ve used standard Node-Red nodes here including function nodes with a little coding to break up the (now Json) data into what I’m interested in).

Hi Tony – apparently you soon won’t be using Dark Sky – they are going over to “the Daak Side” ie selling out to Apple at the expense of everyone else so that’s about to be a dead end – hence the change.

Morning Pete, thanks for sharing your flow and the blog on yr.no. I found it very interesting and the flow work a treat. Thus far looks like a good replacement for Dark Sky. Interestingly the other flow example you provided looks as if it uses Latitude / Longitude so the best of both worlds. Like you I think the local town, Bakewell, in my case is near enough.

Bob, my only caviat on towns is foreign towns – Huescar in Southern Spain has a little symbol above the E which some might have trouble with… I did – never occurred to me – and it is the next town along to our Spanish town of Galera.

Thanks for the confirmation Phil, it was something of a shot in the dark which seems to work well. For my next trick I need to get my head around how to get the peak result for the day.. I suppose if I have it take a reading at 8am every morning for something like “6 hours from now” that’ll be near enough….

The Dark Sky API will be available until the end of 2021, so if you are lucky enough to have a subscription there is plenty of time to compare API results with other sites. I have been using the API for about 3 years for local forecasts.

Yr.no looks very promising and they also have a very nice Android app too which I’ve been using for a week, time will tell. I had a small problem with the app and their tech people got back to me within 4 hours, which is brilliant.

Thanks for the flow Pete, it will speed things up enormously!

For anyone without a Dark Sky API subscription the is (was) a Dark Sky Plugin for Grafana. [edit] The Plugin needs an API Key!!!

Thinking about it Gary – I DO have a Dark Sky key – got it ages ago as I did some work on my Spanish NR pages for my hall display to show expected rain or sun. I don’t use it in the Northeast of England as it is almost always going to rain, but as subscribers from warmer parts of the world will know, having info in advance is handy if you’re planning the day out.. is it to be shopping and culture – or a day at the pool/lake 🙂

Welcome

Hi - I hope the all-new top banner is now more descripive. Let me know if I missed anything important. I hope you like it. I'm Pete and this is my (big) technology blog.

Use the search box or check out the archives and other links below - be sure to SHARE what you like using the social media buttons and please subscribe to my Youtube Video Channel

Please remember to register or log in - the top menu changes a lot when you are part of the party. Please note that registrations with no name or suspicious looking email dresses will be considered to be spammers and will be deleted. Don't forget to tick the box so you will get email follow-ups to comments. We've a great community in here. Spammers and "guest post" companies beware - you have NO chance of success and a good chance of getting spammed badly in return.

To buy me a coffee or help fuel my gadget habit, please use the Paypal donate link below.

Disclaimer: Because I have no idea of your level of technical skill or the requirements of your country laws in terms of electricity supply etc, I accept no responsibility for any damage attributed to following advice in these pages. When dealing with wall outlet (high) voltages you should satisfy yourself that whatever you are doing is safe and if unsure, seek advice from someone who is sure.

Notice: I'm always happy to offer advice on stuff I've written - and indeed take advice. If I can help in any way just let me know but PLEASE don't ask me how to program in C/PASCAL/NODE/etc. There are many resources out there - if you want to program and can't - there's always Google.

Email Newsletter

Enter a name and your real email address if you would like to receive occasional summary emails - sorry but invalid-looking or automated names and email addresses will be removed to help protect others.

Links

EE Times | Electronic Engineering TimesEE Times connects the global electronics community through news, analysis, education, and peer-to-peer discussion around technology, business, products and design