From 4e522448b11e890d1ad0fa6d829e3fef5af1bee1 Mon Sep 17 00:00:00 2001 From: Philip Rosenberg-Watt Date: Tue, 27 Feb 2018 12:19:02 -0700 Subject: [PATCH] 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. --- homeassistant/components/weather/darksky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/weather/darksky.py b/homeassistant/components/weather/darksky.py index 21f67ce080a..139f8abfce6 100644 --- a/homeassistant/components/weather/darksky.py +++ b/homeassistant/components/weather/darksky.py @@ -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):