Skip to content

Commit

Permalink
Update collector.py
Browse files Browse the repository at this point in the history
Fix rain_amount_max being from being unknown. If it is missing, it will take the same value as rain_amount_min
  • Loading branch information
bremor authored Nov 13, 2020
1 parent c28dd05 commit 3553447
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions custom_components/bureau_of_meteorology/PyBoM/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3553447

Please sign in to comment.