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

Fix exception when parts of Pollen.com can't be reached
This commit is contained in:
Aaron Bach
2018-07-04 17:30:15 -06:00
committed by GitHub
parent 91d6d0df84
commit f65c3940ae

View File

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