mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Remove arbitrary forecast limit for meteo_lt (#155877)
This commit is contained in:
@@ -139,7 +139,7 @@ class MeteoLtWeatherEntity(CoordinatorEntity[MeteoLtUpdateCoordinator], WeatherE
|
||||
forecasts_by_date[date].append(timestamp)
|
||||
|
||||
daily_forecasts = []
|
||||
for date in sorted(forecasts_by_date.keys())[:5]:
|
||||
for date in sorted(forecasts_by_date.keys()):
|
||||
day_forecasts = forecasts_by_date[date]
|
||||
if not day_forecasts:
|
||||
continue
|
||||
@@ -186,5 +186,5 @@ class MeteoLtWeatherEntity(CoordinatorEntity[MeteoLtUpdateCoordinator], WeatherE
|
||||
return None
|
||||
return [
|
||||
self._convert_forecast_data(forecast_data)
|
||||
for forecast_data in self.coordinator.data.forecast_timestamps[:24]
|
||||
for forecast_data in self.coordinator.data.forecast_timestamps
|
||||
]
|
||||
|
||||
@@ -48,6 +48,84 @@
|
||||
"relativeHumidity": 65,
|
||||
"totalPrecipitation": 0.1,
|
||||
"conditionCode": "cloudy"
|
||||
},
|
||||
{
|
||||
"forecastTimeUtc": "2025-09-26 10:00:00",
|
||||
"airTemperature": 15.0,
|
||||
"feelsLikeTemperature": 15.0,
|
||||
"windSpeed": 3,
|
||||
"windGust": 9,
|
||||
"windDirection": 35,
|
||||
"cloudCover": 30,
|
||||
"seaLevelPressure": 1030,
|
||||
"relativeHumidity": 60,
|
||||
"totalPrecipitation": 0.2,
|
||||
"conditionCode": "cloudy"
|
||||
},
|
||||
{
|
||||
"forecastTimeUtc": "2025-09-27 10:00:00",
|
||||
"airTemperature": 16.0,
|
||||
"feelsLikeTemperature": 16.0,
|
||||
"windSpeed": 4,
|
||||
"windGust": 10,
|
||||
"windDirection": 40,
|
||||
"cloudCover": 35,
|
||||
"seaLevelPressure": 1029,
|
||||
"relativeHumidity": 55,
|
||||
"totalPrecipitation": 0.3,
|
||||
"conditionCode": "rainy"
|
||||
},
|
||||
{
|
||||
"forecastTimeUtc": "2025-09-28 10:00:00",
|
||||
"airTemperature": 17.0,
|
||||
"feelsLikeTemperature": 17.0,
|
||||
"windSpeed": 5,
|
||||
"windGust": 11,
|
||||
"windDirection": 45,
|
||||
"cloudCover": 40,
|
||||
"seaLevelPressure": 1028,
|
||||
"relativeHumidity": 50,
|
||||
"totalPrecipitation": 0.4,
|
||||
"conditionCode": "rainy"
|
||||
},
|
||||
{
|
||||
"forecastTimeUtc": "2025-09-29 10:00:00",
|
||||
"airTemperature": 18.0,
|
||||
"feelsLikeTemperature": 18.0,
|
||||
"windSpeed": 6,
|
||||
"windGust": 12,
|
||||
"windDirection": 50,
|
||||
"cloudCover": 45,
|
||||
"seaLevelPressure": 1027,
|
||||
"relativeHumidity": 45,
|
||||
"totalPrecipitation": 0.5,
|
||||
"conditionCode": "rainy"
|
||||
},
|
||||
{
|
||||
"forecastTimeUtc": "2025-09-30 10:00:00",
|
||||
"airTemperature": 19.0,
|
||||
"feelsLikeTemperature": 19.0,
|
||||
"windSpeed": 7,
|
||||
"windGust": 13,
|
||||
"windDirection": 55,
|
||||
"cloudCover": 50,
|
||||
"seaLevelPressure": 1026,
|
||||
"relativeHumidity": 40,
|
||||
"totalPrecipitation": 0.6,
|
||||
"conditionCode": "rainy"
|
||||
},
|
||||
{
|
||||
"forecastTimeUtc": "2025-10-01 10:00:00",
|
||||
"airTemperature": 20.0,
|
||||
"feelsLikeTemperature": 20.0,
|
||||
"windSpeed": 8,
|
||||
"windGust": 14,
|
||||
"windDirection": 60,
|
||||
"cloudCover": 55,
|
||||
"seaLevelPressure": 1025,
|
||||
"relativeHumidity": 35,
|
||||
"totalPrecipitation": 0.7,
|
||||
"conditionCode": "rainy"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -34,3 +34,34 @@ async def test_weather_entity(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2025-09-25 9:00:00")
|
||||
async def test_forecast_no_limits(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that forecast returns all available data from API without limits."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.services.async_call(
|
||||
"weather",
|
||||
"get_forecasts",
|
||||
{"entity_id": "weather.vilnius", "type": "hourly"},
|
||||
blocking=True,
|
||||
return_response=True,
|
||||
)
|
||||
hourly_forecasts = result["weather.vilnius"]["forecast"]
|
||||
assert len(hourly_forecasts) == 9
|
||||
|
||||
result = await hass.services.async_call(
|
||||
"weather",
|
||||
"get_forecasts",
|
||||
{"entity_id": "weather.vilnius", "type": "daily"},
|
||||
blocking=True,
|
||||
return_response=True,
|
||||
)
|
||||
daily_forecasts = result["weather.vilnius"]["forecast"]
|
||||
assert len(daily_forecasts) == 7
|
||||
|
||||
Reference in New Issue
Block a user