switchdoclabs / OurWeatherWeatherPlus

OurWeather Software for WeatherPlus Board - creates (or you rename) a directory called "SDL_ESP8266_WeatherPlus"
http://www.switchdoc.com
20 stars 32 forks source link

NAN handling creates invalid JSON #21

Open ConorIA opened 4 years ago

ConorIA commented 4 years ago

When the AM2315 returns bad values, these are currently set to NAN. The JSON returned from the REST API contains these values as nan, which is invalid because strings must be enclosed in quotes. Reading the JSON in R or Home Assistant fails with errors.

On my local compile, I've opted to replace the NANs with -999 and the JSON is parsed coreectly.

Another option would be to return null in place of the nan as null is valid JSON. I'm not sure whether this change should happen when the values are read or when the values are inserted into the JSON return.