diff --git a/server/src/forecast.mjs b/server/src/forecast.mjs index a707c81..15fbf03 100644 --- a/server/src/forecast.mjs +++ b/server/src/forecast.mjs @@ -49,14 +49,14 @@ function absoluteHumidity(tempC, humidity) { } function pressureRule(trend3h, currentHpa) { - if (trend3h < -2.0) return { label: 'Storm likely', code: 211, precipChance: 0.85 }; - if (trend3h < -0.8) return { label: 'Rain likely', code: 501, precipChance: 0.65 }; - if (trend3h < -0.3) return { label: 'Cloudy', code: 803, precipChance: 0.35 }; - if (trend3h > 1.5) return { label: 'Clearing', code: 801, precipChance: 0.05 }; - if (trend3h > 0.3) return { label: 'Improving', code: 800, precipChance: 0.10 }; - if (currentHpa < 1000) return { label: 'Unsettled', code: 802, precipChance: 0.30 }; - if (currentHpa < 1013) return { label: 'Partly cloudy', code: 802, precipChance: 0.15 }; - return { label: 'Fair', code: 800, precipChance: 0.05 }; + if (trend3h < -2.0) return { label: 'Storm likely', precipitation_chance: 0.85 }; + if (trend3h < -0.8) return { label: 'Rain likely', precipitation_chance: 0.65 }; + if (trend3h < -0.3) return { label: 'Cloudy', precipitation_chance: 0.35 }; + if (trend3h > 1.5) return { label: 'Clearing', precipitation_chance: 0.05 }; + if (trend3h > 0.3) return { label: 'Improving', precipitation_chance: 0.10 }; + if (currentHpa < 1000) return { label: 'Unsettled', precipitation_chance: 0.30 }; + if (currentHpa < 1013) return { label: 'Partly cloudy', precipitation_chance: 0.15 }; + return { label: 'Fair', precipitation_chance: 0.05 }; } function solarTempDelta(sunElevation, cloudFraction) { @@ -143,7 +143,7 @@ export async function get24HourForecast(currentSensors) { wind_gusts: Math.round(wind_speed * 1.4 * 10) / 10, wind_direction: currentSensors.wind_direction ?? 0, clouds, - precipitation_chance: Math.round(weather.precipChance * (1 - i * 0.02) * 100), + precipitation_chance: Math.round(weather.precipitation_chance * (1 - i * 0.02) * 100), accumulation: 0, uv_index, uv_dose: 0, @@ -216,7 +216,6 @@ function summarise(slots) { return { time: slots[0].time, label: dominant.label, - code: dominant.code ?? null, icon: dominant.icon, temperature: peak(fin('temperature')), temperature_max: peak(finAll('temperature')), @@ -272,21 +271,21 @@ export async function getForecast() { export function getWeatherCondition(data) { if(data.lightning_rate > 0 && data.raining === 'True') { - return {label: 'Thunderstorm', icon: '11d', code: 211}; + return {label: 'Thunderstorm', icon: '11d'}; } if(data.raining === 'True') { - if(data.precipitation > 7.6) return {label: 'Heavy Rain', icon: '10d', code: 502}; - if(data.precipitation > 2.5) return {label: 'Moderate Rain', icon: '10d', code: 501}; - return {label: 'Light Rain', icon: '09d', code: 500}; + if(data.precipitation > 7.6) return {label: 'Heavy Rain', icon: '10d'}; + if(data.precipitation > 2.5) return {label: 'Moderate Rain', icon: '10d'}; + return {label: 'Light Rain', icon: '09d'}; } - if(data.visibility < 10) return {label: 'Mist', icon: '50d', code: 701}; + if(data.visibility < 10) return {label: 'Mist', icon: '50d'}; const dayNight = data.daytime ? 'd' : 'n'; - if(data.clouds > 0.85) return {label: 'Overcast Clouds', icon: `04${dayNight}`, code: 804}; - if(data.clouds > 0.50) return {label: 'Broken Clouds', icon: `04${dayNight}`, code: 803}; - if(data.clouds > 0.25) return {label: 'Scattered Clouds', icon: `03${dayNight}`, code: 802}; - if(data.clouds > 0.10) return {label: 'Few Clouds', icon: `02${dayNight}`, code: 801}; - return {label: 'Clear Sky', icon: `01${dayNight}`, code: 800}; + if(data.clouds > 0.85) return {label: 'Overcast Clouds', icon: `04${dayNight}`}; + if(data.clouds > 0.50) return {label: 'Broken Clouds', icon: `04${dayNight}`}; + if(data.clouds > 0.25) return {label: 'Scattered Clouds', icon: `03${dayNight}`}; + if(data.clouds > 0.10) return {label: 'Few Clouds', icon: `02${dayNight}`}; + return {label: 'Clear Sky', icon: `01${dayNight}`}; }