From 9a5e0281db476b598cadd421bfd1e6fc5b0582e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Mon, 9 May 2022 01:20:18 +0200 Subject: [PATCH] Add missing AEMET weather units (#70165) --- CODEOWNERS | 2 ++ homeassistant/components/aemet/manifest.json | 2 +- homeassistant/components/aemet/weather.py | 8 +++++--- tests/components/aemet/test_weather.py | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index ecb9115480f..2e2a8c0584f 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -32,6 +32,8 @@ build.json @home-assistant/supervisor /tests/components/adguard/ @frenck /homeassistant/components/advantage_air/ @Bre77 /tests/components/advantage_air/ @Bre77 +/homeassistant/components/aemet/ @Noltari +/tests/components/aemet/ @Noltari /homeassistant/components/agent_dvr/ @ispysoftware /tests/components/agent_dvr/ @ispysoftware /homeassistant/components/air_quality/ @home-assistant/core diff --git a/homeassistant/components/aemet/manifest.json b/homeassistant/components/aemet/manifest.json index 087d5c38820..e530489476e 100644 --- a/homeassistant/components/aemet/manifest.json +++ b/homeassistant/components/aemet/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/aemet", "requirements": ["AEMET-OpenData==0.2.1"], - "codeowners": [], + "codeowners": ["@Noltari"], "iot_class": "cloud_polling", "loggers": ["aemet_opendata"] } diff --git a/homeassistant/components/aemet/weather.py b/homeassistant/components/aemet/weather.py index 2bbb4d0da55..d05442b621e 100644 --- a/homeassistant/components/aemet/weather.py +++ b/homeassistant/components/aemet/weather.py @@ -1,7 +1,7 @@ """Support for the AEMET OpenData service.""" from homeassistant.components.weather import WeatherEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import PRESSURE_HPA, SPEED_KILOMETERS_PER_HOUR, TEMP_CELSIUS from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -48,6 +48,8 @@ class AemetWeather(CoordinatorEntity[WeatherUpdateCoordinator], WeatherEntity): _attr_attribution = ATTRIBUTION _attr_temperature_unit = TEMP_CELSIUS + _attr_pressure_unit = PRESSURE_HPA + _attr_wind_speed_unit = SPEED_KILOMETERS_PER_HOUR def __init__( self, @@ -92,10 +94,10 @@ class AemetWeather(CoordinatorEntity[WeatherUpdateCoordinator], WeatherEntity): @property def wind_bearing(self): - """Return the temperature.""" + """Return the wind bearing.""" return self.coordinator.data[ATTR_API_WIND_BEARING] @property def wind_speed(self): - """Return the temperature.""" + """Return the wind speed.""" return self.coordinator.data[ATTR_API_WIND_SPEED] diff --git a/tests/components/aemet/test_weather.py b/tests/components/aemet/test_weather.py index d1f1889c807..809b61e0bda 100644 --- a/tests/components/aemet/test_weather.py +++ b/tests/components/aemet/test_weather.py @@ -42,10 +42,10 @@ async def test_aemet_weather(hass): assert state.state == ATTR_CONDITION_SNOWY assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION assert state.attributes.get(ATTR_WEATHER_HUMIDITY) == 99.0 - assert state.attributes.get(ATTR_WEATHER_PRESSURE) == 1004.4 + assert state.attributes.get(ATTR_WEATHER_PRESSURE) == 100440.0 assert state.attributes.get(ATTR_WEATHER_TEMPERATURE) == -0.7 assert state.attributes.get(ATTR_WEATHER_WIND_BEARING) == 90.0 - assert state.attributes.get(ATTR_WEATHER_WIND_SPEED) == 15 + assert state.attributes.get(ATTR_WEATHER_WIND_SPEED) == 4.17 forecast = state.attributes.get(ATTR_FORECAST)[0] assert forecast.get(ATTR_FORECAST_CONDITION) == ATTR_CONDITION_PARTLYCLOUDY assert forecast.get(ATTR_FORECAST_PRECIPITATION) is None @@ -57,7 +57,7 @@ async def test_aemet_weather(hass): == dt_util.parse_datetime("2021-01-10 00:00:00+00:00").isoformat() ) assert forecast.get(ATTR_FORECAST_WIND_BEARING) == 45.0 - assert forecast.get(ATTR_FORECAST_WIND_SPEED) == 20 + assert forecast.get(ATTR_FORECAST_WIND_SPEED) == 5.56 state = hass.states.get("weather.aemet_hourly") assert state is None