mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Fix unhandled exception when IQVIA API fails to return data (#43359)
This commit is contained in:
parent
be39104a36
commit
3ffd97acd4
@ -155,6 +155,9 @@ class IQVIAEntity(CoordinatorEntity):
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
"""Handle updated data from the coordinator."""
|
||||
if not self.coordinator.last_update_success:
|
||||
return
|
||||
|
||||
self.update_from_latest_data()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
@ -105,6 +105,7 @@ class ForecastSensor(IQVIAEntity):
|
||||
def update_from_latest_data(self):
|
||||
"""Update the sensor."""
|
||||
data = self.coordinator.data.get("Location")
|
||||
|
||||
if not data or not data.get("periods"):
|
||||
return
|
||||
|
||||
@ -142,6 +143,9 @@ class IndexSensor(IQVIAEntity):
|
||||
@callback
|
||||
def update_from_latest_data(self):
|
||||
"""Update the sensor."""
|
||||
if not self.coordinator.last_update_success:
|
||||
return
|
||||
|
||||
try:
|
||||
if self._type in (TYPE_ALLERGY_TODAY, TYPE_ALLERGY_TOMORROW):
|
||||
data = self.coordinator.data.get("Location")
|
||||
|
Loading…
x
Reference in New Issue
Block a user