diff --git a/background.html b/background.html
index 1eeacb3..ec6f974 100644
--- a/background.html
+++ b/background.html
@@ -2131,10 +2131,21 @@ window.weatherThemes = {
}
function fetchWeather() {
+ var WEATHER_CFG = (window.CONFIG && window.CONFIG.weather) || {};
+ var currentFields = ['temperature_2m', 'relative_humidity_2m', 'weather_code', 'wind_speed_10m', 'wind_direction_10m'];
+ var hourlyFields = ['temperature_2m', 'weather_code', 'wind_speed_10m', 'wind_direction_10m'];
+ if (WEATHER_CFG.precipitation !== false) {
+ currentFields.push('precipitation');
+ hourlyFields.push('precipitation');
+ }
+ if (WEATHER_CFG.snowfall !== false) {
+ currentFields.push('snowfall');
+ hourlyFields.push('snowfall');
+ }
var url = 'https://api.open-meteo.com/v1/forecast?latitude=' + WEATHER_LAT +
'&longitude=' + WEATHER_LON +
- '¤t=temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m,wind_direction_10m' +
- '&hourly=temperature_2m,weather_code,wind_speed_10m,wind_direction_10m' +
+ '¤t=' + currentFields.join(',') +
+ '&hourly=' + hourlyFields.join(',') +
'&daily=weather_code,temperature_2m_max,temperature_2m_min' +
'&timezone=Europe/Berlin&forecast_days=5';
@@ -2151,6 +2162,15 @@ window.weatherThemes = {
speedKmh: Number(data.current.wind_speed_10m || 0),
dirDeg: Number(data.current.wind_direction_10m || 0)
};
+ window.__currentWeather = {
+ code: Number(data.current.weather_code || 0),
+ tempC: Number(data.current.temperature_2m || 0),
+ humidity: Number(data.current.relative_humidity_2m || 0),
+ precipMm: Number(data.current.precipitation || 0),
+ snowMm: Number(data.current.snowfall || 0),
+ windKmh: Number(data.current.wind_speed_10m || 0),
+ windDirDeg: Number(data.current.wind_direction_10m || 0)
+ };
// while the weather sim runs it owns the theme - a live
// poll must not override the configured test weather
if (!__weatherSimActive)
@@ -2171,6 +2191,15 @@ window.weatherThemes = {
speedKmh: Number(rec.json.current.wind_speed_10m || 0),
dirDeg: Number(rec.json.current.wind_direction_10m || 0)
};
+ window.__currentWeather = {
+ code: Number(rec.json.current.weather_code || 0),
+ tempC: Number(rec.json.current.temperature_2m || 0),
+ humidity: Number(rec.json.current.relative_humidity_2m || 0),
+ precipMm: Number(rec.json.current.precipitation || 0),
+ snowMm: Number(rec.json.current.snowfall || 0),
+ windKmh: Number(rec.json.current.wind_speed_10m || 0),
+ windDirDeg: Number(rec.json.current.wind_direction_10m || 0)
+ };
if (!__weatherSimActive)
setWeatherTheme(getWeatherThemeName(currentWeatherCode));
updateWeatherDisplay();
@@ -2234,6 +2263,15 @@ window.weatherThemes = {
dirDeg: Number(hourly.wind_direction_10m[curIdx] || 0)
};
}
+ window.__currentWeather = {
+ code: Number(curCode || 0),
+ tempC: Number(curTemp || 0),
+ humidity: Number(current.relative_humidity_2m || 0),
+ precipMm: Number((hourly.precipitation && hourly.precipitation[curIdx]) || 0),
+ snowMm: Number((hourly.snowfall && hourly.snowfall[curIdx]) || 0),
+ windKmh: Number(window.__currentWind ? window.__currentWind.speedKmh : 0),
+ windDirDeg: Number(window.__currentWind ? window.__currentWind.dirDeg : 0)
+ };
if (!__weatherSimActive && curCode !== currentWeatherCode) {
currentWeatherCode = curCode;
setWeatherTheme(getWeatherThemeName(curCode));
@@ -2256,6 +2294,15 @@ window.weatherThemes = {
speedKmh: Number(curWindSpeed || 0),
dirDeg: Number(curWindDir || 0)
};
+ window.__currentWeather = {
+ code: Number(curCode || 0),
+ tempC: Number(curTemp || 0),
+ humidity: Number(current.relative_humidity_2m || 0),
+ precipMm: Number(current.precipitation || 0),
+ snowMm: Number(current.snowfall || 0),
+ windKmh: Number(curWindSpeed || 0),
+ windDirDeg: Number(curWindDir || 0)
+ };
var windDisplay = currentUnits === 'imperial'
? Math.round(curWindSpeed * 0.621371) + ' mph'
: Math.round(curWindSpeed) + ' km/h';
diff --git a/config.js b/config.js
index cccefaf..2bd2a60 100644
--- a/config.js
+++ b/config.js
@@ -105,6 +105,19 @@ window.CONFIG = {
weatherSimInterval: 30000, // ms per weather step when weatherSim is true
// weatherSim: true, weatherSimInterval: 15000
+ // ------------------------------------------------------------------
+ // Weather data
+ // ------------------------------------------------------------------
+ // Open-Meteo fields used by the scene. These knobs only control which
+ // optional weather values are requested and exposed as window.__currentWeather.
+ weather: {
+ precipitation: true, // mm/h total precipitation
+ snowfall: true, // cm/h snowfall
+ hourly: true, // use hourly values for the simulated clock
+ // weather: { precipitation: false, snowfall: false, hourly: false }
+ // weather: { precipitation: true, snowfall: true }
+ },
+
// ------------------------------------------------------------------
// Tiles and caches
// ------------------------------------------------------------------