diff --git a/client/src/components/CurrentWeather.vue b/client/src/components/CurrentWeather.vue index 866ad4a..efd6be0 100644 --- a/client/src/components/CurrentWeather.vue +++ b/client/src/components/CurrentWeather.vue @@ -137,11 +137,11 @@ onMounted(async () => {
- +
- +
@@ -153,7 +153,7 @@ onMounted(async () => {
Precipitation
- {{ !data.precipitation && data.raining == 'True' ? 'Spitting' : data.precipitation.toFixed(1) + 'mm'}} + {{ data.raining == 'False' ? (data.precipitation_chance + '%') : (data.percipitation > 0 ? data.precipitation.toFixed(1) + 'mm' : 'Spitting')}}
Humidity diff --git a/client/src/components/ForecastStrip.vue b/client/src/components/ForecastStrip.vue index 9ae28d3..088de19 100644 --- a/client/src/components/ForecastStrip.vue +++ b/client/src/components/ForecastStrip.vue @@ -61,12 +61,12 @@ function dir(deg: number) {
-
{{ formatDate('ddd, MMM d', new Date(d.time + 'T00:00:00')) }}
+
{{ formatDate('ddd, MMM D', new Date(d.time + 'T00:00:00')) }}
{{ d.label }}
- ↑{{ d.temperature_max || '—' }} - ↓{{ d.temperature_min || '—' }} + ↑{{ ~~(d.temperature_max) + '°' || '—' }} + ↓{{ ~~(d.temperature_min) + '°' || '—' }}
🌡️ {{ d.humidity || 0 }}%
🍃 {{ ~~(d.wind_gusts as any) || 0 }} Kph ({{dir(d.wind_dir as any)}})
diff --git a/server/src/forecast.mjs b/server/src/forecast.mjs index 558d6d0..effd7ad 100644 --- a/server/src/forecast.mjs +++ b/server/src/forecast.mjs @@ -1,6 +1,7 @@ // forecast.mjs import {queryHourly, getCoords, queryCurrent} from './influx.mjs'; import { getCelestialForecast } from './celestial.mjs'; +import {getWeatherCondition} from './openweather.mjs'; export let lastForecast = { ts: 0, slots: [], summary: null } const TTL = 10 * 60 * 1000 @@ -150,7 +151,7 @@ export async function get24HourForecast(currentSensors) { const humidity = forecastHumidity(seedAbsHum, temperature); const wind_speed = forecastWind(seedWind, pressureTrend); - return { + const snapshot = { time: time.toISOString().slice(0, 16), // "YYYY-MM-DDTHH:MM" temperature, humidity, @@ -161,10 +162,10 @@ export async function get24HourForecast(currentSensors) { pressure_hpa: Math.round(pressure * 100) / 100, wind_speed, clouds, - precip_chance: Math.round(weather.precipChance * (1 - i * 0.02) * 100), // confidence decays - label: weather.label, - code: weather.code, + precipitation_chance: Math.round(weather.precipChance * (1 - i * 0.02) * 100), // confidence decays }; + + return Object.assign(snapshot, getWeatherCondition(snapshot)); }); // Pass through getCelestialForecast to enrich sun/moon data @@ -188,7 +189,7 @@ export async function get24HourForecast(currentSensors) { function summarise(slots) { if (!slots.length) return null const temps = slots.map(s => s.temperature).filter(Number.isFinite) - const precips = slots.map(s => s.precip_chance).filter(Number.isFinite) + const precips = slots.map(s => s.precipitation_chance).filter(Number.isFinite) const winds = slots.map(s => s.wind_speed).filter(Number.isFinite) const gusts = slots.map(s => s.wind_gusts).filter(Number.isFinite) const uvs = slots.map(s => s.uv_index).filter(Number.isFinite) @@ -202,13 +203,13 @@ function summarise(slots) { return { time: slots[0].time.slice(0, 10), - label, + label: dominant.label, code: dominant.code, icon: dominant.icon ?? null, temperature: Math.max(...temps), temperature_max: Math.max(...temps), temperature_min: Math.min(...temps), - precip_chance: Math.round(Math.max(...precips)), + precipitation_chance: Math.round(Math.max(...precips)), wind_speed: Math.round(Math.max(...winds) * 10) / 10, wind_gusts: gusts.length ? Math.round(Math.max(...gusts) * 10) / 10 : null, uv_index: uvs.length ? Math.max(...uvs) : null, diff --git a/server/src/server.mjs b/server/src/server.mjs index 588f9db..105fc20 100644 --- a/server/src/server.mjs +++ b/server/src/server.mjs @@ -48,7 +48,7 @@ app.get('/api/current', async (req, res) => { // Merge forecast summary fields — sensor readings take priority const merged = { ...(summary ? { - precipitation_chance: summary.precip_chance, + precipitation_chance: summary.precipitation_chance, temperature_max: summary.temperature_max, temperature_min: summary.temperature_min, uv_index_max: summary.uv_index,