In the previous examples, we showed how to read and write groov View Data Store tags. Now let’s use that basic knowledge and some of the power of Node-RED to do something more interesting.

This example will get current weather data from Weather Underground and display it in groov View.

Step 1 - Add new Data Store and Tags to groov View Project

To keep your groov View project organized, add a new Data Store device to your groov View project:

  1. Open groov View and go into Build mode.
  2. In the Gadget Palette, on the Tags tab, click Configure Device and Tags to open the “Configure Device and Tags” view.
  3. Click Add New Device and select Data Store from the menu.
  4. For the name, enter WeatherDataStore.
  5. Click Create to create the Data Store.

Add a Data Store device to a groov project

Now add some tags.

  1. Make sure that the “WeatherDataStore” Data Store is selected.
  2. Click Configure Tags to open the “Configure Data Store Tags” view.
  3. Add the following tags:
    • String tag named condition
    • Decimal Number tag named temperatureC
    • Decimal Number tag named temperatureF
    • Decimal Number tag named wind

Add new Data Store tags for weather

Create a groov View page with gadgets using the new tags. For example:

Create a page with gadgets using the new tags

Step 2 - Create a Weather Underground Account

Weather Underground has an API that provides weather data for developers and applications. There is a free option that allows you to make 500 requests per day, and additional plans are available for purchase.

In this example, we’ll use the free plan to move some current weather data into groov View.

First, you need a Weather Underground account. You can register here for your free account. You will be given an API key to use when making requests to the Weather Underground service.

Step 3 - Install Weather Underground Nodes for Node-RED

There’s a package available for Node-RED that can access the Weather Underground API. It’s called node-red-node-weather-underground and its homepage is here.

To install the node in Node-RED 0.15.2 or newer:

  1. Make sure that your Node-RED runtime can access the Internet.
    • If you’re using Node-RED on a groov EPIC processor or groov Edge Appliance, then the device must be able to access the Internet when installing nodes. Details on this are in the groov EPIC Troubleshooting and groov Edge Appliance Troubleshooting sections.
    • Node-RED will also need to be connected to the Internet to use the Weather Underground API, which is an online web service.
  2. Open the Node-RED editor in your browser.
  3. Under the menu, select the Manage palette menu item. This will open the “Manage palette” view.
  4. Click the Install tab.
  5. In the search field, enter “weather” and scroll down to find node-red-node-weather-underground.
  6. Click the Install button for node-red-node-weather-underground. It will take a few moments to process.
  7. Click Done to close the Manage palette view.
  8. The weather Underground nodes should now be in the list of available nodes, probably near the bottom.
Static Image
Click the image to start and stop the animation.

Step 4 - Test Weather Underground Nodes

Before connecting the weather data to groov View, first just try the nodes and see how they work.

  1. In Node-RED, drag out an Inject node onto a flow.
  2. Drag out a Weather Underground function node. Make sure you grab the one with a port on each side of the node.
  3. Drag out a Debug node.
  4. Connect the Inject node to the Weather Underground node, and then that to the Debug node.
  5. Double-click on the wunderground node to open the “Edit wunderground node” view.
  6. Enter a City and Country or US State.
  7. Enter your Weather Underground API key.
  8. Click Done.
  9. Click Deploy.
  10. Make sure the Debug tab is viewable in the right-hand sidebar.
  11. Click the Inject node’s button (the square on the left-side of the node).
  12. In the Debug tab, you should see an entry like this:

Sample debug output

That’s the content of the response from the Weather Underground API.

It means that msg.payload contains a JavaScript object with certain properties and values, as defined by the API and the node. Reformatted for easy reading, it looks like this:

msg.payload = {
    "weather": "Clear",
    "tempk": 297.2,
    "tempc": 24,
    "tempf": 75.2,
    "humidity": "21%",
    "windspeed": 0,
    "winddirection": 301,
    "location": "Business Park, Temecula, California",
    "epoch": "1482274378",
    "description": "The weather in Temecula at coordinates: 33.49000168, -117.15000153 is Clear",
    "forecast": "Temecula : Tuesday : Sunshine and clouds mixed. High 24C. Winds light and variable."
  • msg is a JavaScript object, with a property named “payload”. msg objects are what Node-RED passes between nodes.
  • msg.payload is a JavaScript object, with various properties.
    • Message payloads are very common in Node-RED. By default, most nodes will either read or write to msg.payload.
    • Some nodes will let you use other objects or properties, while some simpler nodes only use msg.payload.
  • msg.payload.weather is a string describing the current weather conditions.
  • msg.payload.tempf is a numeric value for the current temperature in degrees Fahrenheit.

Using this information, we can now connect the data into groov gadgets.

Step 5 - Connect Current Temperature to groov View Node

  1. Drag out a groov View Write node.
  2. Connect the output of the Weather Underground node (i.e. the right-hand side port) to the input of the groov View Read node. Sample debug output
  3. Double-click on the groov View Write node to open the “Edit groov write node” view.
  4. Since we created a new Data Store in groov View, we need to configure it in Node-RED too.
  5. In the Data Store field, with “Add new groov-data-store” selected, click on the pencil icon.
  6. Add a Data Store named WeatherDataStore. It must exactly match the name in the groov View project.
  7. For the Tag Name field, enter temperatureF.
  8. For the Value field, select “msg.”, and then enter payload.tempf. This will tell the node to use the property at msg.payload.tempf, which as we saw in the previous section, contains the current temperature. Sample debug output
  9. Click Done.
  10. Click Deploy.
  11. Click the inject node’s button
  12. Go to groov View and see the temperature value in the gadget.

Step 6 - Connect Additional Weather Data

In a similar way, you can connect other data to additional groov tags.

  1. Drag out two more groov View Write nodes.
  2. Connect the output of the Weather Underground node to each new groov View Write node.
  3. For the first new node, configure these fields:
    • Data Store: select the existing WeatherDataStore configuration.
    • Tag Name: enter condition.
    • Value: select “msg.” and enter payload.weather.
  4. For the other new node, configure these fields:
    • Data Store: select the existing WeatherDataStore configuration.
    • Tag Name: enter wind.
    • Value: select “msg.” and enter payload.windspeed. Sample debug output
  5. Deploy the flow and try it out.

Step 7 - Periodically Update Weather Data

The free Weather Underground API plan allows for 500 API calls per day. If you’re only requesting data for one city from one device, that comes out to a request every three minutes.

The Inject node has several options for periodically injecting messages into the flow. We can use it to periodically refresh the weather data and keep the data in groov View fresh.

  1. Double-click on the Inject node to open the “Edit inject node” view.
  2. For the Repeat field, select “interval” and enter a value of 5 minutes or greater. This will keep your Weather Underground API requests well within the 500 requests-per-day limit.
  3. For the Name field, enter a useful name like “Every 5 minutes”.
  4. Click Done.
  5. Delete the Debug node, as you probably don’t need it anymore. Sample debug output
  6. Click Deploy. The weather data will now be refreshed every three minutes.

If you’d like to get data for additional cities, you can either make less-frequent requests, or purchase an appropriate plan from Weather Underground.

Sample _groov_ View page with trend


This concludes our Getting Started with Node-RED for groov View section.

There’s also a quick introduction to Node-RED on the official website, with tutorials for a first and second flow.

Please explore the other material available on the Opto 22 Developer site for additional information, including the section on Node-RED resources.