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.


15 thoughts on “The Weather

  1. 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 🙁

  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!)

    1. Simon- Sorry about hijacking the thread, but I don’t know any other way to reach out to you.

      I cannot get the WU nodes to install. Any help would be appreciated.
      I did install the nodes, but I am still learning how to parse the data into something presentable on the Node Red UI.

      Steve Mann

      1. Hi

        If you have problems with nodes other than mine – you need to go to the repositories for the nodes and talk to the relevant developer of the node. Most are quite responsive.


        1. Thanks, I was able to follow your instructions, above, and that’s how I got the results in my message. I suspect that I need some functions to separate the individual elements in the incoming xml, but that’s beyond my experience in Node Red.

          How do you display the results in your Node Red dashboard?

          On the Weather Underground nodes, they came from and there is no link to the author or forum there.

          Hmm, I just noticed the latest version is only a few days ago. Maybe if I try one prior, which is a few months old…. just thinkin’.

          One thing I am not sure of- do I need to reboot my Node Red Pi after I install new nodes?

          Anyway, thanks for the response. I have learned a few things from your blog posts.

          While I have your attention. Is there a tutorial, language reference or Rosetta Stone for writing my own Node Red functions?

          1. Writing Node-Red functions – go to the Node-Red sight. Go to Node-Red Google Groups and discuss with the guys who wrote it.

            No you don’t need to reboot node-red generally – I PERSONALLY shut down Node-Red – install – boot it up.. but you can do it all in Node-Red itself now without shutting down – though I suggest at least a browser refresh.

            It isn’t my node-red dashboard – again – node-red-dashboard google group.

            1. Thanks. Seriously. I found a lot of information there and have been experimenting with “learning” JSON and making nodes to extract the data from the message payload. It’s an experience….

              I found a free JSON formatter that really helped me understand the structure of the data:

              On the problem installing Weather Underground, The RPi that I was using for Node-red is hosed. At least Node-Red is broken. I moved my work to another RPi to continue my experiments, and Weather Underground installed just fine. I also have my mqtt broker (mosquitto) there, and a 5-drive 2Tb RAID array. If I reinstall the O/S on it, I don’t know what will happen to my RAID array, and rebuilding it takes days. So, I will just use the second RPi for my Node-Red work.

              On the ‘learning to write functions’, this is still a black hole. The Node-red site has some basic, very basic information. But not being proficient in JSON leaves me in the dark. I’ll be referring to JSON help sites to continue.

              Again, thanks
              Just think, a month ago I never heard of mqtt and Node-Red.

      2. Steve, I’m away for another month or so without access to my system. I see Pete has given some pointers, so hope you’ll get things going with those. I’ll leave the email I received from this post in my to do’s and will take a look when I get back at how I used the wunderground node.


        1. Thanks. Pete is a remarkable resource. As you can see from my reply to him, I am further along with my learning process. Let me know when you get back and we can compare nodes.

  3. 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.


Comments are closed.