Skip to content

Commit 4f64014

Browse files
Add wind gust sensor to OpenWeatherMap (home-assistant#150607)
1 parent cf68214 commit 4f64014

File tree

4 files changed

+132
-1
lines changed

4 files changed

+132
-1
lines changed

homeassistant/components/openweathermap/sensor.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
ATTR_API_WEATHER,
5252
ATTR_API_WEATHER_CODE,
5353
ATTR_API_WIND_BEARING,
54+
ATTR_API_WIND_GUST,
5455
ATTR_API_WIND_SPEED,
5556
ATTRIBUTION,
5657
DOMAIN,
@@ -93,6 +94,13 @@
9394
device_class=SensorDeviceClass.WIND_SPEED,
9495
state_class=SensorStateClass.MEASUREMENT,
9596
),
97+
SensorEntityDescription(
98+
key=ATTR_API_WIND_GUST,
99+
name="Wind gust",
100+
native_unit_of_measurement=UnitOfSpeed.METERS_PER_SECOND,
101+
device_class=SensorDeviceClass.WIND_SPEED,
102+
state_class=SensorStateClass.MEASUREMENT,
103+
),
96104
SensorEntityDescription(
97105
key=ATTR_API_WIND_BEARING,
98106
name="Wind bearing",

tests/components/openweathermap/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def owm_client_mock() -> Generator[AsyncMock]:
7777
cloud_coverage=75,
7878
visibility=10000,
7979
wind_speed=9.83,
80+
wind_gust=11.81,
8081
wind_bearing=199,
81-
wind_gust=None,
8282
rain={"1h": 1.21},
8383
snow=None,
8484
condition=WeatherCondition(

tests/components/openweathermap/snapshots/test_sensor.ambr

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,66 @@
12391239
'state': '199',
12401240
})
12411241
# ---
1242+
# name: test_sensor_states[current][sensor.openweathermap_wind_gust-entry]
1243+
EntityRegistryEntrySnapshot({
1244+
'aliases': set({
1245+
}),
1246+
'area_id': None,
1247+
'capabilities': dict({
1248+
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
1249+
}),
1250+
'config_entry_id': <ANY>,
1251+
'config_subentry_id': <ANY>,
1252+
'device_class': None,
1253+
'device_id': <ANY>,
1254+
'disabled_by': None,
1255+
'domain': 'sensor',
1256+
'entity_category': None,
1257+
'entity_id': 'sensor.openweathermap_wind_gust',
1258+
'has_entity_name': True,
1259+
'hidden_by': None,
1260+
'icon': None,
1261+
'id': <ANY>,
1262+
'labels': set({
1263+
}),
1264+
'name': None,
1265+
'options': dict({
1266+
'sensor': dict({
1267+
'suggested_display_precision': 2,
1268+
}),
1269+
'sensor.private': dict({
1270+
'suggested_unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
1271+
}),
1272+
}),
1273+
'original_device_class': <SensorDeviceClass.WIND_SPEED: 'wind_speed'>,
1274+
'original_icon': None,
1275+
'original_name': 'Wind gust',
1276+
'platform': 'openweathermap',
1277+
'previous_unique_id': None,
1278+
'suggested_object_id': None,
1279+
'supported_features': 0,
1280+
'translation_key': None,
1281+
'unique_id': '12.34-56.78-wind_gust',
1282+
'unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
1283+
})
1284+
# ---
1285+
# name: test_sensor_states[current][sensor.openweathermap_wind_gust-state]
1286+
StateSnapshot({
1287+
'attributes': ReadOnlyDict({
1288+
'attribution': 'Data provided by OpenWeatherMap',
1289+
'device_class': 'wind_speed',
1290+
'friendly_name': 'openweathermap Wind gust',
1291+
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
1292+
'unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
1293+
}),
1294+
'context': <ANY>,
1295+
'entity_id': 'sensor.openweathermap_wind_gust',
1296+
'last_changed': <ANY>,
1297+
'last_reported': <ANY>,
1298+
'last_updated': <ANY>,
1299+
'state': '42.516',
1300+
})
1301+
# ---
12421302
# name: test_sensor_states[current][sensor.openweathermap_wind_speed-entry]
12431303
EntityRegistryEntrySnapshot({
12441304
'aliases': set({
@@ -2108,6 +2168,66 @@
21082168
'state': '199',
21092169
})
21102170
# ---
2171+
# name: test_sensor_states[v3.0][sensor.openweathermap_wind_gust-entry]
2172+
EntityRegistryEntrySnapshot({
2173+
'aliases': set({
2174+
}),
2175+
'area_id': None,
2176+
'capabilities': dict({
2177+
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
2178+
}),
2179+
'config_entry_id': <ANY>,
2180+
'config_subentry_id': <ANY>,
2181+
'device_class': None,
2182+
'device_id': <ANY>,
2183+
'disabled_by': None,
2184+
'domain': 'sensor',
2185+
'entity_category': None,
2186+
'entity_id': 'sensor.openweathermap_wind_gust',
2187+
'has_entity_name': True,
2188+
'hidden_by': None,
2189+
'icon': None,
2190+
'id': <ANY>,
2191+
'labels': set({
2192+
}),
2193+
'name': None,
2194+
'options': dict({
2195+
'sensor': dict({
2196+
'suggested_display_precision': 2,
2197+
}),
2198+
'sensor.private': dict({
2199+
'suggested_unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
2200+
}),
2201+
}),
2202+
'original_device_class': <SensorDeviceClass.WIND_SPEED: 'wind_speed'>,
2203+
'original_icon': None,
2204+
'original_name': 'Wind gust',
2205+
'platform': 'openweathermap',
2206+
'previous_unique_id': None,
2207+
'suggested_object_id': None,
2208+
'supported_features': 0,
2209+
'translation_key': None,
2210+
'unique_id': '12.34-56.78-wind_gust',
2211+
'unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
2212+
})
2213+
# ---
2214+
# name: test_sensor_states[v3.0][sensor.openweathermap_wind_gust-state]
2215+
StateSnapshot({
2216+
'attributes': ReadOnlyDict({
2217+
'attribution': 'Data provided by OpenWeatherMap',
2218+
'device_class': 'wind_speed',
2219+
'friendly_name': 'openweathermap Wind gust',
2220+
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
2221+
'unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
2222+
}),
2223+
'context': <ANY>,
2224+
'entity_id': 'sensor.openweathermap_wind_gust',
2225+
'last_changed': <ANY>,
2226+
'last_reported': <ANY>,
2227+
'last_updated': <ANY>,
2228+
'state': '42.516',
2229+
})
2230+
# ---
21112231
# name: test_sensor_states[v3.0][sensor.openweathermap_wind_speed-entry]
21122232
EntityRegistryEntrySnapshot({
21132233
'aliases': set({

tests/components/openweathermap/snapshots/test_weather.ambr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
7575
'visibility_unit': <UnitOfLength.KILOMETERS: 'km'>,
7676
'wind_bearing': 199,
77+
'wind_gust_speed': 42.52,
7778
'wind_speed': 35.39,
7879
'wind_speed_unit': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
7980
}),
@@ -137,6 +138,7 @@
137138
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
138139
'visibility_unit': <UnitOfLength.KILOMETERS: 'km'>,
139140
'wind_bearing': 199,
141+
'wind_gust_speed': 42.52,
140142
'wind_speed': 35.39,
141143
'wind_speed_unit': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
142144
}),
@@ -200,6 +202,7 @@
200202
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
201203
'visibility_unit': <UnitOfLength.KILOMETERS: 'km'>,
202204
'wind_bearing': 199,
205+
'wind_gust_speed': 42.52,
203206
'wind_speed': 35.39,
204207
'wind_speed_unit': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
205208
}),

0 commit comments

Comments
 (0)