Fix DarkSky floating-point math (#12753)

DarkSky delivers relative humidity from 0-100% as a 0-1 decimal value,
so we convert it by multiplying by 100.0. Unfortunately, due to floating
point math, the display of a raw value of 0.29 ends up looking like
28.999999999999996% relative humidity.

This change rounds the value to two decimal places.
This commit is contained in:
Philip Rosenberg-Watt 2018-02-27 12:19:02 -07:00 committed by Paulus Schoutsen
parent 8645f244da
commit 4e522448b1

View File

@ -96,7 +96,7 @@ class DarkSkyWeather(WeatherEntity):
@property
def humidity(self):
"""Return the humidity."""
return self._ds_currently.get('humidity') * 100.0
return round(self._ds_currently.get('humidity') * 100.0, 2)
@property
def wind_speed(self):