mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 12:15:08 +02:00
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:
@@ -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)
|
||||||
|
Reference in New Issue
Block a user