Node-RED OpenWeatherMap Node

1.0.1 · active · verified Sun Apr 19

This package provides two Node-RED nodes, 'OpenWeatherMap' (input) and 'OpenWeatherMap Query' (query), for integrating weather data from the OpenWeatherMap API into Node-RED flows. The 'input' node periodically fetches current weather or a 5-day forecast based on configured location (city/country or lat/lon) and outputs a message if data changes. The 'query' node allows on-demand fetching of current weather, triggered by input messages containing location details. It returns detailed weather information including temperature, humidity, wind, and precipitation, as well as an object with full API data. Currently at version 1.0.1, it is part of the broader Node-RED ecosystem and follows its release cadence for updates and compatibility. A key differentiator is its seamless integration into Node-RED's visual programming environment, abstracting direct API calls and simplifying complex API interactions into configurable nodes. This makes it accessible for users who prefer visual programming over writing code for data fetching and processing.

Common errors

Warnings

Install

Quickstart

This quickstart guides you through installing the Node-RED OpenWeatherMap node, configuring it, and providing example input messages to trigger the 'OpenWeatherMap Query' node for fetching weather data.

/*
  Step 1: Install the node in your Node-RED environment.
  Open your Node-RED user directory (typically ~/.node-red) in your terminal and run:
*/
// npm install node-red-node-openweathermap

/*
  Step 2: Restart Node-RED to load the new nodes (if it was running).
*/
// node-red

/*
  Step 3: In the Node-RED editor (usually accessible at http://localhost:1880),
  drag an "OpenWeatherMap Query" node from the palette onto the canvas.
  Double-click the node to configure it, providing your OpenWeatherMap API Key
  (obtained from openweathermap.org/appid).

  Step 4: To trigger the 'OpenWeatherMap Query' node and fetch current weather
  for a specific location, inject a message (e.g., using an 'Inject' node)
  with the following structure:
*/
const msg_by_city = {
  payload: {},
  location: {
    city: "London",
    country: "UK"
  }
};

// Alternatively, you can specify location using latitude and longitude:
const msg_by_coords = {
  payload: {},
  location: {
    lat: 51.5074,
    lon: 0.1278
  }
};

/*
  The 'OpenWeatherMap Query' node will then output a message (msg.payload)
  containing detailed weather data, similar to the following:
  {
    "description": "light rain",
    "weather": "Rain",
    "icon": "10d",
    "id": 500,
    "tempc": 15.2,
    "tempk": 288.35,
    "humidity": 87,
    "windspeed": 2.1,
    "winddirection": 240,
    "location": "London",
    "rain": 0.5,
    "lat": 51.5074,
    "lon": 0.1278,
    "city": "London",
    "country": "UK",
    "time": 1678886400, // example epoch timestamp
    "data": { /* full JSON from OpenWeatherMap API */ } // full JSON from OpenWeatherMap API
  }
*/

view raw JSON →