In a recent blog post, fascination of blinking lights was discussed. Let’s take that concept a bit further using another nodeRED node to do some work and an Automat BaseBoard to display the result.

This time, the node HTTP request is used to send a request to a weather web service. The weather service can provide you with 5 day weather forecasts for a given location. The web service will return its result in JSON format (or XML if chosen). So, the weather forecast for Stockholm is requested and the JSON response is sent to a function node. In that node you write JavaScript and thus create your own functions. In this function node, we look through the list of weather data and look for the first weather data that has a time of 18:00. When we’ve found this weather data, we look in it to see if it mentions the word ”rain”. The result of this will be true or false, and the result will be sent to a switch node. The switch node will look at its incoming data, if it fulfills a given condition, it will send the data on a given output. In this case the switch will send the data on output 1 to a blink node that will blink a connected BaseBoard’s blue LED, if the switch receives the value true. If the switch node’s incoming data has the value false, it will send the data through on its second output, a blink node that will flash the BaseBoard’s white LED.

So, when receiving input, this nodeRED flow will fetch a weather forecast for Stockholm. If it will rain at 18:00 on the day it was fetched, a connected BaseBoard will flash with its blue LED (I mean, water is blue), I will put on my rain coat and stay dry when biking home from Neue Labs office, otherwise it will flash with the white color of the sun.