Add wind gust sensor to OpenWeatherMap (#150607)

This commit is contained in:
G Johansson
2025-08-13 23:34:12 +02:00
committed by GitHub
parent cf68214c4d
commit 4f64014816
4 changed files with 132 additions and 1 deletions

View File

@@ -51,6 +51,7 @@ from .const import (
ATTR_API_WEATHER,
ATTR_API_WEATHER_CODE,
ATTR_API_WIND_BEARING,
ATTR_API_WIND_GUST,
ATTR_API_WIND_SPEED,
ATTRIBUTION,
DOMAIN,
@@ -93,6 +94,13 @@ WEATHER_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
device_class=SensorDeviceClass.WIND_SPEED,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=ATTR_API_WIND_GUST,
name="Wind gust",
native_unit_of_measurement=UnitOfSpeed.METERS_PER_SECOND,
device_class=SensorDeviceClass.WIND_SPEED,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=ATTR_API_WIND_BEARING,
name="Wind bearing",

View File

@@ -77,8 +77,8 @@ def owm_client_mock() -> Generator[AsyncMock]:
cloud_coverage=75,
visibility=10000,
wind_speed=9.83,
wind_gust=11.81,
wind_bearing=199,
wind_gust=None,
rain={"1h": 1.21},
snow=None,
condition=WeatherCondition(

View File

@@ -1239,6 +1239,66 @@
'state': '199',
})
# ---
# name: test_sensor_states[current][sensor.openweathermap_wind_gust-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.openweathermap_wind_gust',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
'sensor.private': dict({
'suggested_unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
}),
}),
'original_device_class': <SensorDeviceClass.WIND_SPEED: 'wind_speed'>,
'original_icon': None,
'original_name': 'Wind gust',
'platform': 'openweathermap',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '12.34-56.78-wind_gust',
'unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
})
# ---
# name: test_sensor_states[current][sensor.openweathermap_wind_gust-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by OpenWeatherMap',
'device_class': 'wind_speed',
'friendly_name': 'openweathermap Wind gust',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
}),
'context': <ANY>,
'entity_id': 'sensor.openweathermap_wind_gust',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '42.516',
})
# ---
# name: test_sensor_states[current][sensor.openweathermap_wind_speed-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@@ -2108,6 +2168,66 @@
'state': '199',
})
# ---
# name: test_sensor_states[v3.0][sensor.openweathermap_wind_gust-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.openweathermap_wind_gust',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
'sensor.private': dict({
'suggested_unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
}),
}),
'original_device_class': <SensorDeviceClass.WIND_SPEED: 'wind_speed'>,
'original_icon': None,
'original_name': 'Wind gust',
'platform': 'openweathermap',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '12.34-56.78-wind_gust',
'unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
})
# ---
# name: test_sensor_states[v3.0][sensor.openweathermap_wind_gust-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by OpenWeatherMap',
'device_class': 'wind_speed',
'friendly_name': 'openweathermap Wind gust',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
}),
'context': <ANY>,
'entity_id': 'sensor.openweathermap_wind_gust',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '42.516',
})
# ---
# name: test_sensor_states[v3.0][sensor.openweathermap_wind_speed-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@@ -74,6 +74,7 @@
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
'visibility_unit': <UnitOfLength.KILOMETERS: 'km'>,
'wind_bearing': 199,
'wind_gust_speed': 42.52,
'wind_speed': 35.39,
'wind_speed_unit': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
}),
@@ -137,6 +138,7 @@
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
'visibility_unit': <UnitOfLength.KILOMETERS: 'km'>,
'wind_bearing': 199,
'wind_gust_speed': 42.52,
'wind_speed': 35.39,
'wind_speed_unit': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
}),
@@ -200,6 +202,7 @@
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
'visibility_unit': <UnitOfLength.KILOMETERS: 'km'>,
'wind_bearing': 199,
'wind_gust_speed': 42.52,
'wind_speed': 35.39,
'wind_speed_unit': <UnitOfSpeed.KILOMETERS_PER_HOUR: 'km/h'>,
}),