mirror of
https://github.com/home-assistant/core.git
synced 2025-05-02 21:19:16 +00:00
Round humidity for display purposes (#12766)
Humidity was not being rounded as temperature was. This change fixes that.
This commit is contained in:
parent
9658f4383c
commit
e82b358831
@ -110,7 +110,7 @@ class WeatherEntity(Entity):
|
|||||||
ATTR_WEATHER_TEMPERATURE: show_temp(
|
ATTR_WEATHER_TEMPERATURE: show_temp(
|
||||||
self.hass, self.temperature, self.temperature_unit,
|
self.hass, self.temperature, self.temperature_unit,
|
||||||
self.precision),
|
self.precision),
|
||||||
ATTR_WEATHER_HUMIDITY: self.humidity,
|
ATTR_WEATHER_HUMIDITY: round(self.humidity)
|
||||||
}
|
}
|
||||||
|
|
||||||
ozone = self.ozone
|
ozone = self.ozone
|
||||||
|
@ -96,7 +96,7 @@ class DarkSkyWeather(WeatherEntity):
|
|||||||
@property
|
@property
|
||||||
def humidity(self):
|
def humidity(self):
|
||||||
"""Return the humidity."""
|
"""Return the humidity."""
|
||||||
return round(self._ds_currently.get('humidity') * 100.0, 2)
|
return self._ds_currently.get('humidity') * 100.0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wind_speed(self):
|
def wind_speed(self):
|
||||||
|
@ -3,11 +3,12 @@ from numbers import Number
|
|||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.util.temperature import convert as convert_temperature
|
from homeassistant.util.temperature import convert as convert_temperature
|
||||||
|
from homeassistant.const import PRECISION_HALVES, PRECISION_TENTHS
|
||||||
|
|
||||||
|
|
||||||
def display_temp(hass: HomeAssistant, temperature: float, unit: str,
|
def display_temp(hass: HomeAssistant, temperature: float, unit: str,
|
||||||
precision: float) -> float:
|
precision: float) -> float:
|
||||||
"""Convert temperature into preferred units for display purposes."""
|
"""Convert temperature into preferred units/precision for display."""
|
||||||
temperature_unit = unit
|
temperature_unit = unit
|
||||||
ha_unit = hass.config.units.temperature_unit
|
ha_unit = hass.config.units.temperature_unit
|
||||||
|
|
||||||
@ -25,9 +26,12 @@ def display_temp(hass: HomeAssistant, temperature: float, unit: str,
|
|||||||
temperature, temperature_unit, ha_unit)
|
temperature, temperature_unit, ha_unit)
|
||||||
|
|
||||||
# Round in the units appropriate
|
# Round in the units appropriate
|
||||||
if precision == 0.5:
|
if precision == PRECISION_HALVES:
|
||||||
return round(temperature * 2) / 2.0
|
temperature = round(temperature * 2) / 2.0
|
||||||
elif precision == 0.1:
|
elif precision == PRECISION_TENTHS:
|
||||||
return round(temperature, 1)
|
temperature = round(temperature, 1)
|
||||||
# Integer as a fall back (PRECISION_WHOLE)
|
# Integer as a fall back (PRECISION_WHOLE)
|
||||||
return round(temperature)
|
else:
|
||||||
|
temperature = round(temperature)
|
||||||
|
|
||||||
|
return temperature
|
||||||
|
Loading…
x
Reference in New Issue
Block a user