Convert openweathermap dewpoint from kelvin to celcius (#51893)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev>pull/50412/head
parent
ab73ce00a0
commit
3c0a24db50
|
@ -18,6 +18,7 @@ from homeassistant.components.weather import (
|
|||
ATTR_FORECAST_WIND_BEARING,
|
||||
ATTR_FORECAST_WIND_SPEED,
|
||||
)
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
from homeassistant.helpers import sun
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
from homeassistant.util import dt
|
||||
|
@ -179,10 +180,10 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
|
|||
|
||||
return forecast
|
||||
|
||||
@staticmethod
|
||||
def _fmt_dewpoint(dewpoint):
|
||||
def _fmt_dewpoint(self, dewpoint):
|
||||
if dewpoint is not None:
|
||||
return round(dewpoint / 100, 1)
|
||||
dewpoint = dewpoint - 273.15
|
||||
return round(self.hass.config.units.temperature(dewpoint, TEMP_CELSIUS), 1)
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -187,6 +187,7 @@ def _create_mocked_owm(is_api_online: bool):
|
|||
weather.snow.return_value = []
|
||||
weather.detailed_status.return_value = "status"
|
||||
weather.weather_code = 803
|
||||
weather.dewpoint = 10
|
||||
|
||||
mocked_owm.weather_at_coords.return_value.weather = weather
|
||||
|
||||
|
|
Loading…
Reference in New Issue