MagicMirrorOrg/MagicMirror · error · Error

Unknown weather type: ${this.config.type}

Error message

Unknown weather type: ${this.config.type}

What it means

openmeteo's #handleResponse switches on this.config.type; unsupported values log '[openmeteo] Unknown type' and throw 'Unknown weather type'. It fires after a successful API parse, so it purely indicates a config problem, not an API problem.

Source

Thrown at defaultmodules/weather/providers/openmeteo.js:225

			return;
		}

		try {
			let weatherData;
			switch (this.config.type) {
				case "current":
					weatherData = this.#generateWeatherDayFromCurrentWeather(parsedData);
					break;
				case "forecast":
				case "daily":
					weatherData = this.#generateWeatherObjectsFromForecast(parsedData);
					break;
				case "hourly":
					weatherData = this.#generateWeatherObjectsFromHourly(parsedData);
					break;
				default:
					Log.error(`[openmeteo] Unknown type: ${this.config.type}`);
					throw new Error(`Unknown weather type: ${this.config.type}`);
			}

			if (weatherData && this.onDataCallback) {
				this.onDataCallback(weatherData);
			}
		} catch (error) {
			Log.error("[openmeteo] Error processing weather data:", error);
			if (this.onErrorCallback) {
				this.onErrorCallback({
					message: error.message,
					translationKey: "MODULE_ERROR_UNSPECIFIED"
				});
			}
		}
	}

	#getQueryParameters () {
		let maxNumberOfDays = this.config.maxNumberOfDays;

View on GitHub (pinned to 4b4a59534f)

Solutions

  1. Set config.type to 'current', 'daily' or 'hourly'
  2. Fix the casing/whitespace of the type string
  3. Validate type against the supported set before calling initialize()

Example fix

// before
config = { type: "3hourly", ... }
// after
config = { type: "hourly", ... }
Defensive patterns

Strategy: validation

Validate before calling

const OPENMETEO_TYPES = ["current", "daily", "hourly"];
if (!OPENMETEO_TYPES.includes(config.type)) throw new Error(`openmeteo type must be one of ${OPENMETEO_TYPES.join(" | ")}`);

Type guard

const isValidType = (t) => typeof t === "string" && ["current", "daily", "hourly"].includes(t);

Try / catch

try {
  provider.initialize(config);
} catch (err) {
  if (err.message.startsWith("Unknown weather type:")) {
    console.error(`openmeteo: '${config.type}' unsupported — use current/daily/hourly`);
  } else throw err;
}

Prevention

When it happens

Trigger: config.type is any string other than the handled cases ('current', 'daily', 'hourly'), e.g. 'today', 'forecast', or a mistyped value.

Common situations: Config copied from a provider with richer type vocabulary; camelCase or capitalized type; UI passing a free-form string into the provider.

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


AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31). Data as JSON: /api/errors/d68debfa2f892871. Report an issue: GitHub.