-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Description
The LocalWeatherProvider in tag pr-170 throws "insufficient data" error when using Zimmerman watering algorithm with a PWS that does not provide solarRadiation data.
Environment
- Docker image:
ghcr.io/opensprinkler/weather-server:pr-170 - Weather provider:
local(PWS via WeeWX) - Watering algorithm: Zimmerman (selected in OpenSprinkler device)
- PWS: Weather station without solar radiation sensor
Problem
All observations in observations.json have "solarRadiation":null because the PWS doesn't have a solar sensor. This causes the weather server to continuously throw:
There is insufficient data to support watering calculation from local PWS.
Root Cause
In /weather/dist/index.cjs line ~XX (LocalWeatherProvider):
const avgSolar = dayObs.reduce((sum, obs) =>
!isNaN(obs.solarRadiation) && ++cSolar2 ? sum + obs.solarRadiation : sum,
0) / cSolar2;
if (!(cTemp2 && cHumidity2 && cPrecip2) ||
[minTemp, minHum, -maxTemp, -maxHum].includes(Infinity) ||
!(cSolar2 && cWind2 && cPrecip2)) { // <- THIS FAILS
throw new CodedError(10);
}When solarRadiation is null:
isNaN(null)returnsfalsecSolarstays0- Condition
!(cSolar2 && ...)istrue→ Error thrown
Expected Behavior
Zimmerman algorithm does NOT require solarRadiation - it only uses temperature, humidity, and rain. The check should allow cSolar == 0 when using Zimmerman.
Suggested Fix
Differentiate between ETo (which requires solarRadiation) and Zimmerman (which doesn't):
// Only require solar/wind for ETo calculations
if (!(cTemp2 && cHumidity2 && cPrecip2) ||
[minTemp, minHum, -maxTemp, -maxHum].includes(Infinity)) {
throw new CodedError(10);
}
// For ETo: additionally require solar and wind
if (isEToCalculation && !(cSolar2 && cWind2)) {
throw new CodedError(10);
}Workaround
Switch to :release tag (but loses 7-day historical data feature from pr-170)
Additional Context
- 323 observations collected over 27 hours
- All other data (temp, humidity, wind, precip) are valid
- Data retention appears to be ~24 hours (288 entries)
- Forum discussion confirms this is a known issue: https://opensprinkler.com/forums/topic/opensprinkler-and-pws/
Metadata
Metadata
Assignees
Labels
No labels