Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion homeassistant/components/aemet/weather.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion tests/components/aemet/test_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down