Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion homeassistant/components/dnsip/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ async def async_update(self) -> None:
try:
async with asyncio.timeout(10):
response = await self.resolver.query(self.hostname, self.querytype)
except TimeoutError:
except TimeoutError as err:
_LOGGER.debug("Timeout while resolving host: %s", err)
await self.resolver.close()
except DNSError as err:
_LOGGER.warning("Exception while resolving host: %s", err)
await self.resolver.close()

if response:
sorted_ips = sort_ips(
Expand Down
15 changes: 12 additions & 3 deletions homeassistant/components/metoffice/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,13 @@ def _async_forecast_daily(self) -> list[WeatherForecast] | None:
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
Expand All @@ -285,10 +288,13 @@ def _async_forecast_hourly(self) -> list[WeatherForecast] | None:
)

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
Expand All @@ -299,8 +305,11 @@ def _async_forecast_twice_daily(self) -> list[WeatherForecast] | None:
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
]
140 changes: 140 additions & 0 deletions tests/components/metoffice/snapshots/test_weather.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
Loading