node-red-contrib-weather
raw JSON → 0.1.2 verified Sat Apr 25 auth: no javascript maintenance
Node-RED Node for fetching weather data from Xiaomi (Mi) weather API for Chinese locations. Current stable version 0.1.2, last released 2019-12-5, no active development. Key differentiator: simple integration with Node-RED, supports latitude/longitude input within China only, outputs weather object, temperature, humidity, weather condition, AQI, sunrise/sunset. Does not use any official weather API; data source is Xiaomi's internal service. Low maintenance, bug fixes via GitHub issues/QQ group.
Common errors
error TypeError: Cannot read property 'payload' of undefined ↓
cause Input msg object is missing or not from a proper Node-RED inject node.
fix
Ensure inject node is configured to send a JSON payload: {"latitude":31,"longitude":121}.
error Error: No data from weather API ↓
cause Latitude/longitude out of China range or API temporarily unavailable.
fix
Use coordinates within China (e.g., 31,121 for Shanghai). Check network connectivity.
error Weather node output is empty object {} ↓
cause Input payload not parsed as JSON; node uses default lat/lon from node config which may be empty.
fix
Set input payload to valid JSON string: {"latitude":31,"longitude":121} or configure lat/lon in node properties.
Warnings
gotcha Only supports Chinese locations; lat/lon outside China (approx 18-54 N, 73-135 E) will return no data or errors. ↓
fix Use only within China; for global weather, use other nodes like node-red-contrib-openweathermap.
deprecated Unofficial Xiaomi API; may break or become unavailable without notice. ↓
fix Consider switching to a more reliable weather node using an official API with API key.
breaking Output structure changed in v0.1.1: data moved from msg to msg.payload. ↓
fix Update downstream nodes to read msg.payload instead of msg directly.
deprecated No updates since 2019-12-5; no activity, may be abandoned. ↓
fix Check for newer versions or consider alternatives.
Install
npm install node-red-contrib-weather yarn add node-red-contrib-weather pnpm add node-red-contrib-weather Imports
- weather node wrong
Cannot import in code; it's a Node-RED node, not a library.correctInstall via npm: npm install -g node-red-contrib-weather (then use in Node-RED palette) - msg.payload input wrong
Sending non-JSON payload or missing payload field; node falls back to node's configured lat/lon.correctInput msg.payload must be JSON: {"latitude":31,"longitude":121} - output msg.payload wrong
Expecting msg.data or msg.weather; earlier versions (0.0.x) used msg directly.correctWeather data is placed in msg.payload (object with weather fields).
Quickstart
// In Node-RED flow:
// Inject node -> weather node -> Debug node
// Inject node payload: {"latitude":31,"longitude":121}
// Weather node configuration: leave lat/lon empty (use input payload)
// Debug node outputs weather object with fields: temperature, humidity, condition, AQI, sunrise, sunset, etc.