MagicMirrorOrg/MagicMirror · error · Error
Unknown weather type: ${this.config.type}
Error message
Unknown weather type: ${this.config.type} What it means
The WeatherAPI.com provider validates its configured weather type at startup in #validateConfig. Only "hourly", "daily" and "current" are supported; a config of "forecast" is auto-rewritten to "daily" before the check. Any other value (typo, wrong provider keyword, missing type) throws this Error during initialize.
Source
Thrown at defaultmodules/weather/providers/weatherapi.js:58
this.fetcher.startPeriodicFetch();
}
}
stop () {
if (this.fetcher) {
this.fetcher.clearTimer();
}
}
#validateConfig () {
this.config.type = `${this.config.type ?? ""}`.trim().toLowerCase();
if (this.config.type === "forecast") {
this.config.type = "daily";
}
if (!["hourly", "daily", "current"].includes(this.config.type)) {
throw new Error(`Unknown weather type: ${this.config.type}`);
}
if (!this.config.apiKey || `${this.config.apiKey}`.trim() === "") {
throw new Error("apiKey is required");
}
if (!Number.isFinite(this.config.lat) || !Number.isFinite(this.config.lon)) {
throw new Error("Latitude and longitude are required");
}
}
#initializeFetcher () {
const url = this.#getUrl();
this.fetcher = new HTTPFetcher(url, {
reloadInterval: this.config.updateInterval,
headers: { "Cache-Control": "no-cache" },
logContext: "weatherprovider.weatherapi"View on GitHub (pinned to 4b4a59534f)
Solutions
- Set weatherProvider: "weatherapi" config type to one of "current", "hourly", "daily" (or "forecast", which is accepted and treated as daily).
- Check for typos/case: values are compared exactly, lowercase.
- If migrating from another provider, map its type vocabulary to weatherapi's hourly/daily/current.
- Ensure the type property is actually defined in the module config and not overridden by another module.
Example fix
// before
config: {
weatherProvider: "weatherapi",
type: "forecast5day"
}
// after
config: {
weatherProvider: "weatherapi",
type: "daily"
} Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = ["current", "hourly", "daily", "forecast"];
if (!ALLOWED.includes(config.type)) {
throw new Error(`weatherapi: type must be one of ${ALLOWED.join(", ")}, got ${JSON.stringify(config.type)}`);
} Type guard
function isValidWeatherType(t) {
return typeof t === "string" && ["hourly", "daily", "current"].includes(t);
} Prevention
- Copy type values only from the provider's documented list (current/hourly/daily/forecast).
- Keep a shared constants file for type strings across providers.
- Validate the whole weather config at startup with a schema check before module init.
When it happens
Trigger: config.type is set to anything other than "hourly", "daily", "current" (or "forecast", which is normalized to "daily") when the module initializes — e.g. type: "Forecast", type: "weekly", or type omitted so it is undefined.
Common situations: Copy-pasting a config from another weather provider (weathergov uses "forecast"; openmeteo/other modules use different vocab), typos or wrong capitalization, forgetting the type field entirely so undefined fails the includes() check.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Latitude and longitude are required
- Latitude and longitude are required
- siteCode and provCode are required
- apiKey is required
- [weather] Deprecation warning: Your are using the deprecated
AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31).
Data as JSON: /api/errors/2f82a57c2c5ba623.
Report an issue: GitHub.