OpenSprinkler Forums OpenSprinkler Unified Firmware 200% watering because of -9999 precip today Reply To: 200% watering because of -9999 precip today

#42893

dolfs
Participant

Unfortunately there is yet another problem (which I discovered tonight). When you use parseFloat to convert yesterday’s precip to a float there will be a problem if the string was empty (which does happen with wunderground apparently). This then results in NaN and when you attempt to clamp against 0 for both today and yesterday and add them together, the result of the addition is then also NaN. This in turn results in 100% in Zimmerman. It makes sense to interpret an empty value as 0.

I suggest adding

   if (isNan(currentPrecip)) currentPrecip = 0.0
    if (isNan(yesterdayPrecip)) yesterdayPrecip = 0.0

alternatively

   precip:		( (currentPrecip < 0) || isNan(currentPrecip)) ? 0 : currentPrecip ) + (( yesterdayPrecip < 0 || isNan(yesterdayPrecip)) ? 0 : yesterdayPrecip ),