Fixing current forecast
This commit is contained in:
@@ -175,8 +175,10 @@ export async function get24HourForecast(currentSensors) {
|
||||
// Second pass — apply solar heating now that we have sun_elevation per slot
|
||||
for (const slot of enriched) {
|
||||
if (slot.sunrise && slot.sunset) {
|
||||
const t = new Date(slot.time).getTime();
|
||||
slot.daytime = t >= new Date(slot.sunrise).getTime() && t < new Date(slot.sunset).getTime();
|
||||
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();
|
||||
const set = slot.sunset instanceof Date ? slot.sunset.getTime() : new Date(slot.sunset).getTime();
|
||||
slot.daytime = t >= rise && t < set;
|
||||
} else {
|
||||
slot.daytime = (slot.sun_elevation ?? 0) > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user