Fix exception when parts of Pollen.com can't be reached (#15296)

Fix exception when parts of Pollen.com can't be reached
pull/15281/merge
Aaron Bach 2018-07-04 17:30:15 -06:00 committed by GitHub
parent 91d6d0df84
commit f65c3940ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -183,9 +183,12 @@ class PollencomSensor(Entity):
return
if self._category:
data = self.pollencom.data[self._category]['Location']
data = self.pollencom.data[self._category].get('Location')
else:
data = self.pollencom.data[self._type]['Location']
data = self.pollencom.data[self._type].get('Location')
if not data:
return
indices = [p['Index'] for p in data['periods']]
average = round(mean(indices), 1)