Skip to content

Commit

Permalink
Use next hourly forecast for missing conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldavie committed Jul 12, 2019
1 parent 7da65c8 commit 93f9be3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions homeassistant/components/environment_canada/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def temperature(self):
"""Return the temperature."""
if self.ec_data.conditions.get('temperature').get('value'):
return float(self.ec_data.conditions['temperature']['value'])
if self.ec_data.hourly_forecasts[0].get('temperature'):
return float(self.ec_data.hourly_forecasts[0]['temperature'])
return None

@property
Expand Down Expand Up @@ -148,12 +150,15 @@ def visibility(self):
@property
def condition(self):
"""Return the weather condition."""
icon_code = self.ec_data.conditions.get('icon_code').get('value')
icon_code = None

if self.ec_data.conditions.get('icon_code').get('value'):
icon_code = self.ec_data.conditions['icon_code']['value']
elif self.ec_data.hourly_forecasts[0].get('icon_code'):
icon_code = self.ec_data.hourly_forecasts[0]['icon_code']

if icon_code:
return icon_code_to_condition(int(icon_code))
condition = self.ec_data.conditions.get('condition').get('value')
if condition:
return condition
return ''

@property
Expand Down

0 comments on commit 93f9be3

Please sign in to comment.