From 3553447ce7a60fe26bde4c480cfbdec5e3a0b316 Mon Sep 17 00:00:00 2001 From: bremor <34525505+bremor@users.noreply.github.com> Date: Fri, 13 Nov 2020 13:28:29 +1100 Subject: [PATCH] Update collector.py Fix rain_amount_max being from being unknown. If it is missing, it will take the same value as rain_amount_min --- .../bureau_of_meteorology/PyBoM/collector.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/custom_components/bureau_of_meteorology/PyBoM/collector.py b/custom_components/bureau_of_meteorology/PyBoM/collector.py index 53590a4..3b22fa1 100644 --- a/custom_components/bureau_of_meteorology/PyBoM/collector.py +++ b/custom_components/bureau_of_meteorology/PyBoM/collector.py @@ -121,9 +121,14 @@ async def flatten_forecast_data(self): flattened["uv_end_time"] = uv["end_time"] rain = self.daily_forecasts_data["data"][day]["rain"] - flattened["rain_amount_min"] = rain["amount"]["min"] - flattened["rain_amount_max"] = rain["amount"]["max"] flattened["rain_chance"] = rain["chance"] + flattened["rain_amount_min"] = rain["amount"]["min"] + + # When rain amount max is None, set as rain amount min + if rain["amount"]["max"] is None: + flattened["rain_amount_max"] = flattened["rain_amount_min"] + else: + flattened["rain_amount_max"] = rain["amount"]["max"] self.daily_forecasts_data["data"][day].update(flattened)