1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-15 07:36:16 +00:00

Show current day/hour in metoffice forecasts (#152689)

This commit is contained in:
avee87
2025-10-25 00:14:46 +01:00
committed by GitHub
parent d9f6a6bf99
commit 27390647ff
2 changed files with 152 additions and 3 deletions

View File

@@ -270,10 +270,13 @@ class MetOfficeWeather(
self.forecast_coordinators["daily"],
)
timesteps = coordinator.data.timesteps
start_datetime = datetime.now(tz=timesteps[0]["time"].tzinfo).replace(
hour=0, minute=0, second=0, microsecond=0
)
return [
_build_daily_forecast_data(timestep)
for timestep in timesteps
if timestep["time"] > datetime.now(tz=timesteps[0]["time"].tzinfo)
if timestep["time"] >= start_datetime
]
@callback
@@ -285,10 +288,13 @@ class MetOfficeWeather(
)
timesteps = coordinator.data.timesteps
start_datetime = datetime.now(tz=timesteps[0]["time"].tzinfo).replace(
minute=0, second=0, microsecond=0
)
return [
_build_hourly_forecast_data(timestep)
for timestep in timesteps
if timestep["time"] > datetime.now(tz=timesteps[0]["time"].tzinfo)
if timestep["time"] >= start_datetime
]
@callback
@@ -299,8 +305,11 @@ class MetOfficeWeather(
self.forecast_coordinators["twice_daily"],
)
timesteps = coordinator.data.timesteps
start_datetime = datetime.now(tz=timesteps[0]["time"].tzinfo).replace(
hour=0, minute=0, second=0, microsecond=0
)
return [
_build_twice_daily_forecast_data(timestep)
for timestep in timesteps
if timestep["time"] > datetime.now(tz=timesteps[0]["time"].tzinfo)
if timestep["time"] >= start_datetime
]

View File

@@ -3,6 +3,20 @@
dict({
'weather.met_office_wavertree': dict({
'forecast': list([
dict({
'apparent_temperature': 9.8,
'condition': 'rainy',
'datetime': '2024-11-23T00:00:00+00:00',
'precipitation': None,
'precipitation_probability': 65,
'pressure': 987.5,
'temperature': 12.6,
'templow': 11.5,
'uv_index': 1,
'wind_bearing': 176,
'wind_gust_speed': 55.55,
'wind_speed': 28.33,
}),
dict({
'apparent_temperature': 9.2,
'condition': 'cloudy',
@@ -95,6 +109,19 @@
dict({
'weather.met_office_wavertree': dict({
'forecast': list([
dict({
'apparent_temperature': 5.8,
'condition': 'rainy',
'datetime': '2024-11-23T12:00:00+00:00',
'precipitation': 0.25,
'precipitation_probability': 61,
'pressure': 987.5,
'temperature': 9.3,
'uv_index': 1,
'wind_bearing': 176,
'wind_gust_speed': 55.55,
'wind_speed': 28.33,
}),
dict({
'apparent_temperature': 6.8,
'condition': 'rainy',
@@ -727,6 +754,36 @@
dict({
'weather.met_office_wavertree': dict({
'forecast': list([
dict({
'apparent_temperature': 9.5,
'condition': 'rainy',
'datetime': '2024-11-23T00:00:00+00:00',
'is_daytime': False,
'precipitation': None,
'precipitation_probability': 74,
'pressure': 984.9,
'temperature': 13.9,
'templow': 10.7,
'uv_index': None,
'wind_bearing': 171,
'wind_gust_speed': 50.69,
'wind_speed': 26.78,
}),
dict({
'apparent_temperature': 9.8,
'condition': 'rainy',
'datetime': '2024-11-23T12:00:00+00:00',
'is_daytime': True,
'precipitation': None,
'precipitation_probability': 65,
'pressure': 987.5,
'temperature': 14.5,
'templow': 11.6,
'uv_index': 1,
'wind_bearing': 176,
'wind_gust_speed': 55.55,
'wind_speed': 28.33,
}),
dict({
'apparent_temperature': 4.8,
'condition': 'cloudy',
@@ -915,6 +972,20 @@
dict({
'weather.met_office_wavertree': dict({
'forecast': list([
dict({
'apparent_temperature': 9.8,
'condition': 'rainy',
'datetime': '2024-11-23T00:00:00+00:00',
'precipitation': None,
'precipitation_probability': 65,
'pressure': 987.5,
'temperature': 12.6,
'templow': 11.5,
'uv_index': 1,
'wind_bearing': 176,
'wind_gust_speed': 55.55,
'wind_speed': 28.33,
}),
dict({
'apparent_temperature': 9.2,
'condition': 'cloudy',
@@ -1007,6 +1078,19 @@
dict({
'weather.met_office_wavertree': dict({
'forecast': list([
dict({
'apparent_temperature': 5.8,
'condition': 'rainy',
'datetime': '2024-11-23T12:00:00+00:00',
'precipitation': 0.25,
'precipitation_probability': 61,
'pressure': 987.5,
'temperature': 9.3,
'uv_index': 1,
'wind_bearing': 176,
'wind_gust_speed': 55.55,
'wind_speed': 28.33,
}),
dict({
'apparent_temperature': 6.8,
'condition': 'rainy',
@@ -1639,6 +1723,36 @@
dict({
'weather.met_office_wavertree': dict({
'forecast': list([
dict({
'apparent_temperature': 9.5,
'condition': 'rainy',
'datetime': '2024-11-23T00:00:00+00:00',
'is_daytime': False,
'precipitation': None,
'precipitation_probability': 74,
'pressure': 984.9,
'temperature': 13.9,
'templow': 10.7,
'uv_index': None,
'wind_bearing': 171,
'wind_gust_speed': 50.69,
'wind_speed': 26.78,
}),
dict({
'apparent_temperature': 9.8,
'condition': 'rainy',
'datetime': '2024-11-23T12:00:00+00:00',
'is_daytime': True,
'precipitation': None,
'precipitation_probability': 65,
'pressure': 987.5,
'temperature': 14.5,
'templow': 11.6,
'uv_index': 1,
'wind_bearing': 176,
'wind_gust_speed': 55.55,
'wind_speed': 28.33,
}),
dict({
'apparent_temperature': 4.8,
'condition': 'cloudy',
@@ -1825,6 +1939,19 @@
# ---
# name: test_forecast_subscription
list([
dict({
'apparent_temperature': 5.8,
'condition': 'rainy',
'datetime': '2024-11-23T12:00:00+00:00',
'precipitation': 0.25,
'precipitation_probability': 61,
'pressure': 987.5,
'temperature': 9.3,
'uv_index': 1,
'wind_bearing': 176,
'wind_gust_speed': 55.55,
'wind_speed': 28.33,
}),
dict({
'apparent_temperature': 6.8,
'condition': 'rainy',
@@ -2453,6 +2580,19 @@
# ---
# name: test_forecast_subscription.1
list([
dict({
'apparent_temperature': 5.8,
'condition': 'rainy',
'datetime': '2024-11-23T12:00:00+00:00',
'precipitation': 0.25,
'precipitation_probability': 61,
'pressure': 987.5,
'temperature': 9.3,
'uv_index': 1,
'wind_bearing': 176,
'wind_gust_speed': 55.55,
'wind_speed': 28.33,
}),
dict({
'apparent_temperature': 6.8,
'condition': 'rainy',