diff --git a/homeassistant/components/dnsip/sensor.py b/homeassistant/components/dnsip/sensor.py index 07509a02f864c..adadfd5e23d5d 100644 --- a/homeassistant/components/dnsip/sensor.py +++ b/homeassistant/components/dnsip/sensor.py @@ -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( diff --git a/homeassistant/components/metoffice/weather.py b/homeassistant/components/metoffice/weather.py index 04a2c0fd5b852..5624faebfb2a2 100644 --- a/homeassistant/components/metoffice/weather.py +++ b/homeassistant/components/metoffice/weather.py @@ -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 @@ -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 @@ -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 ] diff --git a/tests/components/metoffice/snapshots/test_weather.ambr b/tests/components/metoffice/snapshots/test_weather.ambr index 74b54d1bc2fe5..2fcef6f088be2 100644 --- a/tests/components/metoffice/snapshots/test_weather.ambr +++ b/tests/components/metoffice/snapshots/test_weather.ambr @@ -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',