mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Convert openweathermap dewpoint from kelvin to celcius (#51893)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
ab73ce00a0
commit
3c0a24db50
@ -18,6 +18,7 @@ from homeassistant.components.weather import (
|
|||||||
ATTR_FORECAST_WIND_BEARING,
|
ATTR_FORECAST_WIND_BEARING,
|
||||||
ATTR_FORECAST_WIND_SPEED,
|
ATTR_FORECAST_WIND_SPEED,
|
||||||
)
|
)
|
||||||
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
from homeassistant.helpers import sun
|
from homeassistant.helpers import sun
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
from homeassistant.util import dt
|
from homeassistant.util import dt
|
||||||
@ -179,10 +180,10 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
|
|
||||||
return forecast
|
return forecast
|
||||||
|
|
||||||
@staticmethod
|
def _fmt_dewpoint(self, dewpoint):
|
||||||
def _fmt_dewpoint(dewpoint):
|
|
||||||
if dewpoint is not None:
|
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
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -187,6 +187,7 @@ def _create_mocked_owm(is_api_online: bool):
|
|||||||
weather.snow.return_value = []
|
weather.snow.return_value = []
|
||||||
weather.detailed_status.return_value = "status"
|
weather.detailed_status.return_value = "status"
|
||||||
weather.weather_code = 803
|
weather.weather_code = 803
|
||||||
|
weather.dewpoint = 10
|
||||||
|
|
||||||
mocked_owm.weather_at_coords.return_value.weather = weather
|
mocked_owm.weather_at_coords.return_value.weather = weather
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user