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
Fabian Zimmermann 2021-06-28 11:35:33 +02:00 committed by GitHub
parent ab73ce00a0
commit 3c0a24db50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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