Fix IQVIA failing to start if any API call fails (#50615)

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
Aaron Bach 2021-05-14 15:23:16 -06:00 committed by GitHub
parent 960ed13f94
commit 9c5f1b4406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -104,9 +104,12 @@ class ForecastSensor(IQVIAEntity):
@callback
def update_from_latest_data(self):
"""Update the sensor."""
data = self.coordinator.data.get("Location")
if not self.coordinator.data:
return
if not data or not data.get("periods"):
data = self.coordinator.data.get("Location", {})
if not data.get("periods"):
return
indices = [p["Index"] for p in data["periods"]]