The Weather

I had a chat with my pal Jonathan today about the weather – and more specifically getting it into Node-Red.  If you are building your home control with Node-Red at the centre then it is always nice to have information about the local weather to send off to your various displays (such as the one described earlier today) and is a dead easy way to get it!

Go to and sign up - that will give you an API number. No, really it is that easy and as long as you don’t use it 1,000 times a day, it is free. Simples.

Here’s what you do: setup

Using an HTTP node (the yellow one) and fill it in as below substituting XXXXXXX for your API key – and the long/lat coordinates for your own (I got mine off the Google Maps command line when pointing at my village). If you’re not in the UK then you’ll have to try something else. US is probably a good start for our friends in the USA. setup

In the function (orange) you need this..

var weather = JSON.parse(msg.payload);

And that is that. NOW you need to know what is available in your new json object and remember – don’t use that timestamp inject (it is irrelevant what it is injecting – it’s just a trigger) more than 999 times a day Smile

So if you look at the output from the incoming XML it is MASSIVE – but put into a JSON online viewer like once converted it starts to look more reasonable. json

For example if we expand currently – we get…


And how do we access that? Simples – having called the object “weather” we get the temperature as weather.currently.temperature

and so on. In HOURLY we see timestamps and things like chances of precipitation… a little clever loop and… remember in an earlier blog we looked at showing graphs of history in Imperihome? It would not be beyond the bounds of reason to feed this lot into said graphs!!!

Well, even without digging any further, hopefully there are a few items of interest for you.  weather.currently.summary is good as are weather.hourly.summary and weather.daily.summary.

If you want to check the weather you could look at this – but with your coordinates. .,-0.0295

And on the subject of weather but otherwise unrelated – this looks like a fun site…

Oh, nearly forgot – and you’ll be needing some fancy icons..

Have fun. And if you know of something BETTER – leave a link in the comments.


7 thoughts on “The Weather

  1. Wunderground also has nodes for that you can import to make things easier. I'm not at home now but I think also has a node.


    1. The code was dead easy to put into Node-Red as you can see but when you get home if there are links that others here might find useful I'd really appreciate if you'd dump the links in here.


  2. Thanks Peter, your approach is much better than the dedicated node as it allows me to specify other parameter (most important LANGUAGE!!!) while getting the same data; true some more wrok needed to parse but at least I've all in my native language (the family will be happier!)

  3. by the way, anyone can help to understand how to pass to the API two parameters?
    if I add "?lang=it" or "?units=si" they both work perfectly but if I add them both "?lang=it?units=si" I get an error "400"; I tried already to swap the flags but same errors 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *