MagicMirrorOrg/MagicMirror · error · Error
Unknown weather type: ${this.config.type}
Error message
Unknown weather type: ${this.config.type} What it means
When using the One Call endpoint, openweathermap's #handleResponse switches on this.config.type to map the payload to current/daily/hourly weather objects. Unhandled types are logged and throw 'Unknown weather type'. This is a config validation error occurring after a successful API response.
Source
Thrown at defaultmodules/weather/providers/openweathermap.js:123
this.locationName = data.timezone;
}
const onecallData = this.#generateWeatherObjectsFromOnecall(data);
switch (this.config.type) {
case "current":
weatherData = onecallData.current;
break;
case "forecast":
case "daily":
weatherData = onecallData.days;
break;
case "hourly":
weatherData = onecallData.hours;
break;
default:
Log.error(`[openweathermap] Unknown type: ${this.config.type}`);
throw new Error(`Unknown weather type: ${this.config.type}`);
}
} else if (this.config.weatherEndpoint === "/weather") {
// Current weather endpoint (API v2.5)
weatherData = this.#generateWeatherObjectFromCurrentWeather(data);
} else if (this.config.weatherEndpoint === "/forecast") {
// 3-hourly forecast endpoint (API v2.5)
weatherData = this.config.type === "hourly"
? this.#generateHourlyWeatherObjectsFromForecast(data)
: this.#generateDailyWeatherObjectsFromForecast(data);
} else {
throw new Error(`Unknown weather endpoint: ${this.config.weatherEndpoint}`);
}
if (weatherData && this.onDataCallback) {
this.onDataCallback(weatherData);
}
} catch (error) {
Log.error("[openweathermap] Error processing weather data:", error);View on GitHub (pinned to 4b4a59534f)
Solutions
- Set config.type to 'current', 'daily' or 'hourly'
- Fix typos/casing in the type value
- Add validation of type before initialize()
Example fix
// before
config = { type: "minutely", ... }
// after
config = { type: "current", ... } Defensive patterns
Strategy: validation
Validate before calling
const OWM_TYPES = ["current", "daily", "hourly"];
if (!OWM_TYPES.includes(config.type)) throw new Error(`openweathermap type must be one of ${OWM_TYPES.join(" | ")}`); Type guard
const isOwmType = (t) => ["current", "daily", "hourly"].includes(t);
Try / catch
try {
provider.initialize(config);
} catch (err) {
if (err.message.startsWith("Unknown weather type:")) {
console.error(`Set config.type to current/daily/hourly (got '${config.type}')`);
} else throw err;
} Prevention
- Map OpenWeb 'exclude' segments (minutely/alerts) separately — they are not types
- Validate the type enum at config load time
- Use consistent lowercase type strings across your app
- Test each provider config in CI
When it happens
Trigger: config.type contains a value outside the switch cases (e.g. 'minutely', 'alerts', typo) while weatherEndpoint is the One Call endpoint.
Common situations: Passing OpenWeather 'exclude' segments (minutely/alerts) as type by mistake; capitalization mismatch; config template not filled in.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown weather endpoint: ${this.config.weatherEndpoint}
- Unknown weather type: ${this.config.type}
- Unknown weather type: ${this.config.type}
- setCallbacks() must be called before initialize()
- Latitude and longitude are required
AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31).
Data as JSON: /api/errors/e460b66a013d6a03.
Report an issue: GitHub.