diff --git a/homeassistant/components/aemet/weather.py b/homeassistant/components/aemet/weather.py index cf23d6f3643684..310c681d4b8742 100644 --- a/homeassistant/components/aemet/weather.py +++ b/homeassistant/components/aemet/weather.py @@ -1,7 +1,12 @@ """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 ( + LENGTH_MILLIMETERS, + PRESSURE_HPA, + SPEED_METERS_PER_SECOND, + TEMP_CELSIUS, +) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -48,6 +53,9 @@ class AemetWeather(CoordinatorEntity, WeatherEntity): _attr_attribution = ATTRIBUTION _attr_temperature_unit = TEMP_CELSIUS + _attr_pressure_unit = PRESSURE_HPA + _attr_wind_speed_unit = SPEED_METERS_PER_SECOND + _attr_precipitation_unit = LENGTH_MILLIMETERS def __init__( self, diff --git a/tests/components/aemet/test_weather.py b/tests/components/aemet/test_weather.py index 43acf4c1c8731c..f6bdbf1d4bf163 100644 --- a/tests/components/aemet/test_weather.py +++ b/tests/components/aemet/test_weather.py @@ -21,7 +21,7 @@ ATTR_WEATHER_WIND_BEARING, ATTR_WEATHER_WIND_SPEED, ) -from homeassistant.const import ATTR_ATTRIBUTION +from homeassistant.const import ATTR_ATTRIBUTION, PRESSURE_HPA import homeassistant.util.dt as dt_util from .util import async_init_integration @@ -30,6 +30,8 @@ async def test_aemet_weather(hass): """Test states of the weather.""" + hass.config.units.pressure_unit = PRESSURE_HPA + now = dt_util.parse_datetime("2021-01-09 12:00:00+00:00") with patch("homeassistant.util.dt.now", return_value=now), patch( "homeassistant.util.dt.utcnow", return_value=now