Add missing attributes to weather entity (#172494)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Arsène Reymond
2026-07-26 21:25:17 +02:00
committed by GitHub
parent 8e4aa62911
commit fa3125fcac
2 changed files with 21 additions and 0 deletions
@@ -9,12 +9,14 @@ from homeassistant.components.weather import (
ATTR_CONDITION_SUNNY,
ATTR_FORECAST_CONDITION,
ATTR_FORECAST_HUMIDITY,
ATTR_FORECAST_NATIVE_APPARENT_TEMP,
ATTR_FORECAST_NATIVE_PRECIPITATION,
ATTR_FORECAST_NATIVE_TEMP,
ATTR_FORECAST_NATIVE_TEMP_LOW,
ATTR_FORECAST_NATIVE_WIND_GUST_SPEED,
ATTR_FORECAST_NATIVE_WIND_SPEED,
ATTR_FORECAST_TIME,
ATTR_FORECAST_UV_INDEX,
ATTR_FORECAST_WIND_BEARING,
Forecast,
WeatherEntity,
@@ -142,6 +144,12 @@ class MeteoFranceWeather(
"""Return the temperature."""
return self.coordinator.data.current_forecast["T"]["value"]
@property
@override
def native_apparent_temperature(self) -> float | None:
"""Return the apparent temperature."""
return self.coordinator.data.current_forecast["T"].get("windchill")
@property
@override
def native_pressure(self) -> float:
@@ -154,6 +162,13 @@ class MeteoFranceWeather(
"""Return the humidity."""
return self.coordinator.data.current_forecast["humidity"]
@property
@override
def uv_index(self) -> float | None:
"""Return the UV index."""
uv_index = self.coordinator.data.current_forecast.get("uv")
return float(uv_index) if uv_index is not None else None
@property
@override
def native_wind_speed(self) -> float:
@@ -195,7 +210,11 @@ class MeteoFranceWeather(
),
ATTR_FORECAST_HUMIDITY: forecast["humidity"],
ATTR_FORECAST_NATIVE_TEMP: forecast["T"]["value"],
ATTR_FORECAST_NATIVE_APPARENT_TEMP: forecast["T"].get(
"windchill"
),
ATTR_FORECAST_NATIVE_PRECIPITATION: forecast["rain"].get("1h"),
ATTR_FORECAST_UV_INDEX: forecast.get("uv"),
ATTR_FORECAST_NATIVE_WIND_SPEED: forecast["wind"]["speed"],
ATTR_FORECAST_NATIVE_WIND_GUST_SPEED: forecast["wind"].get(
"gust"
@@ -39,6 +39,7 @@
# name: test_weather[weather.meteo_france_forecast_for_city_la_clusaz_la_clusaz-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<WeatherEntityStateAttribute.APPARENT_TEMPERATURE: 'apparent_temperature'>: 5.4,
<EntityStateAttribute.ATTRIBUTION: 'attribution'>: 'Data provided by Météo-France',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Météo-France forecast for city La Clusaz La Clusaz',
<WeatherEntityStateAttribute.HUMIDITY: 'humidity'>: 75,
@@ -48,6 +49,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WeatherEntityFeature: 3>,
<WeatherEntityStateAttribute.TEMPERATURE: 'temperature'>: 9.1,
<WeatherEntityStateAttribute.TEMPERATURE_UNIT: 'temperature_unit'>: <UnitOfTemperature.CELSIUS: '°C'>,
<WeatherEntityStateAttribute.UV_INDEX: 'uv_index'>: 1.0,
<WeatherEntityStateAttribute.VISIBILITY_UNIT: 'visibility_unit'>: <UnitOfLength.KILOMETERS: 'km'>,
<WeatherEntityStateAttribute.WIND_BEARING: 'wind_bearing'>: 200,
<WeatherEntityStateAttribute.WIND_GUST_SPEED: 'wind_gust_speed'>: 64.8,