diff --git a/homeassistant/components/iqvia/__init__.py b/homeassistant/components/iqvia/__init__.py index d730b406896..db0df3a073b 100644 --- a/homeassistant/components/iqvia/__init__.py +++ b/homeassistant/components/iqvia/__init__.py @@ -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() diff --git a/homeassistant/components/iqvia/sensor.py b/homeassistant/components/iqvia/sensor.py index e53ee96b1c4..48ec1cf97b1 100644 --- a/homeassistant/components/iqvia/sensor.py +++ b/homeassistant/components/iqvia/sensor.py @@ -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")