MagicMirrorOrg/MagicMirror · error · Error
Unknown weather type: ${this.config.type}
Error message
Unknown weather type: ${this.config.type} What it means
After validating the buienradar response, #handleResponse switches on this.config.type to select daily or hourly generation. Any type other than 'current'/'daily'/'hourly' (whatever the supported cases are) falls to default and throws. It indicates an unsupported weather type string in the provider config.
Source
Thrown at defaultmodules/weather/providers/buienradar.js:152
throw new Error("Invalid API response");
}
this.#setLocationName(data.location);
let weatherData;
switch (this.config.type) {
case "current":
weatherData = this.#generateCurrentWeather(data.days[0]);
break;
case "forecast":
case "daily":
weatherData = this.#generateDailyForecast(data.days);
break;
case "hourly":
weatherData = this.#generateHourlyForecast(data.days);
break;
default:
throw new Error(`Unknown weather type: ${this.config.type}`);
}
if (this.onDataCallback && weatherData) {
this.onDataCallback(weatherData);
}
} catch (error) {
Log.error("[buienradar] Error processing weather data:", error);
this.#sendErrorCallback(error.message);
}
}
#sendErrorCallback (message) {
if (this.onErrorCallback) {
this.onErrorCallback({
message,
translationKey: ERROR_TRANSLATION_KEY
});
}View on GitHub (pinned to 4b4a59534f)
Solutions
- Set config.type to a supported value: 'current', 'daily' or 'hourly'
- Fix casing/typos in the type string (values are case-sensitive)
- Check the provider's documented supported types
Example fix
// before
config = { type: "daily-forecast", ... }
// after
config = { type: "daily", ... } Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = ["current", "daily", "hourly"];
if (!SUPPORTED.includes(config.type)) throw new Error(`Unsupported type ${config.type}; use one of ${SUPPORTED.join(", ")}`); Type guard
const isWeatherType = (t) => ["current", "daily", "hourly"].includes(t);
Try / catch
try {
provider.initialize(config);
} catch (err) {
if (err.message.startsWith("Unknown weather type:")) {
console.error(`Bad type '${config.type}' — allowed: current, daily, hourly`);
} else throw err;
} Prevention
- Whitelist config.type against the provider's supported values at startup
- Remember type strings are case-sensitive and trimmed exactly
- Copy only types documented for THIS provider, not others
- Add a schema check (e.g. zod enum) on the module config
When it happens
Trigger: config.type set to a value not handled by the switch, e.g. 'weekly', 'minutely', or a typo like 'hourly ' or 'Hourly'.
Common situations: Copy-pasting config between providers with different supported types; case sensitivity mistakes; adding a type string the provider doesn't implement.
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 type: ${this.config.type}
- Unknown weather type: ${this.config.type}
- Unknown weather endpoint: ${this.config.weatherEndpoint}
- Latitude and longitude are required
- Invalid API response
AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31).
Data as JSON: /api/errors/a3201777fe12cf1d.
Report an issue: GitHub.