From f08bfdc748d53fa3748e2714f50b32de7606369f Mon Sep 17 00:00:00 2001 From: Andrew <34544450+10100011@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:44:12 +0000 Subject: [PATCH 1/2] Bump pyopenweathermap to v0.2.1 --- .../components/openweathermap/coordinator.py | 13 +++++++------ .../components/openweathermap/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/openweathermap/coordinator.py b/homeassistant/components/openweathermap/coordinator.py index f7672a1290bc5..3ef0eda0c8fbd 100644 --- a/homeassistant/components/openweathermap/coordinator.py +++ b/homeassistant/components/openweathermap/coordinator.py @@ -192,12 +192,13 @@ def _calc_precipitation_kind(rain, snow): @staticmethod def _get_precipitation_value(precipitation): """Get precipitation value from weather data.""" - if "all" in precipitation: - return round(precipitation["all"], 2) - if "3h" in precipitation: - return round(precipitation["3h"], 2) - if "1h" in precipitation: - return round(precipitation["1h"], 2) + if precipitation is not None: + if "all" in precipitation: + return round(precipitation["all"], 2) + if "3h" in precipitation: + return round(precipitation["3h"], 2) + if "1h" in precipitation: + return round(precipitation["1h"], 2) return 0 def _get_condition(self, weather_code, timestamp=None): diff --git a/homeassistant/components/openweathermap/manifest.json b/homeassistant/components/openweathermap/manifest.json index 199e750ad4f3f..14313a5a77e84 100644 --- a/homeassistant/components/openweathermap/manifest.json +++ b/homeassistant/components/openweathermap/manifest.json @@ -6,5 +6,5 @@ "documentation": "https://www.home-assistant.io/integrations/openweathermap", "iot_class": "cloud_polling", "loggers": ["pyopenweathermap"], - "requirements": ["pyopenweathermap==0.1.1"] + "requirements": ["pyopenweathermap==0.2.1"] } diff --git a/requirements_all.txt b/requirements_all.txt index 1585b35f3dda0..1fa221b60fe56 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2113,7 +2113,7 @@ pyombi==0.1.10 pyopenuv==2023.02.0 # homeassistant.components.openweathermap -pyopenweathermap==0.1.1 +pyopenweathermap==0.2.1 # homeassistant.components.opnsense pyopnsense==0.4.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index de1c7c0b915cc..e5b2ea0b9731f 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1700,7 +1700,7 @@ pyoctoprintapi==0.1.12 pyopenuv==2023.02.0 # homeassistant.components.openweathermap -pyopenweathermap==0.1.1 +pyopenweathermap==0.2.1 # homeassistant.components.opnsense pyopnsense==0.4.0 From 538b6e83a82f68a3d16422ad6b842cd4412e90ed Mon Sep 17 00:00:00 2001 From: Andrew <34544450+10100011@users.noreply.github.com> Date: Mon, 21 Oct 2024 12:37:52 +0000 Subject: [PATCH 2/2] Adding required test / correcting constructor --- tests/components/openweathermap/test_config_flow.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/components/openweathermap/test_config_flow.py b/tests/components/openweathermap/test_config_flow.py index f18aa432e2f1e..aec343607544a 100644 --- a/tests/components/openweathermap/test_config_flow.py +++ b/tests/components/openweathermap/test_config_flow.py @@ -7,6 +7,7 @@ CurrentWeather, DailyTemperature, DailyWeatherForecast, + MinutelyWeatherForecast, RequestError, WeatherCondition, WeatherReport, @@ -105,7 +106,12 @@ def _create_mocked_owm_factory(is_valid: bool): rain=0, snow=0, ) - weather_report = WeatherReport(current_weather, [], [daily_weather_forecast]) + minutely_weather_forecast = MinutelyWeatherForecast( + date_time=1728672360, precipitation=2.54 + ) + weather_report = WeatherReport( + current_weather, [minutely_weather_forecast], [], [daily_weather_forecast] + ) mocked_owm_client = MagicMock() mocked_owm_client.validate_key = AsyncMock(return_value=is_valid)