From fdb752073f5728c61dfd32febaa359af80670ad6 Mon Sep 17 00:00:00 2001 From: ztimson Date: Wed, 24 Jun 2026 17:18:49 -0400 Subject: [PATCH] Fixes --- server/src/forecast.mjs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/server/src/forecast.mjs b/server/src/forecast.mjs index cbbe938..3e3c157 100644 --- a/server/src/forecast.mjs +++ b/server/src/forecast.mjs @@ -1,6 +1,6 @@ // forecast.mjs import {queryHourly, getCoords, queryCurrent} from './influx.mjs'; -import { getCelestialForecast } from './celestial.mjs'; +import {getCelestialCurrent, getCelestialForecast} from './celestial.mjs'; import {getWeatherCondition} from './openweather.mjs'; export let lastForecast = { ts: 0, slots: [], summary: null } @@ -151,9 +151,9 @@ export async function get24HourForecast(currentSensors) { const humidity = forecastHumidity(seedAbsHum, temperature); const wind_speed = forecastWind(seedWind, pressureTrend); + const celestial = getCelestialCurrent(coords.latitude, coords.longitude, time); const snapshot = { time, - daytime: false, temperature, humidity, humidity_abs: absoluteHumidity(temperature, humidity), @@ -163,17 +163,15 @@ export async function get24HourForecast(currentSensors) { pressure_hpa: Math.round(pressure * 100) / 100, wind_speed, clouds, - precipitation_chance: Math.round(weather.precipChance * (1 - i * 0.02) * 100), // confidence decays + precipitation_chance: Math.round(weather.precipChance * (1 - i * 0.02) * 100), + ...celestial }; return Object.assign(snapshot, getWeatherCondition(snapshot)); }); - // Pass through getCelestialForecast to enrich sun/moon data - const enriched = getCelestialForecast(coords.latitude, coords.longitude, slots); - // Second pass — apply solar heating now that we have sun_elevation per slot - for (const slot of enriched) { + for (const slot of slots) { if (slot.sunrise && slot.sunset) { const t = slot.time instanceof Date ? slot.time.getTime() : new Date(slot.time).getTime(); const rise = slot.sunrise instanceof Date ? slot.sunrise.getTime() : new Date(slot.sunrise).getTime(); @@ -193,7 +191,7 @@ export async function get24HourForecast(currentSensors) { slot.humidity_abs = absoluteHumidity(slot.temperature, slot.humidity); } - return enriched; + return slots; } function summarise(slots) {