Skip to content

Commit

Permalink
Add missing AEMET wind gust speed (#100157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Noltari authored Sep 12, 2023
1 parent 80b03b4 commit da13afb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion homeassistant/components/aemet/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
ATTR_API_FORECAST_TEMP_LOW,
ATTR_API_FORECAST_TIME,
ATTR_API_FORECAST_WIND_BEARING,
ATTR_API_FORECAST_WIND_MAX_SPEED,
ATTR_API_FORECAST_WIND_SPEED,
ATTR_API_HUMIDITY,
ATTR_API_PRESSURE,
Expand Down Expand Up @@ -99,6 +100,12 @@
name="Wind bearing",
native_unit_of_measurement=DEGREE,
),
SensorEntityDescription(
key=ATTR_API_FORECAST_WIND_MAX_SPEED,
name="Wind max speed",
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.WIND_SPEED,
),
SensorEntityDescription(
key=ATTR_API_FORECAST_WIND_SPEED,
name="Wind speed",
Expand Down Expand Up @@ -206,13 +213,14 @@
name="Wind max speed",
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.WIND_SPEED,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=ATTR_API_WIND_SPEED,
name="Wind speed",
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.WIND_SPEED,
state_class=SensorStateClass.MEASUREMENT,
),
)

Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/aemet/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
ATTR_API_PRESSURE,
ATTR_API_TEMPERATURE,
ATTR_API_WIND_BEARING,
ATTR_API_WIND_MAX_SPEED,
ATTR_API_WIND_SPEED,
ATTRIBUTION,
DOMAIN,
Expand Down Expand Up @@ -193,6 +194,11 @@ def wind_bearing(self):
"""Return the wind bearing."""
return self.coordinator.data[ATTR_API_WIND_BEARING]

@property
def native_wind_gust_speed(self):
"""Return the wind gust speed in native units."""
return self.coordinator.data[ATTR_API_WIND_MAX_SPEED]

@property
def native_wind_speed(self):
"""Return the wind speed."""
Expand Down
3 changes: 3 additions & 0 deletions tests/components/aemet/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ async def test_aemet_forecast_create_sensors(
state = hass.states.get("sensor.aemet_hourly_forecast_wind_bearing")
assert state is None

state = hass.states.get("sensor.aemet_hourly_forecast_wind_max_speed")
assert state is None

state = hass.states.get("sensor.aemet_hourly_forecast_wind_speed")
assert state is None

Expand Down
3 changes: 3 additions & 0 deletions tests/components/aemet/test_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
ATTR_WEATHER_PRESSURE,
ATTR_WEATHER_TEMPERATURE,
ATTR_WEATHER_WIND_BEARING,
ATTR_WEATHER_WIND_GUST_SPEED,
ATTR_WEATHER_WIND_SPEED,
DOMAIN as WEATHER_DOMAIN,
SERVICE_GET_FORECAST,
Expand Down Expand Up @@ -58,6 +59,7 @@ async def test_aemet_weather(
assert state.attributes.get(ATTR_WEATHER_PRESSURE) == 1004.4 # 100440.0 Pa -> hPa
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_GUST_SPEED) == 24.0
assert state.attributes.get(ATTR_WEATHER_WIND_SPEED) == 15.0 # 4.17 m/s -> km/h
forecast = state.attributes.get(ATTR_FORECAST)[0]
assert forecast.get(ATTR_FORECAST_CONDITION) == ATTR_CONDITION_PARTLYCLOUDY
Expand Down Expand Up @@ -101,6 +103,7 @@ async def test_aemet_weather_legacy(
assert state.attributes.get(ATTR_WEATHER_PRESSURE) == 1004.4 # 100440.0 Pa -> hPa
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_GUST_SPEED) == 24.0
assert state.attributes.get(ATTR_WEATHER_WIND_SPEED) == 15.0 # 4.17 m/s -> km/h
forecast = state.attributes.get(ATTR_FORECAST)[0]
assert forecast.get(ATTR_FORECAST_CONDITION) == ATTR_CONDITION_PARTLYCLOUDY
Expand Down

0 comments on commit da13afb

Please sign in to comment.